diff options
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r-- | include/net/inet_hashtables.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index c816708fa556..6731df2cea67 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -240,4 +240,38 @@ static inline void __inet_hash(struct inet_hashinfo *hashinfo, | |||
240 | if (listen_possible && sk->sk_state == TCP_LISTEN) | 240 | if (listen_possible && sk->sk_state == TCP_LISTEN) |
241 | wake_up(&hashinfo->lhash_wait); | 241 | wake_up(&hashinfo->lhash_wait); |
242 | } | 242 | } |
243 | |||
244 | static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk) | ||
245 | { | ||
246 | if (sk->sk_state != TCP_CLOSE) { | ||
247 | local_bh_disable(); | ||
248 | __inet_hash(hashinfo, sk, 1); | ||
249 | local_bh_enable(); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk) | ||
254 | { | ||
255 | rwlock_t *lock; | ||
256 | |||
257 | if (sk_unhashed(sk)) | ||
258 | goto out; | ||
259 | |||
260 | if (sk->sk_state == TCP_LISTEN) { | ||
261 | local_bh_disable(); | ||
262 | inet_listen_wlock(hashinfo); | ||
263 | lock = &hashinfo->lhash_lock; | ||
264 | } else { | ||
265 | struct inet_ehash_bucket *head = &hashinfo->ehash[sk->sk_hashent]; | ||
266 | lock = &head->lock; | ||
267 | write_lock_bh(&head->lock); | ||
268 | } | ||
269 | |||
270 | if (__sk_del_node_init(sk)) | ||
271 | sock_prot_dec_use(sk->sk_prot); | ||
272 | write_unlock_bh(lock); | ||
273 | out: | ||
274 | if (sk->sk_state == TCP_LISTEN) | ||
275 | wake_up(&hashinfo->lhash_wait); | ||
276 | } | ||
243 | #endif /* _INET_HASHTABLES_H */ | 277 | #endif /* _INET_HASHTABLES_H */ |