aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2009-11-10 02:20:34 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-11 22:22:12 -0500
commit08e9897d512fe7a67e46209543b3815b57a36dc7 (patch)
tree0fad8d5d896a0b191f2df1425afa9565041dedae /net/core
parent7e5ca6a22de8fa79897daae51d76b473e44f8066 (diff)
netdev: fold name hash properly (v3)
The full_name_hash function does not produce well distributed values in the lower bits, so most code uses hash_32() to fold it. This is really a bug introduced when name hashing was added, back in 2.5 when I added name hashing. hash_32 is all that is needed since full_name_hash returns unsigned int which is only 32 bits on 64 bit platforms. Also, there is no point in using hash_32 on ifindex, because the is naturally sequential and usually well distributed. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index bf629ac08b87..ad8e320ceba7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -79,6 +79,7 @@
79#include <linux/cpu.h> 79#include <linux/cpu.h>
80#include <linux/types.h> 80#include <linux/types.h>
81#include <linux/kernel.h> 81#include <linux/kernel.h>
82#include <linux/hash.h>
82#include <linux/sched.h> 83#include <linux/sched.h>
83#include <linux/mutex.h> 84#include <linux/mutex.h>
84#include <linux/string.h> 85#include <linux/string.h>
@@ -196,7 +197,7 @@ EXPORT_SYMBOL(dev_base_lock);
196static inline struct hlist_head *dev_name_hash(struct net *net, const char *name) 197static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
197{ 198{
198 unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ)); 199 unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
199 return &net->dev_name_head[hash & (NETDEV_HASHENTRIES - 1)]; 200 return &net->dev_name_head[hash_32(hash, NETDEV_HASHBITS)];
200} 201}
201 202
202static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex) 203static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex)