From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCHv5 3/3] batman-adv: Modified forwarding behaviour for multicast packets
Date: Fri, 14 Jun 2013 16:30:28 +0200 [thread overview]
Message-ID: <20130614143028.GA26907@pandem0nium> (raw)
In-Reply-To: <1371200525-2011-4-git-send-email-linus.luessing@web.de>
[-- Attachment #1: Type: text/plain, Size: 2741 bytes --]
On Fri, Jun 14, 2013 at 11:02:05AM +0200, Linus Lüssing wrote:
> /**
> + * batadv_tt_orig_entries_count - count the number of originators
> + * @head: a list of originators
> + *
> + * Return the number of originator entries in the given list.
> + *
> + * The caller needs to hold the rcu_read_lock().
> + */
> +static int batadv_tt_orig_entries_count(struct hlist_head *head)
> +{
> + struct batadv_tt_orig_list_entry *orig_entry;
> + int count = 0;
> +
> + hlist_for_each_entry_rcu(orig_entry, head, list) {
> + if (!atomic_read(&orig_entry->refcount))
> + continue;
> +
> + count++;
> + }
> +
> + return count;
> +}
> +
> +/**
> + * batadv_tt_global_hash_count - count the number of orig entries
> + * @hash: hash table containing the tt entries
> + * @addr: the mac address of the client to count entries for
> + * @vid: VLAN identifier
> + *
> + * Return the number of originators advertising the given address/data
> + * (excluding ourself).
> + */
> +int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
> + const uint8_t *addr, unsigned short vid)
> +{
> + struct hlist_head *head, *orig_list;
> + struct batadv_tt_common_entry to_search, *tt_common_entry;
> + struct batadv_tt_global_entry *tt_global_entry;
> + uint32_t index;
> + int count = 0;
> +
> + if (!bat_priv->tt.global_hash)
> + goto out;
> +
> + memcpy(to_search.addr, addr, ETH_ALEN);
> + to_search.vid = vid;
> +
> + index = batadv_choose_tt(&to_search, bat_priv->tt.global_hash->size);
> + head = &bat_priv->tt.global_hash->table[index];
> +
> + rcu_read_lock();
> + hlist_for_each_entry_rcu(tt_common_entry, head, hash_entry) {
> + if (!batadv_compare_eth(tt_common_entry, addr))
> + continue;
> +
> + if (!atomic_read(&tt_common_entry->refcount))
> + continue;
> +
> + tt_global_entry = container_of(tt_common_entry,
> + struct batadv_tt_global_entry,
> + common);
> + orig_list = &tt_global_entry->orig_list;
> + count = batadv_tt_orig_entries_count(orig_list);
> + break;
> + }
> + rcu_read_unlock();
> +
> +out:
> + return count;
> +}
> +
> +/**
I've been thinking about this part ... it is not good to iterate over the whole
hash for every multicast packet - this is the fastpath after all, so it's critical.
Can't you just use batadv_tt_global_hash_find(), count the list entries within
struct batadv_tt_global_entry (or find out if it is empty, one entry or more
than one entry) and be done? This should be much faster.
Apart from that, the patch series appears to be pretty mature now, I've done
some more testing in my VMs and it looks good. Should be (hopefully) the last
thing from my side. :)
Cheers,
Simon
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-06-14 14:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 9:02 [B.A.T.M.A.N.] Basic Multicast Optimizations Linus Lüssing
2013-06-14 9:02 ` [B.A.T.M.A.N.] [PATCHv5 1/3] batman-adv: Multicast Listener Announcements via Translation Table Linus Lüssing
2013-06-14 9:02 ` [B.A.T.M.A.N.] [PATCHv5 2/3] batman-adv: Announce new capability via multicast TVLV Linus Lüssing
2013-06-14 9:02 ` [B.A.T.M.A.N.] [PATCHv5 3/3] batman-adv: Modified forwarding behaviour for multicast packets Linus Lüssing
2013-06-14 14:30 ` Simon Wunderlich [this message]
2013-06-14 15:50 ` Linus Lüssing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130614143028.GA26907@pandem0nium \
--to=simon.wunderlich@s2003.tu-chemnitz.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox