aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/arp.h
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2012-08-08 17:52:28 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-09 19:18:06 -0400
commitb14f243a42c7aa43de71f878641acd003f223022 (patch)
tree13d052f3d3eab915c26eadd9a1f6997aef168998 /include/net/arp.h
parenta399a8053164ec8bcb06fed52be9941a26ecde11 (diff)
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/arp.h')
-rw-r--r--include/net/arp.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/arp.h b/include/net/arp.h
index 7f7df93f37cd..b630dae03411 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -3,6 +3,7 @@
3#define _ARP_H 3#define _ARP_H
4 4
5#include <linux/if_arp.h> 5#include <linux/if_arp.h>
6#include <linux/hash.h>
6#include <net/neighbour.h> 7#include <net/neighbour.h>
7 8
8 9
@@ -10,7 +11,7 @@ extern struct neigh_table arp_tbl;
10 11
11static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) 12static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
12{ 13{
13 u32 val = key ^ dev->ifindex; 14 u32 val = key ^ hash32_ptr(dev);
14 15
15 return val * hash_rnd; 16 return val * hash_rnd;
16} 17}