diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-18 17:05:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-18 22:00:34 -0400 |
commit | 5b441f76f1b83591e8cd9d60ba1df3a2aacde27f (patch) | |
tree | 13aff60eedcd644be5bec2bb0190ba4ccca3141e /net/ipv4 | |
parent | 6eada0110c8984477f5f1e57a0b7f7b2fc841e30 (diff) |
net: introduce sk_ehashfn() helper
Goal is to unify IPv4/IPv6 inet_hash handling, and use common helpers
for all kind of sockets (full sockets, timewait and request sockets)
inet_sk_ehashfn() becomes sk_ehashfn() but still only copes with IPv4
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/inet_hashtables.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 330a08bcd1c1..3a86dfd7ae33 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
@@ -37,16 +37,11 @@ static u32 inet_ehashfn(const struct net *net, const __be32 laddr, | |||
37 | } | 37 | } |
38 | 38 | ||
39 | 39 | ||
40 | static unsigned int inet_sk_ehashfn(const struct sock *sk) | 40 | u32 sk_ehashfn(const struct sock *sk) |
41 | { | 41 | { |
42 | const struct inet_sock *inet = inet_sk(sk); | 42 | return inet_ehashfn(sock_net(sk), |
43 | const __be32 laddr = inet->inet_rcv_saddr; | 43 | sk->sk_rcv_saddr, sk->sk_num, |
44 | const __u16 lport = inet->inet_num; | 44 | sk->sk_daddr, sk->sk_dport); |
45 | const __be32 faddr = inet->inet_daddr; | ||
46 | const __be16 fport = inet->inet_dport; | ||
47 | struct net *net = sock_net(sk); | ||
48 | |||
49 | return inet_ehashfn(net, laddr, lport, faddr, fport); | ||
50 | } | 45 | } |
51 | 46 | ||
52 | /* | 47 | /* |
@@ -407,13 +402,13 @@ int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw) | |||
407 | { | 402 | { |
408 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 403 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
409 | struct hlist_nulls_head *list; | 404 | struct hlist_nulls_head *list; |
410 | spinlock_t *lock; | ||
411 | struct inet_ehash_bucket *head; | 405 | struct inet_ehash_bucket *head; |
406 | spinlock_t *lock; | ||
412 | int twrefcnt = 0; | 407 | int twrefcnt = 0; |
413 | 408 | ||
414 | WARN_ON(!sk_unhashed(sk)); | 409 | WARN_ON(!sk_unhashed(sk)); |
415 | 410 | ||
416 | sk->sk_hash = inet_sk_ehashfn(sk); | 411 | sk->sk_hash = sk_ehashfn(sk); |
417 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); | 412 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); |
418 | list = &head->chain; | 413 | list = &head->chain; |
419 | lock = inet_ehash_lockp(hashinfo, sk->sk_hash); | 414 | lock = inet_ehash_lockp(hashinfo, sk->sk_hash); |