tcp/dccp: add tw->tw_bslot
We want to allow inet_twsk_kill() working even if netns has been dismantled/freed, to get rid of inet_twsk_purge(). This patch adds tw->tw_bslot to cache the bind bucket slot so that inet_twsk_kill() no longer needs to dereference twsk_net(tw) Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8a0de61c40
commit
d507204d3c
|
@ -72,6 +72,7 @@ struct inet_timewait_sock {
|
||||||
tw_tos : 8;
|
tw_tos : 8;
|
||||||
u32 tw_txhash;
|
u32 tw_txhash;
|
||||||
u32 tw_priority;
|
u32 tw_priority;
|
||||||
|
u32 tw_bslot; /* bind bucket slot */
|
||||||
struct timer_list tw_timer;
|
struct timer_list tw_timer;
|
||||||
struct inet_bind_bucket *tw_tb;
|
struct inet_bind_bucket *tw_tb;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,8 +52,7 @@ static void inet_twsk_kill(struct inet_timewait_sock *tw)
|
||||||
spin_unlock(lock);
|
spin_unlock(lock);
|
||||||
|
|
||||||
/* Disassociate with bind bucket. */
|
/* Disassociate with bind bucket. */
|
||||||
bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num,
|
bhead = &hashinfo->bhash[tw->tw_bslot];
|
||||||
hashinfo->bhash_size)];
|
|
||||||
|
|
||||||
spin_lock(&bhead->lock);
|
spin_lock(&bhead->lock);
|
||||||
inet_twsk_bind_unhash(tw, hashinfo);
|
inet_twsk_bind_unhash(tw, hashinfo);
|
||||||
|
@ -110,8 +109,12 @@ void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
|
||||||
Note, that any socket with inet->num != 0 MUST be bound in
|
Note, that any socket with inet->num != 0 MUST be bound in
|
||||||
binding cache, even if it is closed.
|
binding cache, even if it is closed.
|
||||||
*/
|
*/
|
||||||
bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), inet->inet_num,
|
/* Cache inet_bhashfn(), because 'struct net' might be no longer
|
||||||
hashinfo->bhash_size)];
|
* available later in inet_twsk_kill().
|
||||||
|
*/
|
||||||
|
tw->tw_bslot = inet_bhashfn(twsk_net(tw), inet->inet_num,
|
||||||
|
hashinfo->bhash_size);
|
||||||
|
bhead = &hashinfo->bhash[tw->tw_bslot];
|
||||||
spin_lock(&bhead->lock);
|
spin_lock(&bhead->lock);
|
||||||
tw->tw_tb = icsk->icsk_bind_hash;
|
tw->tw_tb = icsk->icsk_bind_hash;
|
||||||
WARN_ON(!icsk->icsk_bind_hash);
|
WARN_ON(!icsk->icsk_bind_hash);
|
||||||
|
|
Loading…
Reference in New Issue