diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-19 00:05:34 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-19 05:00:34 +0300 |
commit | 5b441f76f1b83591e8cd9d60ba1df3a2aacde27f (patch) | |
tree | 13aff60eedcd644be5bec2bb0190ba4ccca3141e /net/ipv4/inet_hashtables.c | |
parent | 6eada0110c8984477f5f1e57a0b7f7b2fc841e30 (diff) | |
download | linux-5b441f76f1b83591e8cd9d60ba1df3a2aacde27f.tar.xz |
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/inet_hashtables.c')
-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, } -static unsigned int inet_sk_ehashfn(const struct sock *sk) +u32 sk_ehashfn(const struct sock *sk) { - const struct inet_sock *inet = inet_sk(sk); - const __be32 laddr = inet->inet_rcv_saddr; - const __u16 lport = inet->inet_num; - const __be32 faddr = inet->inet_daddr; - const __be16 fport = inet->inet_dport; - struct net *net = sock_net(sk); - - return inet_ehashfn(net, laddr, lport, faddr, fport); + return inet_ehashfn(sock_net(sk), + sk->sk_rcv_saddr, sk->sk_num, + sk->sk_daddr, sk->sk_dport); } /* @@ -407,13 +402,13 @@ int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw) { struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; struct hlist_nulls_head *list; - spinlock_t *lock; struct inet_ehash_bucket *head; + spinlock_t *lock; int twrefcnt = 0; WARN_ON(!sk_unhashed(sk)); - sk->sk_hash = inet_sk_ehashfn(sk); + sk->sk_hash = sk_ehashfn(sk); head = inet_ehash_bucket(hashinfo, sk->sk_hash); list = &head->chain; lock = inet_ehash_lockp(hashinfo, sk->sk_hash); |