aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-17 16:23:08 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-17 16:23:08 -0400
commitd3a25c980fc231238256f8d80816367674e5caaf (patch)
treeb6e35c533d84c7e5b43c704c1a9ca547bc3b4d87 /net/ipv4
parenta6ff1a2f1e91578860b37df9fd861ef7af207de4 (diff)
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/ipv4')
-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 a5bd0b4acc61..812e4447a223 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
1347 return oldest; 1347 return oldest;
1348} 1348}
1349 1349
1350static inline u32 fnhe_hashfun(__be32 daddr)
1351{
1352 u32 hval;
1353
1354 hval = (__force u32) daddr;
1355 hval ^= (hval >> 11) ^ (hval >> 22);
1356
1357 return hval & (FNHE_HASH_SIZE - 1);
1358}
1359
1350static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 daddr) 1360static struct fib_nh_exception *find_or_create_fnhe(struct fib_nh *nh, __be32 daddr)
1351{ 1361{
1352 struct fnhe_hash_bucket *hash = nh->nh_exceptions; 1362 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 return NULL; 1371 return NULL;
1362 } 1372 }
1363 1373
1364 hval = (__force u32) daddr; 1374 hval = fnhe_hashfun(daddr);
1365 hval ^= (hval >> 11) ^ (hval >> 22);
1366 hash += hval; 1375 hash += hval;
1367 1376
1368 depth = 0; 1377 depth = 0;
@@ -1890,8 +1899,7 @@ static void rt_bind_exception(struct rtable *rt, struct fib_nh *nh, __be32 daddr
1890 struct fib_nh_exception *fnhe; 1899 struct fib_nh_exception *fnhe;
1891 u32 hval; 1900 u32 hval;
1892 1901
1893 hval = (__force u32) daddr; 1902 hval = fnhe_hashfun(daddr);
1894 hval ^= (hval >> 11) ^ (hval >> 22);
1895 1903
1896 for (fnhe = rcu_dereference(hash[hval].chain); fnhe; 1904 for (fnhe = rcu_dereference(hash[hval].chain); fnhe;
1897 fnhe = rcu_dereference(fnhe->fnhe_next)) { 1905 fnhe = rcu_dereference(fnhe->fnhe_next)) {