Commit d3a25c98 authored by David S. Miller's avatar David S. Miller

ipv4: Fix nexthop exception hash computation.

Need to mask it with (FNHE_HASH_SIZE - 1).
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a6ff1a2f
...@@ -1347,6 +1347,16 @@ static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash, __be3 ...@@ -1347,6 +1347,16 @@ static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash, __be3
return oldest; return oldest;
} }
static inline u32 fnhe_hashfun(__be32 daddr)
{
u32 hval;
hval = (__force u32) daddr;
hval ^= (hval >> 11) ^ (hval >> 22);
return hval & (FNHE_HASH_SIZE - 1);
}
static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 daddr) static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 daddr)
{ {
struct fnhe_hash_bucket *hash = nh->nh_exceptions; struct fnhe_hash_bucket *hash = nh->nh_exceptions;
...@@ -1361,8 +1371,7 @@ static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 da ...@@ -1361,8 +1371,7 @@ static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 da
return NULL; return NULL;
} }
hval = (__force u32) daddr; hval = fnhe_hashfun(daddr);
hval ^= (hval >> 11) ^ (hval >> 22);
hash += hval; hash += hval;
depth = 0; depth = 0;
...@@ -1890,8 +1899,7 @@ static void rt_bind_exception(struct rtable *rt, struct fib_nh *nh, __be32 daddr ...@@ -1890,8 +1899,7 @@ static void rt_bind_exception(struct rtable *rt, struct fib_nh *nh, __be32 daddr
struct fib_nh_exception *fnhe; struct fib_nh_exception *fnhe;
u32 hval; u32 hval;
hval = (__force u32) daddr; hval = fnhe_hashfun(daddr);
hval ^= (hval >> 11) ^ (hval >> 22);
for (fnhe = rcu_dereference(hash[hval].chain); fnhe; for (fnhe = rcu_dereference(hash[hval].chain); fnhe;
fnhe = rcu_dereference(fnhe->fnhe_next)) { fnhe = rcu_dereference(fnhe->fnhe_next)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment