Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IPV4: route use jhash3

Since route hash is a triple, use jhash_3words rather doing the mixing
directly. This should be as fast and give better distribution.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stephen Hemminger and committed by
David S. Miller
1294fc4a 5969f71d

+4 -6
+4 -6
net/ipv4/route.c
··· 259 259 #define RT_CACHE_STAT_INC(field) \ 260 260 (__raw_get_cpu_var(rt_cache_stat).field++) 261 261 262 - static unsigned int rt_hash_code(u32 daddr, u32 saddr) 262 + static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx) 263 263 { 264 - return jhash_2words(daddr, saddr, atomic_read(&rt_genid)) 264 + return jhash_3words((__force u32)(__be32)(daddr), 265 + (__force u32)(__be32)(saddr), 266 + idx, atomic_read(&rt_genid)) 265 267 & rt_hash_mask; 266 268 } 267 - 268 - #define rt_hash(daddr, saddr, idx) \ 269 - rt_hash_code((__force u32)(__be32)(daddr),\ 270 - (__force u32)(__be32)(saddr) ^ ((idx) << 5)) 271 269 272 270 #ifdef CONFIG_PROC_FS 273 271 struct rt_cache_iter_state {