aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/hash.h10
-rw-r--r--include/net/arp.h3
-rw-r--r--include/net/ndisc.h3
3 files changed, 14 insertions, 2 deletions
diff --git a/include/linux/hash.h b/include/linux/hash.h
index b80506bdd733..24df9e70406f 100644
--- a/include/linux/hash.h
+++ b/include/linux/hash.h
@@ -67,4 +67,14 @@ static inline unsigned long hash_ptr(const void *ptr, unsigned int bits)
67{ 67{
68 return hash_long((unsigned long)ptr, bits); 68 return hash_long((unsigned long)ptr, bits);
69} 69}
70
71static inline u32 hash32_ptr(const void *ptr)
72{
73 unsigned long val = (unsigned long)ptr;
74
75#if BITS_PER_LONG == 64
76 val ^= (val >> 32);
77#endif
78 return (u32)val;
79}
70#endif /* _LINUX_HASH_H */ 80#endif /* _LINUX_HASH_H */
diff --git a/include/net/arp.h b/include/net/arp.h
index 7f7df93f37cd..b630dae03411 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -3,6 +3,7 @@
3#define _ARP_H 3#define _ARP_H
4 4
5#include <linux/if_arp.h> 5#include <linux/if_arp.h>
6#include <linux/hash.h>
6#include <net/neighbour.h> 7#include <net/neighbour.h>
7 8
8 9
@@ -10,7 +11,7 @@ extern struct neigh_table arp_tbl;
10 11
11static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) 12static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
12{ 13{
13 u32 val = key ^ dev->ifindex; 14 u32 val = key ^ hash32_ptr(dev);
14 15
15 return val * hash_rnd; 16 return val * hash_rnd;
16} 17}
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 96a3b5c03e37..980d263765cf 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -49,6 +49,7 @@ enum {
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/if_arp.h> 50#include <linux/if_arp.h>
51#include <linux/netdevice.h> 51#include <linux/netdevice.h>
52#include <linux/hash.h>
52 53
53#include <net/neighbour.h> 54#include <net/neighbour.h>
54 55
@@ -134,7 +135,7 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _
134{ 135{
135 const u32 *p32 = pkey; 136 const u32 *p32 = pkey;
136 137
137 return (((p32[0] ^ dev->ifindex) * hash_rnd[0]) + 138 return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
138 (p32[1] * hash_rnd[1]) + 139 (p32[1] * hash_rnd[1]) +
139 (p32[2] * hash_rnd[2]) + 140 (p32[2] * hash_rnd[2]) +
140 (p32[3] * hash_rnd[3])); 141 (p32[3] * hash_rnd[3]));