diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-18 17:05:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-18 22:00:34 -0400 |
commit | d1e559d0b1b0d02f76a6bd5b768a99dc834ae926 (patch) | |
tree | 283048c1921aeec1c2dfb25e72e6e67cddffcb23 /net/ipv6/inet6_hashtables.c | |
parent | 5b441f76f1b83591e8cd9d60ba1df3a2aacde27f (diff) |
inet: add IPv6 support to sk_ehashfn()
Intent is to converge IPv4 & IPv6 inet_hash functions to
factorize code.
IPv4 sockets initialize sk_rcv_saddr and sk_v6_daddr
in this patch, thanks to new sk_daddr_set() and sk_rcv_saddr_set()
helpers.
__inet6_hash can now use sk_ehashfn() instead of a private
inet6_sk_ehashfn() and will simply use __inet_hash() in a
following patch.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/inet6_hashtables.c')
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index df7df99d1d7e..ed5787b20192 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -23,11 +23,9 @@ | |||
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 u32 inet6_ehashfn(const struct net *net, | 26 | u32 inet6_ehashfn(const struct net *net, |
27 | const struct in6_addr *laddr, | 27 | const struct in6_addr *laddr, const u16 lport, |
28 | const u16 lport, | 28 | const struct in6_addr *faddr, const __be16 fport) |
29 | const struct in6_addr *faddr, | ||
30 | const __be16 fport) | ||
31 | { | 29 | { |
32 | static u32 inet6_ehash_secret __read_mostly; | 30 | static u32 inet6_ehash_secret __read_mostly; |
33 | static u32 ipv6_hash_secret __read_mostly; | 31 | static u32 ipv6_hash_secret __read_mostly; |
@@ -44,18 +42,6 @@ static u32 inet6_ehashfn(const struct net *net, | |||
44 | inet6_ehash_secret + net_hash_mix(net)); | 42 | inet6_ehash_secret + net_hash_mix(net)); |
45 | } | 43 | } |
46 | 44 | ||
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 | |||
59 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) | 45 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) |
60 | { | 46 | { |
61 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 47 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
@@ -75,7 +61,7 @@ int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) | |||
75 | struct hlist_nulls_head *list; | 61 | struct hlist_nulls_head *list; |
76 | spinlock_t *lock; | 62 | spinlock_t *lock; |
77 | 63 | ||
78 | sk->sk_hash = hash = inet6_sk_ehashfn(sk); | 64 | sk->sk_hash = hash = sk_ehashfn(sk); |
79 | list = &inet_ehash_bucket(hashinfo, hash)->chain; | 65 | list = &inet_ehash_bucket(hashinfo, hash)->chain; |
80 | lock = inet_ehash_lockp(hashinfo, hash); | 66 | lock = inet_ehash_lockp(hashinfo, hash); |
81 | spin_lock(lock); | 67 | spin_lock(lock); |