* [PATCH net-stable 3.3..3.12] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic
@ 2014-02-03 1:40 Neal Cardwell
2014-02-03 3:54 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Neal Cardwell @ 2014-02-03 1:40 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Neal Cardwell, Eric Dumazet
Fix inet_diag_dump_icsk() to reflect the fact that both TIME_WAIT and
FIN_WAIT2 connections are represented by inet_timewait_sock (not just
TIME_WAIT). Thus:
(a) We need to iterate through the time_wait buckets if the user wants
either TIME_WAIT or FIN_WAIT2. (Before fixing this, "ss -nemoi state
fin-wait-2" would not return any sockets, even if there were some in
FIN_WAIT2.)
(b) We need to check tw_substate to see if the user wants to dump
sockets in the particular substate (TIME_WAIT or FIN_WAIT2) that a
given connection is in. (Before fixing this, "ss -nemoi state
time-wait" would actually return sockets in state FIN_WAIT2.)
An analogous fix is in v3.13: 70315d22d3c7383f9a508d0aab21e2eb35b2303a
("inet_diag: fix inet_diag_dump_icsk() to use correct state for
timewait sockets") but that patch is quite different because 3.13 code
is very different in this area due to the unification of TCP hash
tables in 05dbc7b ("tcp/dccp: remove twchain") in v3.13-rc1.
I tested that this applies cleanly between v3.3 and v3.12, and tested
that it works in both 3.3 and 3.12. It does not apply cleanly to 3.2
and earlier (though it makes semantic sense), and semantically is not
the right fix for 3.13 and beyond (as mentioned above).
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Cc: Eric Dumazet <edumazet@google.com>
---
net/ipv4/inet_diag.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 5f64875..7d5126e 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -945,7 +945,7 @@ next_normal:
++num;
}
- if (r->idiag_states & TCPF_TIME_WAIT) {
+ if (r->idiag_states & (TCPF_TIME_WAIT | TCPF_FIN_WAIT2)) {
struct inet_timewait_sock *tw;
inet_twsk_for_each(tw, node,
@@ -955,6 +955,8 @@ next_normal:
if (num < s_num)
goto next_dying;
+ if (!(r->idiag_states & (1 << tw->tw_substate)))
+ goto next_dying;
if (r->sdiag_family != AF_UNSPEC &&
tw->tw_family != r->sdiag_family)
goto next_dying;
--
1.9.0.rc1.175.g0b1dcb5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-stable 3.3..3.12] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic
2014-02-03 1:40 [PATCH net-stable 3.3..3.12] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic Neal Cardwell
@ 2014-02-03 3:54 ` Eric Dumazet
2014-02-03 7:30 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2014-02-03 3:54 UTC (permalink / raw)
To: Neal Cardwell; +Cc: David Miller, netdev, Eric Dumazet
On Sun, 2014-02-02 at 20:40 -0500, Neal Cardwell wrote:
...
> An analogous fix is in v3.13: 70315d22d3c7383f9a508d0aab21e2eb35b2303a
> ("inet_diag: fix inet_diag_dump_icsk() to use correct state for
> timewait sockets") but that patch is quite different because 3.13 code
> is very different in this area due to the unification of TCP hash
> tables in 05dbc7b ("tcp/dccp: remove twchain") in v3.13-rc1.
...
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> ---
> net/ipv4/inet_diag.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Acked-by: Eric Dumazet <edumazet@google.com>
Thanks !
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-stable 3.3..3.12] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic
2014-02-03 3:54 ` Eric Dumazet
@ 2014-02-03 7:30 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2014-02-03 7:30 UTC (permalink / raw)
To: eric.dumazet; +Cc: ncardwell, netdev, edumazet
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 02 Feb 2014 19:54:17 -0800
> On Sun, 2014-02-02 at 20:40 -0500, Neal Cardwell wrote:
> ...
>> An analogous fix is in v3.13: 70315d22d3c7383f9a508d0aab21e2eb35b2303a
>> ("inet_diag: fix inet_diag_dump_icsk() to use correct state for
>> timewait sockets") but that patch is quite different because 3.13 code
>> is very different in this area due to the unification of TCP hash
>> tables in 05dbc7b ("tcp/dccp: remove twchain") in v3.13-rc1.
> ...
>> Signed-off-by: Neal Cardwell <ncardwell@google.com>
>> Cc: Eric Dumazet <edumazet@google.com>
>> ---
>> net/ipv4/inet_diag.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> Acked-by: Eric Dumazet <edumazet@google.com>
Queued up, thanks Neal.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-03 7:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 1:40 [PATCH net-stable 3.3..3.12] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic Neal Cardwell
2014-02-03 3:54 ` Eric Dumazet
2014-02-03 7:30 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).