This Linux kernel change "tcp: Reset bytes_acked and bytes_received when disconnecting" is included in the Linux 4.4.187 release. This change is authored by Christoph Paasch <cpaasch [at] apple.com> on Sat Jul 6 16:13:07 2019 -0700. The commit for this change in Linux stable tree is 364e03f (patch) which is from upstream commit e858faf. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream e858faf.
tcp: Reset bytes_acked and bytes_received when disconnecting [ Upstream commit e858faf556d4e14c750ba1e8852783c6f9520a0e ] If an app is playing tricks to reuse a socket via tcp_disconnect(), bytes_acked/received needs to be reset to 0. Otherwise tcp_info will report the sum of the current and the old connection.. Cc: Eric Dumazet <firstname.lastname@example.org> Fixes: 0df48c26d841 ("tcp: add tcpi_bytes_acked to tcp_info") Fixes: bdd1f9edacb5 ("tcp: add tcpi_bytes_received to tcp_info") Signed-off-by: Christoph Paasch <email@example.com> Signed-off-by: Eric Dumazet <firstname.lastname@example.org> Signed-off-by: David S. Miller <email@example.com> Signed-off-by: Greg Kroah-Hartman <firstname.lastname@example.org>
There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.
net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 303be2b..8e303cd 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2272,6 +2272,8 @@ int tcp_disconnect(struct sock *sk, int flags) dst_release(sk->sk_rx_dst); sk->sk_rx_dst = NULL; tcp_saved_syn_free(tp); + tp->bytes_acked = 0; + tp->bytes_received = 0; WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);