aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/net/inet6_hashtables.h12
-rw-r--r--include/net/inet_sock.h11
2 files changed, 14 insertions, 9 deletions
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index c28e424f53d..668056b4bb0 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -19,6 +19,9 @@
19#include <linux/in6.h> 19#include <linux/in6.h>
20#include <linux/ipv6.h> 20#include <linux/ipv6.h>
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/jhash.h>
23
24#include <net/inet_sock.h>
22 25
23#include <net/ipv6.h> 26#include <net/ipv6.h>
24 27
@@ -28,12 +31,11 @@ struct inet_hashinfo;
28static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport, 31static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
29 const struct in6_addr *faddr, const __be16 fport) 32 const struct in6_addr *faddr, const __be16 fport)
30{ 33{
31 unsigned int hashent = (lport ^ (__force u16)fport); 34 u32 ports = (lport ^ (__force u16)fport);
32 35
33 hashent ^= (__force u32)(laddr->s6_addr32[3] ^ faddr->s6_addr32[3]); 36 return jhash_3words((__force u32)laddr->s6_addr32[3],
34 hashent ^= hashent >> 16; 37 (__force u32)faddr->s6_addr32[3],
35 hashent ^= hashent >> 8; 38 ports, inet_ehash_secret);
36 return hashent;
37} 39}
38 40
39static inline int inet6_sk_ehashfn(const struct sock *sk) 41static inline int inet6_sk_ehashfn(const struct sock *sk)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index ce6da97bc84..62daf214931 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -19,6 +19,7 @@
19 19
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/jhash.h>
22 23
23#include <net/flow.h> 24#include <net/flow.h>
24#include <net/sock.h> 25#include <net/sock.h>
@@ -167,13 +168,15 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
167 168
168extern int inet_sk_rebuild_header(struct sock *sk); 169extern int inet_sk_rebuild_header(struct sock *sk);
169 170
171extern u32 inet_ehash_secret;
172extern void build_ehash_secret(void);
173
170static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport, 174static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport,
171 const __be32 faddr, const __be16 fport) 175 const __be32 faddr, const __be16 fport)
172{ 176{
173 unsigned int h = ((__force __u32)laddr ^ lport) ^ ((__force __u32)faddr ^ (__force __u32)fport); 177 return jhash_2words((__force __u32) laddr ^ (__force __u32) faddr,
174 h ^= h >> 16; 178 ((__u32) lport) << 16 | (__force __u32)fport,
175 h ^= h >> 8; 179 inet_ehash_secret);
176 return h;
177} 180}
178 181
179static inline int inet_sk_ehashfn(const struct sock *sk) 182static inline int inet_sk_ehashfn(const struct sock *sk)