Skip to contentSkip to conversation

tcp: clear tp->segs_{in|out} in tcp_disconnect()

PATCH In review Eric Dumazet 3 participants 3 messages Jan 31, 2020 – Feb 1, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: clear tp->segs_{in|out} in tcp_disconnect()

tp->segs_in and tp->segs_out need to be cleared in tcp_disconnect().

tcp_disconnect() is rarely used, but it is worth fixing it.

Fixes 2efd055c53c0 ("tcp: add tcpi_segs_in and tcpi_segs_out to tcp_info")
Cc Marcelo Ricardo Leitner <[email protected]>
Cc Yuchung Cheng <[email protected]>
Cc Neal Cardwell <[email protected]>
---
 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp.c +2 -0
index 3b601823f69a93dd20f9a4876945a87cd2196dc9..eb2d80519f8e5ad165ca3b8acef2b10bdf8b7345 100644
@@ -2639,6 +2639,8 @@ int tcp_disconnect(struct sock *sk, int flags)
 	sk->sk_rx_dst = NULL;
 	tcp_saved_syn_free(tp);
 	tp->compressed_ack = 0;
+	tp->segs_in = 0;
+	tp->segs_out = 0;
 	tp->bytes_sent = 0;
 	tp->bytes_acked = 0;
 	tp->bytes_received = 0;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Eric Dumazet

tp->segs_in and tp->segs_out need to be cleared in tcp_disconnect().

tcp_disconnect() is rarely used, but it is worth fixing it.

Fixes 2efd055c53c0 ("tcp: add tcpi_segs_in and tcpi_segs_out to tcp_info")
Cc Marcelo Ricardo Leitner <[email protected]>
Cc Yuchung Cheng <[email protected]>
Cc Neal Cardwell <[email protected]>
---
 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp.c +0 -0
index 3b601823f69a93dd20f9a4876945a87cd2196dc9..eb2d80519f8e5ad165ca3b8acef2b10bdf8b7345 100644

net/ipv4/tcp.c int tcp_disconnect(struct sock *sk, int flags)

Quoted 9 lines
net/ipv4/tcp.c +2 -1
@@ -2639,6 +2639,8 @@ int tcp_disconnect(struct sock *sk, int flags)
        sk->sk_rx_dst = NULL;
        tcp_saved_syn_free(tp);
        tp->compressed_ack = 0;
+       tp->segs_in = 0;
+       tp->segs_out = 0;
        tp->bytes_sent = 0;
        tp->bytes_acked = 0;
        tp->bytes_received = 0;
--

Thanks, Eric!

neal

maintainer
#2 lore raw
In reply to Eric Dumazet
Quoted 9 lines · Eric Dumazet

tp->segs_in and tp->segs_out need to be cleared in tcp_disconnect().

tcp_disconnect() is rarely used, but it is worth fixing it.

Fixes 2efd055c53c0 ("tcp: add tcpi_segs_in and tcpi_segs_out to tcp_info")
Cc Marcelo Ricardo Leitner <[email protected]>
Cc Yuchung Cheng <[email protected]>
Cc Neal Cardwell <[email protected]>

Applied all 4 disconnect fixes, and queued them for stable.

Thank you!