diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-04-10 04:54:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-10 04:54:01 -0400 |
commit | 1294fc4a4868d7e83ff749597fbf4e9d5f4d1aa0 (patch) | |
tree | 164465f16a896a40c04ed8398498809bb7d1e918 /net/ipv4/route.c | |
parent | 5969f71d57928511b9cd8744aaf1ed9bc5e88ea2 (diff) |
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>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index d758ea1d80f6..7cdd2bf88e0c 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -259,16 +259,14 @@ static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); | |||
259 | #define RT_CACHE_STAT_INC(field) \ | 259 | #define RT_CACHE_STAT_INC(field) \ |
260 | (__raw_get_cpu_var(rt_cache_stat).field++) | 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 | & rt_hash_mask; | 267 | & rt_hash_mask; |
266 | } | 268 | } |
267 | 269 | ||
268 | #define rt_hash(daddr, saddr, idx) \ | ||
269 | rt_hash_code((__force u32)(__be32)(daddr),\ | ||
270 | (__force u32)(__be32)(saddr) ^ ((idx) << 5)) | ||
271 | |||
272 | #ifdef CONFIG_PROC_FS | 270 | #ifdef CONFIG_PROC_FS |
273 | struct rt_cache_iter_state { | 271 | struct rt_cache_iter_state { |
274 | struct seq_net_private p; | 272 | struct seq_net_private p; |