* [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets
@ 2014-01-10 20:34 Neal Cardwell
2014-01-10 21:32 ` Eric Dumazet
2014-01-14 6:36 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Neal Cardwell @ 2014-01-10 20:34 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Neal Cardwell, Eric Dumazet
Fix inet_diag_dump_icsk() to reflect the fact that both TCP_TIME_WAIT
and TCP_FIN_WAIT2 connections are represented by inet_timewait_sock
(not just TIME_WAIT), and for such sockets the tw_substate field holds
the real state, which can be either TCP_TIME_WAIT or TCP_FIN_WAIT2.
This brings the inet_diag state-matching code in line with the field
it uses to populate idiag_state. This is also analogous to the info
exported in /proc/net/tcp, where get_tcp4_sock() exports sk->sk_state
and get_timewait4_sock() exports tw->tw_substate.
Before fixing this, (a) neither "ss -nemoi" nor "ss -nemoi state
fin-wait-2" would return a socket in TCP_FIN_WAIT2; and (b) "ss -nemoi
state time-wait" would also return sockets in state TCP_FIN_WAIT2.
This is an old bug that predates 05dbc7b ("tcp/dccp: remove twchain").
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Cc: Eric Dumazet <edumazet@google.com>
---
net/ipv4/inet_diag.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index a0f52da..e34dccb 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -930,12 +930,15 @@ skip_listen_ht:
spin_lock_bh(lock);
sk_nulls_for_each(sk, node, &head->chain) {
int res;
+ int state;
if (!net_eq(sock_net(sk), net))
continue;
if (num < s_num)
goto next_normal;
- if (!(r->idiag_states & (1 << sk->sk_state)))
+ state = (sk->sk_state == TCP_TIME_WAIT) ?
+ inet_twsk(sk)->tw_substate : sk->sk_state;
+ if (!(r->idiag_states & (1 << state)))
goto next_normal;
if (r->sdiag_family != AF_UNSPEC &&
sk->sk_family != r->sdiag_family)
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets
2014-01-10 20:34 [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets Neal Cardwell
@ 2014-01-10 21:32 ` Eric Dumazet
2014-01-14 6:36 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2014-01-10 21:32 UTC (permalink / raw)
To: Neal Cardwell; +Cc: David Miller, netdev, Eric Dumazet
On Fri, 2014-01-10 at 15:34 -0500, Neal Cardwell wrote:
> Fix inet_diag_dump_icsk() to reflect the fact that both TCP_TIME_WAIT
> and TCP_FIN_WAIT2 connections are represented by inet_timewait_sock
> (not just TIME_WAIT), and for such sockets the tw_substate field holds
> the real state, which can be either TCP_TIME_WAIT or TCP_FIN_WAIT2.
>
> This brings the inet_diag state-matching code in line with the field
> it uses to populate idiag_state. This is also analogous to the info
> exported in /proc/net/tcp, where get_tcp4_sock() exports sk->sk_state
> and get_timewait4_sock() exports tw->tw_substate.
>
> Before fixing this, (a) neither "ss -nemoi" nor "ss -nemoi state
> fin-wait-2" would return a socket in TCP_FIN_WAIT2; and (b) "ss -nemoi
> state time-wait" would also return sockets in state TCP_FIN_WAIT2.
>
> This is an old bug that predates 05dbc7b ("tcp/dccp: remove twchain").
>
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> ---
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets
2014-01-10 20:34 [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets Neal Cardwell
2014-01-10 21:32 ` Eric Dumazet
@ 2014-01-14 6:36 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-01-14 6:36 UTC (permalink / raw)
To: ncardwell; +Cc: netdev, edumazet
From: Neal Cardwell <ncardwell@google.com>
Date: Fri, 10 Jan 2014 15:34:45 -0500
> Fix inet_diag_dump_icsk() to reflect the fact that both TCP_TIME_WAIT
> and TCP_FIN_WAIT2 connections are represented by inet_timewait_sock
> (not just TIME_WAIT), and for such sockets the tw_substate field holds
> the real state, which can be either TCP_TIME_WAIT or TCP_FIN_WAIT2.
>
> This brings the inet_diag state-matching code in line with the field
> it uses to populate idiag_state. This is also analogous to the info
> exported in /proc/net/tcp, where get_tcp4_sock() exports sk->sk_state
> and get_timewait4_sock() exports tw->tw_substate.
>
> Before fixing this, (a) neither "ss -nemoi" nor "ss -nemoi state
> fin-wait-2" would return a socket in TCP_FIN_WAIT2; and (b) "ss -nemoi
> state time-wait" would also return sockets in state TCP_FIN_WAIT2.
>
> This is an old bug that predates 05dbc7b ("tcp/dccp: remove twchain").
>
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-14 6:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-10 20:34 [PATCH net] inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets Neal Cardwell
2014-01-10 21:32 ` Eric Dumazet
2014-01-14 6:36 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox