summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-17 13:23:08 -0700
committerDavid S. Miller <davem@davemloft.net>2012-07-17 13:23:08 -0700
commitd3a25c980fc231238256f8d80816367674e5caaf (patch)
treeb6e35c533d84c7e5b43c704c1a9ca547bc3b4d87 /net
parenta6ff1a2f1e91578860b37df9fd861ef7af207de4 (diff)
downloadlinux-3.10-d3a25c980fc231238256f8d80816367674e5caaf.tar.gz
linux-3.10-d3a25c980fc231238256f8d80816367674e5caaf.tar.bz2
linux-3.10-d3a25c980fc231238256f8d80816367674e5caaf.zip
ipv4: Fix nexthop exception hash computation.
Need to mask it with (FNHE_HASH_SIZE - 1). Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a5bd0b4acc6..812e4447a22 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1347,6 +1347,16 @@ static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash, __be3
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)
{
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
return NULL;
}
- hval = (__force u32) daddr;
- hval ^= (hval >> 11) ^ (hval >> 22);
+ hval = fnhe_hashfun(daddr);
hash += hval;
depth = 0;
@@ -1890,8 +1899,7 @@ static void rt_bind_exception(struct rtable *rt, struct fib_nh *nh, __be32 daddr
struct fib_nh_exception *fnhe;
u32 hval;
- hval = (__force u32) daddr;
- hval ^= (hval >> 11) ^ (hval >> 22);
+ hval = fnhe_hashfun(daddr);
for (fnhe = rcu_dereference(hash[hval].chain); fnhe;
fnhe = rcu_dereference(fnhe->fnhe_next)) {