From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>, "Maciej Żenczykowski" <maze@google.com>
Subject: [PATCH net-next] macvlan: add a salt to mc_hash()
Date: Thu, 07 Feb 2013 18:41:02 -0800 [thread overview]
Message-ID: <1360291262.28557.89.camel@edumazet-glaptop> (raw)
From: Eric Dumazet <edumazet@google.com>
Some multicast addresses are common to all macvlans,
so if a multicast message has a hash value collision, we
have to deliver a copy to all macvlans, adding significant
latency and possible packet drops if netdev_max_backlog
limit is hit.
Having a per macvlan hash function permits to reduce the
impact of hash collisions.
Suggested-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
Should be applied after
"macvlan: broadcast addr should be part of mc_filter"
drivers/net/macvlan.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index ce7c926..e4b8078 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -127,10 +127,18 @@ static int macvlan_broadcast_one(struct sk_buff *skb,
return vlan->receive(skb);
}
-static unsigned int mc_hash(const unsigned char *addr)
+static u32 macvlan_hash_mix(const struct macvlan_dev *vlan)
+{
+ return (u32)(((unsigned long)vlan) >> L1_CACHE_SHIFT);
+}
+
+
+static unsigned int mc_hash(const struct macvlan_dev *vlan,
+ const unsigned char *addr)
{
u32 val = __get_unaligned_cpu32(addr + 2);
+ val ^= macvlan_hash_mix(vlan);
return hash_32(val, MACVLAN_MC_FILTER_BITS);
}
@@ -145,7 +153,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
struct sk_buff *nskb;
unsigned int i;
int err;
- unsigned int hash = mc_hash(eth->h_dest);
+ unsigned int hash;
if (skb->protocol == htons(ETH_P_PAUSE))
return;
@@ -155,6 +163,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
if (vlan->dev == src || !(vlan->mode & mode))
continue;
+ hash = mc_hash(vlan, eth->h_dest);
if (!test_bit(hash, vlan->mc_filter))
continue;
nskb = skb_clone(skb, GFP_ATOMIC);
@@ -424,10 +433,10 @@ static void macvlan_set_mac_lists(struct net_device *dev)
bitmap_zero(filter, MACVLAN_MC_FILTER_SZ);
netdev_for_each_mc_addr(ha, dev) {
- __set_bit(mc_hash(ha->addr), filter);
+ __set_bit(mc_hash(vlan, ha->addr), filter);
}
- __set_bit(mc_hash(dev->broadcast), filter);
+ __set_bit(mc_hash(vlan, dev->broadcast), filter);
bitmap_copy(vlan->mc_filter, filter, MACVLAN_MC_FILTER_SZ);
}
next reply other threads:[~2013-02-08 2:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 2:41 Eric Dumazet [this message]
2013-02-08 5:07 ` [PATCH net-next] macvlan: add a salt to mc_hash() Maciej Żenczykowski
2013-02-08 22:57 ` David Miller
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=1360291262.28557.89.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=maze@google.com \
--cc=netdev@vger.kernel.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