diff options
Diffstat (limited to 'net/ipv6/inet6_hashtables.c')
| -rw-r--r-- | net/ipv6/inet6_hashtables.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 842d833dfc18..262e13c02ec2 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
| @@ -23,6 +23,39 @@ | |||
| 23 | #include <net/secure_seq.h> | 23 | #include <net/secure_seq.h> |
| 24 | #include <net/ip.h> | 24 | #include <net/ip.h> |
| 25 | 25 | ||
| 26 | static unsigned int inet6_ehashfn(struct net *net, | ||
| 27 | const struct in6_addr *laddr, | ||
| 28 | const u16 lport, | ||
| 29 | const struct in6_addr *faddr, | ||
| 30 | const __be16 fport) | ||
| 31 | { | ||
| 32 | static u32 inet6_ehash_secret __read_mostly; | ||
| 33 | static u32 ipv6_hash_secret __read_mostly; | ||
| 34 | |||
| 35 | u32 lhash, fhash; | ||
| 36 | |||
| 37 | net_get_random_once(&inet6_ehash_secret, sizeof(inet6_ehash_secret)); | ||
| 38 | net_get_random_once(&ipv6_hash_secret, sizeof(ipv6_hash_secret)); | ||
| 39 | |||
| 40 | lhash = (__force u32)laddr->s6_addr32[3]; | ||
| 41 | fhash = __ipv6_addr_jhash(faddr, ipv6_hash_secret); | ||
| 42 | |||
| 43 | return __inet6_ehashfn(lhash, lport, fhash, fport, | ||
| 44 | inet6_ehash_secret + net_hash_mix(net)); | ||
| 45 | } | ||
| 46 | |||
| 47 | static int inet6_sk_ehashfn(const struct sock *sk) | ||
| 48 | { | ||
| 49 | const struct inet_sock *inet = inet_sk(sk); | ||
| 50 | const struct in6_addr *laddr = &sk->sk_v6_rcv_saddr; | ||
| 51 | const struct in6_addr *faddr = &sk->sk_v6_daddr; | ||
| 52 | const __u16 lport = inet->inet_num; | ||
| 53 | const __be16 fport = inet->inet_dport; | ||
| 54 | struct net *net = sock_net(sk); | ||
| 55 | |||
| 56 | return inet6_ehashfn(net, laddr, lport, faddr, fport); | ||
| 57 | } | ||
| 58 | |||
| 26 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) | 59 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) |
| 27 | { | 60 | { |
| 28 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 61 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
