aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_hashtables.c
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2013-10-19 15:48:51 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-19 19:45:34 -0400
commit65cd8033ff375b68037df61603ee68070dc48578 (patch)
tree26b34f9ed023dda5a861001118a1ea1227ae252f /net/ipv4/inet_hashtables.c
parent53481da372851a5506deb5247302f75459b472b4 (diff)
ipv4: split inet_ehashfn to hash functions per compilation unit
This duplicates a bit of code but let's us easily introduce separate secret keys later. The separate compilation units are ipv4/inet_hashtabbles.o, ipv4/udp.o and rds/connection.o. Cc: Eric Dumazet <edumazet@google.com> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_hashtables.c')
-rw-r--r--net/ipv4/inet_hashtables.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index a4b66bbe4f21..18aa668d0cc9 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -24,6 +24,27 @@
24#include <net/secure_seq.h> 24#include <net/secure_seq.h>
25#include <net/ip.h> 25#include <net/ip.h>
26 26
27static unsigned int inet_ehashfn(struct net *net, const __be32 laddr,
28 const __u16 lport, const __be32 faddr,
29 const __be16 fport)
30{
31 return __inet_ehashfn(laddr, lport, faddr, fport,
32 inet_ehash_secret + net_hash_mix(net));
33}
34
35
36static unsigned int inet_sk_ehashfn(const struct sock *sk)
37{
38 const struct inet_sock *inet = inet_sk(sk);
39 const __be32 laddr = inet->inet_rcv_saddr;
40 const __u16 lport = inet->inet_num;
41 const __be32 faddr = inet->inet_daddr;
42 const __be16 fport = inet->inet_dport;
43 struct net *net = sock_net(sk);
44
45 return inet_ehashfn(net, laddr, lport, faddr, fport);
46}
47
27/* 48/*
28 * Allocate and initialize a new local port bind bucket. 49 * Allocate and initialize a new local port bind bucket.
29 * The bindhash mutex for snum's hash chain must be held here. 50 * The bindhash mutex for snum's hash chain must be held here.