netns: introduce the net_hash_mix "salt" for hashes

There are many possible ways to add this "salt", thus I made this
patch to be the last in the series to change it if required.

Currently I propose to use the struct net pointer itself as this 
salt, but since this pointer is most often cache-line aligned, shift 
this right to eliminate the bits, that are most often zeroed.

After this, simply add this mix to prepared hashfn-s.

For CONFIG_NET_NS=n case this salt is 0 and no changes in hashfn
appear.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Pavel Emelyanov
2008-06-16 17:14:11 -07:00
committed by David S. Miller
parent 33de014c63
commit 0b4419162a
5 changed files with 30 additions and 5 deletions

View File

@@ -25,6 +25,7 @@
#include <net/sock.h>
#include <net/request_sock.h>
#include <net/route.h>
#include <net/netns/hash.h>
/** struct ip_options - IP Options
*
@@ -178,7 +179,7 @@ static inline unsigned int inet_ehashfn(struct net *net,
return jhash_3words((__force __u32) laddr,
(__force __u32) faddr,
((__u32) lport) << 16 | (__force __u32)fport,
inet_ehash_secret);
inet_ehash_secret + net_hash_mix(net));
}
static inline int inet_sk_ehashfn(const struct sock *sk)