diff options
Diffstat (limited to 'include/net/inet_hashtables.h')
| -rw-r--r-- | include/net/inet_hashtables.h | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index c23c4ed30724..48ac620cb846 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
| @@ -221,9 +221,9 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk) | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | /* Caller must disable local BH processing. */ | 223 | /* Caller must disable local BH processing. */ |
| 224 | static inline void __inet_inherit_port(struct inet_hashinfo *table, | 224 | static inline void __inet_inherit_port(struct sock *sk, struct sock *child) |
| 225 | struct sock *sk, struct sock *child) | ||
| 226 | { | 225 | { |
| 226 | struct inet_hashinfo *table = sk->sk_prot->hashinfo; | ||
| 227 | const int bhash = inet_bhashfn(inet_sk(child)->num, table->bhash_size); | 227 | const int bhash = inet_bhashfn(inet_sk(child)->num, table->bhash_size); |
| 228 | struct inet_bind_hashbucket *head = &table->bhash[bhash]; | 228 | struct inet_bind_hashbucket *head = &table->bhash[bhash]; |
| 229 | struct inet_bind_bucket *tb; | 229 | struct inet_bind_bucket *tb; |
| @@ -235,15 +235,14 @@ static inline void __inet_inherit_port(struct inet_hashinfo *table, | |||
| 235 | spin_unlock(&head->lock); | 235 | spin_unlock(&head->lock); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | static inline void inet_inherit_port(struct inet_hashinfo *table, | 238 | static inline void inet_inherit_port(struct sock *sk, struct sock *child) |
| 239 | struct sock *sk, struct sock *child) | ||
| 240 | { | 239 | { |
| 241 | local_bh_disable(); | 240 | local_bh_disable(); |
| 242 | __inet_inherit_port(table, sk, child); | 241 | __inet_inherit_port(sk, child); |
| 243 | local_bh_enable(); | 242 | local_bh_enable(); |
| 244 | } | 243 | } |
| 245 | 244 | ||
| 246 | extern void inet_put_port(struct inet_hashinfo *table, struct sock *sk); | 245 | extern void inet_put_port(struct sock *sk); |
| 247 | 246 | ||
| 248 | extern void inet_listen_wlock(struct inet_hashinfo *hashinfo); | 247 | extern void inet_listen_wlock(struct inet_hashinfo *hashinfo); |
| 249 | 248 | ||
| @@ -266,41 +265,9 @@ static inline void inet_listen_unlock(struct inet_hashinfo *hashinfo) | |||
| 266 | wake_up(&hashinfo->lhash_wait); | 265 | wake_up(&hashinfo->lhash_wait); |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | extern void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk); | 268 | extern void __inet_hash_nolisten(struct sock *sk); |
| 270 | extern void __inet_hash_nolisten(struct inet_hashinfo *hinfo, struct sock *sk); | 269 | extern void inet_hash(struct sock *sk); |
| 271 | 270 | extern void inet_unhash(struct sock *sk); | |
| 272 | static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk) | ||
| 273 | { | ||
| 274 | if (sk->sk_state != TCP_CLOSE) { | ||
| 275 | local_bh_disable(); | ||
| 276 | __inet_hash(hashinfo, sk); | ||
| 277 | local_bh_enable(); | ||
| 278 | } | ||
| 279 | } | ||
| 280 | |||
| 281 | static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk) | ||
| 282 | { | ||
| 283 | rwlock_t *lock; | ||
| 284 | |||
| 285 | if (sk_unhashed(sk)) | ||
| 286 | goto out; | ||
| 287 | |||
| 288 | if (sk->sk_state == TCP_LISTEN) { | ||
| 289 | local_bh_disable(); | ||
| 290 | inet_listen_wlock(hashinfo); | ||
| 291 | lock = &hashinfo->lhash_lock; | ||
| 292 | } else { | ||
| 293 | lock = inet_ehash_lockp(hashinfo, sk->sk_hash); | ||
| 294 | write_lock_bh(lock); | ||
| 295 | } | ||
| 296 | |||
| 297 | if (__sk_del_node_init(sk)) | ||
| 298 | sock_prot_inuse_add(sk->sk_prot, -1); | ||
| 299 | write_unlock_bh(lock); | ||
| 300 | out: | ||
| 301 | if (sk->sk_state == TCP_LISTEN) | ||
| 302 | wake_up(&hashinfo->lhash_wait); | ||
| 303 | } | ||
| 304 | 271 | ||
| 305 | extern struct sock *__inet_lookup_listener(struct net *net, | 272 | extern struct sock *__inet_lookup_listener(struct net *net, |
| 306 | struct inet_hashinfo *hashinfo, | 273 | struct inet_hashinfo *hashinfo, |
| @@ -425,7 +392,7 @@ extern int __inet_hash_connect(struct inet_timewait_death_row *death_row, | |||
| 425 | struct sock *sk, | 392 | struct sock *sk, |
| 426 | int (*check_established)(struct inet_timewait_death_row *, | 393 | int (*check_established)(struct inet_timewait_death_row *, |
| 427 | struct sock *, __u16, struct inet_timewait_sock **), | 394 | struct sock *, __u16, struct inet_timewait_sock **), |
| 428 | void (*hash)(struct inet_hashinfo *, struct sock *)); | 395 | void (*hash)(struct sock *sk)); |
| 429 | extern int inet_hash_connect(struct inet_timewait_death_row *death_row, | 396 | extern int inet_hash_connect(struct inet_timewait_death_row *death_row, |
| 430 | struct sock *sk); | 397 | struct sock *sk); |
| 431 | #endif /* _INET_HASHTABLES_H */ | 398 | #endif /* _INET_HASHTABLES_H */ |
