mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 21:51:05 +00:00
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:
parent
33de014c63
commit
0b4419162a
5 changed files with 30 additions and 5 deletions
|
@ -38,6 +38,7 @@ struct udphdr {
|
|||
#ifdef __KERNEL__
|
||||
#include <net/inet_sock.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/netns/hash.h>
|
||||
|
||||
static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
|
||||
{
|
||||
|
@ -48,7 +49,7 @@ static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
|
|||
|
||||
static inline int udp_hashfn(struct net *net, const unsigned num)
|
||||
{
|
||||
return num & (UDP_HTABLE_SIZE - 1);
|
||||
return (num + net_hash_mix(net)) & (UDP_HTABLE_SIZE - 1);
|
||||
}
|
||||
|
||||
struct udp_sock {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue