summaryrefslogtreecommitdiffstats
path: root/include/net/ndisc.h
diff options
context:
space:
mode:
authorPavel Emelyanov2012-08-08 23:52:28 +0200
committerDavid S. Miller2012-08-10 01:18:06 +0200
commitb14f243a42c7aa43de71f878641acd003f223022 (patch)
tree13d052f3d3eab915c26eadd9a1f6997aef168998 /include/net/ndisc.h
parenttime: jiffies_delta_to_clock_t() helper to the rescue (diff)
downloadkernel-qcow2-linux-b14f243a42c7aa43de71f878641acd003f223022.tar.gz
kernel-qcow2-linux-b14f243a42c7aa43de71f878641acd003f223022.tar.xz
kernel-qcow2-linux-b14f243a42c7aa43de71f878641acd003f223022.zip
net: Dont use ifindices in hash fns
Eric noticed, that when there will be devices with equal indices, some hash functions that use them will become less effective as they could. Fix this in advance by mixing the net_device address into the hash value instead of the device index. This is true for arp and ndisc hash fns. The netlabel, can and llc ones are also ifindex-based, but that three are init_net-only, thus will not be affected. Many thanks to David and Eric for the hash32_ptr implementation! Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ndisc.h')
-rw-r--r--include/net/ndisc.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 96a3b5c03e37..980d263765cf 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -49,6 +49,7 @@ enum {
#include <linux/types.h>
#include <linux/if_arp.h>
#include <linux/netdevice.h>
+#include <linux/hash.h>
#include <net/neighbour.h>
@@ -134,7 +135,7 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _
{
const u32 *p32 = pkey;
- return (((p32[0] ^ dev->ifindex) * hash_rnd[0]) +
+ return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
(p32[1] * hash_rnd[1]) +
(p32[2] * hash_rnd[2]) +
(p32[3] * hash_rnd[3]));