diff options
Diffstat (limited to 'include/net/inet6_hashtables.h')
| -rw-r--r-- | include/net/inet6_hashtables.h | 32 | 
1 files changed, 29 insertions, 3 deletions
| diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 5a2beed5a770..25f708ff020e 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
| @@ -48,6 +48,32 @@ static inline int inet6_sk_ehashfn(const struct sock *sk) | |||
| 48 | return inet6_ehashfn(laddr, lport, faddr, fport); | 48 | return inet6_ehashfn(laddr, lport, faddr, fport); | 
| 49 | } | 49 | } | 
| 50 | 50 | ||
| 51 | static inline void __inet6_hash(struct inet_hashinfo *hashinfo, | ||
| 52 | struct sock *sk) | ||
| 53 | { | ||
| 54 | struct hlist_head *list; | ||
| 55 | rwlock_t *lock; | ||
| 56 | |||
| 57 | BUG_TRAP(sk_unhashed(sk)); | ||
| 58 | |||
| 59 | if (sk->sk_state == TCP_LISTEN) { | ||
| 60 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | ||
| 61 | lock = &hashinfo->lhash_lock; | ||
| 62 | inet_listen_wlock(hashinfo); | ||
| 63 | } else { | ||
| 64 | unsigned int hash; | ||
| 65 | sk->sk_hash = hash = inet6_sk_ehashfn(sk); | ||
| 66 | hash &= (hashinfo->ehash_size - 1); | ||
| 67 | list = &hashinfo->ehash[hash].chain; | ||
| 68 | lock = &hashinfo->ehash[hash].lock; | ||
| 69 | write_lock(lock); | ||
| 70 | } | ||
| 71 | |||
| 72 | __sk_add_node(sk, list); | ||
| 73 | sock_prot_inc_use(sk->sk_prot); | ||
| 74 | write_unlock(lock); | ||
| 75 | } | ||
| 76 | |||
| 51 | /* | 77 | /* | 
| 52 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so | 78 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so | 
| 53 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM | 79 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM | 
| @@ -84,10 +110,10 @@ static inline struct sock * | |||
| 84 | 110 | ||
| 85 | if(*((__u32 *)&(tw->tw_dport)) == ports && | 111 | if(*((__u32 *)&(tw->tw_dport)) == ports && | 
| 86 | sk->sk_family == PF_INET6) { | 112 | sk->sk_family == PF_INET6) { | 
| 87 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); | 113 | const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); | 
| 88 | 114 | ||
| 89 | if (ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr) && | 115 | if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && | 
| 90 | ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr) && | 116 | ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && | 
| 91 | (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)) | 117 | (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)) | 
| 92 | goto hit; | 118 | goto hit; | 
| 93 | } | 119 | } | 
