Commit 89865dbb authored by James Morris's avatar James Morris Committed by David S. Miller

[TCP]: Commonize duplicated code into a new function, tcp_bucket_destroy.

parent a163900d
......@@ -144,6 +144,7 @@ extern kmem_cache_t *tcp_sk_cachep;
extern kmem_cache_t *tcp_bucket_cachep;
extern struct tcp_bind_bucket *tcp_bucket_create(struct tcp_bind_hashbucket *head,
unsigned short snum);
extern void tcp_bucket_destroy(struct tcp_bind_bucket *tb);
extern void tcp_bucket_unlock(struct sock *sk);
extern int tcp_port_rover;
extern struct sock *tcp_v4_lookup_listener(u32 addr, unsigned short hnum, int dif);
......
......@@ -142,6 +142,17 @@ struct tcp_bind_bucket *tcp_bucket_create(struct tcp_bind_hashbucket *head,
return tb;
}
/* Caller must hold hashbucket lock for this tb with local BH disabled */
void tcp_bucket_destroy(struct tcp_bind_bucket *tb)
{
if (!tb->owners) {
if (tb->next)
tb->next->pprev = tb->pprev;
*(tb->pprev) = tb->next;
kmem_cache_free(tcp_bucket_cachep, tb);
}
}
/* Caller must disable local BH processing. */
static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
{
......@@ -300,12 +311,7 @@ static void __tcp_put_port(struct sock *sk)
*(sk->bind_pprev) = sk->bind_next;
sk->prev = NULL;
inet->num = 0;
if (!tb->owners) {
if (tb->next)
tb->next->pprev = tb->pprev;
*(tb->pprev) = tb->next;
kmem_cache_free(tcp_bucket_cachep, tb);
}
tcp_bucket_destroy(tb);
spin_unlock(&head->lock);
}
......
......@@ -81,12 +81,7 @@ void tcp_timewait_kill(struct tcp_tw_bucket *tw)
tw->bind_next->bind_pprev = tw->bind_pprev;
*(tw->bind_pprev) = tw->bind_next;
tw->tb = NULL;
if (tb->owners == NULL) {
if (tb->next)
tb->next->pprev = tb->pprev;
*(tb->pprev) = tb->next;
kmem_cache_free(tcp_bucket_cachep, tb);
}
tcp_bucket_destroy(tb);
spin_unlock(&bhead->lock);
#ifdef INET_REFCNT_DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment