Commit dbe7faa4 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

inet: inet_twsk_deschedule factorization

inet_twsk_deschedule() calls are followed by inet_twsk_put().

Only particular case is in inet_twsk_purge() but there is no point
to defer the inet_twsk_put() after re-enabling BH.

Lets rename inet_twsk_deschedule() to inet_twsk_deschedule_put()
and move the inet_twsk_put() inside.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc01538f
...@@ -111,7 +111,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, ...@@ -111,7 +111,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
struct inet_hashinfo *hashinfo); struct inet_hashinfo *hashinfo);
void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo); void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo);
void inet_twsk_deschedule(struct inet_timewait_sock *tw); void inet_twsk_deschedule_put(struct inet_timewait_sock *tw);
void inet_twsk_purge(struct inet_hashinfo *hashinfo, void inet_twsk_purge(struct inet_hashinfo *hashinfo,
struct inet_timewait_death_row *twdr, int family); struct inet_timewait_death_row *twdr, int family);
......
...@@ -380,8 +380,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row, ...@@ -380,8 +380,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
*twp = tw; *twp = tw;
} else if (tw) { } else if (tw) {
/* Silly. Should hash-dance instead... */ /* Silly. Should hash-dance instead... */
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
} }
return 0; return 0;
...@@ -558,10 +557,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, ...@@ -558,10 +557,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
inet_twsk_bind_unhash(tw, hinfo); inet_twsk_bind_unhash(tw, hinfo);
spin_unlock(&head->lock); spin_unlock(&head->lock);
if (tw) { if (tw)
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
}
ret = 0; ret = 0;
goto out; goto out;
......
...@@ -205,13 +205,17 @@ EXPORT_SYMBOL_GPL(inet_twsk_alloc); ...@@ -205,13 +205,17 @@ EXPORT_SYMBOL_GPL(inet_twsk_alloc);
* tcp_input.c to verify this. * tcp_input.c to verify this.
*/ */
/* This is for handling early-kills of TIME_WAIT sockets. */ /* This is for handling early-kills of TIME_WAIT sockets.
void inet_twsk_deschedule(struct inet_timewait_sock *tw) * Warning : consume reference.
* Caller should not access tw anymore.
*/
void inet_twsk_deschedule_put(struct inet_timewait_sock *tw)
{ {
if (del_timer_sync(&tw->tw_timer)) if (del_timer_sync(&tw->tw_timer))
inet_twsk_kill(tw); inet_twsk_kill(tw);
inet_twsk_put(tw);
} }
EXPORT_SYMBOL(inet_twsk_deschedule); EXPORT_SYMBOL(inet_twsk_deschedule_put);
void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo) void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo)
{ {
...@@ -281,9 +285,8 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo, ...@@ -281,9 +285,8 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo,
rcu_read_unlock(); rcu_read_unlock();
local_bh_disable(); local_bh_disable();
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
local_bh_enable(); local_bh_enable();
inet_twsk_put(tw);
goto restart_rcu; goto restart_rcu;
} }
/* If the nulls value we got at the end of this lookup is /* If the nulls value we got at the end of this lookup is
......
...@@ -1683,8 +1683,7 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1683,8 +1683,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
iph->daddr, th->dest, iph->daddr, th->dest,
inet_iif(skb)); inet_iif(skb));
if (sk2) { if (sk2) {
inet_twsk_deschedule(inet_twsk(sk)); inet_twsk_deschedule_put(inet_twsk(sk));
inet_twsk_put(inet_twsk(sk));
sk = sk2; sk = sk2;
goto process; goto process;
} }
......
...@@ -147,8 +147,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, ...@@ -147,8 +147,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
if (!th->fin || if (!th->fin ||
TCP_SKB_CB(skb)->end_seq != tcptw->tw_rcv_nxt + 1) { TCP_SKB_CB(skb)->end_seq != tcptw->tw_rcv_nxt + 1) {
kill_with_rst: kill_with_rst:
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
return TCP_TW_RST; return TCP_TW_RST;
} }
...@@ -198,8 +197,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, ...@@ -198,8 +197,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
*/ */
if (sysctl_tcp_rfc1337 == 0) { if (sysctl_tcp_rfc1337 == 0) {
kill: kill:
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
return TCP_TW_SUCCESS; return TCP_TW_SUCCESS;
} }
} }
......
...@@ -243,8 +243,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, ...@@ -243,8 +243,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
*twp = tw; *twp = tw;
} else if (tw) { } else if (tw) {
/* Silly. Should hash-dance instead... */ /* Silly. Should hash-dance instead... */
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
} }
return 0; return 0;
......
...@@ -1481,8 +1481,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1481,8 +1481,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
ntohs(th->dest), tcp_v6_iif(skb)); ntohs(th->dest), tcp_v6_iif(skb));
if (sk2) { if (sk2) {
struct inet_timewait_sock *tw = inet_twsk(sk); struct inet_timewait_sock *tw = inet_twsk(sk);
inet_twsk_deschedule(tw); inet_twsk_deschedule_put(tw);
inet_twsk_put(tw);
sk = sk2; sk = sk2;
tcp_v6_restore_cb(skb); tcp_v6_restore_cb(skb);
goto process; goto process;
......
...@@ -272,8 +272,7 @@ tproxy_handle_time_wait4(struct sk_buff *skb, __be32 laddr, __be16 lport, ...@@ -272,8 +272,7 @@ tproxy_handle_time_wait4(struct sk_buff *skb, __be32 laddr, __be16 lport,
hp->source, lport ? lport : hp->dest, hp->source, lport ? lport : hp->dest,
skb->dev, NFT_LOOKUP_LISTENER); skb->dev, NFT_LOOKUP_LISTENER);
if (sk2) { if (sk2) {
inet_twsk_deschedule(inet_twsk(sk)); inet_twsk_deschedule_put(inet_twsk(sk));
inet_twsk_put(inet_twsk(sk));
sk = sk2; sk = sk2;
} }
} }
...@@ -437,8 +436,7 @@ tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff, ...@@ -437,8 +436,7 @@ tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
tgi->lport ? tgi->lport : hp->dest, tgi->lport ? tgi->lport : hp->dest,
skb->dev, NFT_LOOKUP_LISTENER); skb->dev, NFT_LOOKUP_LISTENER);
if (sk2) { if (sk2) {
inet_twsk_deschedule(inet_twsk(sk)); inet_twsk_deschedule_put(inet_twsk(sk));
inet_twsk_put(inet_twsk(sk));
sk = sk2; sk = sk2;
} }
} }
......
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