>From 4fad2467644857ccd9833340792a9717b51ee573 Mon Sep 17 00:00:00 2001 From: David S. Miller Date: Mon, 11 Jul 2011 01:37:28 -0700 Subject: [PATCH 05/13] ipv4: Use universal hash for ARP. We need to make sure the multiplier is odd. Signed-off-by: David S. Miller --- include/net/arp.h | 7 +++++++ net/core/neighbour.c | 1 + net/ipv4/arp.c | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index 91f0568..723bde5 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -8,6 +8,13 @@ extern struct neigh_table arp_tbl; +static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) +{ + u32 val = key ^ dev->ifindex; + + return val * hash_rnd; +} + extern void arp_init(void); extern int arp_find(unsigned char *haddr, struct sk_buff *skb); extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg); diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 60e2249..2d02723 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -334,6 +334,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift) ret->hash_buckets = buckets; ret->hash_shift = shift; get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd)); + ret->hash_rnd |= 1; return ret; } diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index c098239..f7afb4c 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -97,7 +97,6 @@ #include #include #include -#include #include #ifdef CONFIG_SYSCTL #include @@ -232,7 +231,7 @@ static u32 arp_hash(const void *pkey, const struct net_device *dev, __u32 hash_rnd) { - return jhash_2words(*(u32 *)pkey, dev->ifindex, hash_rnd); + return arp_hashfn(*(u32 *)pkey, dev, hash_rnd); } static int arp_constructor(struct neighbour *neigh) -- 1.7.1