tcp: Reset bytes_acked and bytes_received when disconnecting [Linux 4.9.187]

This Linux kernel change "tcp: Reset bytes_acked and bytes_received when disconnecting" is included in the Linux 4.9.187 release. This change is authored by Christoph Paasch <cpaasch [at]> on Sat Jul 6 16:13:07 2019 -0700. The commit for this change in Linux stable tree is 01dd367 (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 <>
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 <>
Signed-off-by: Eric Dumazet <>
Signed-off-by: David S. Miller <>
Signed-off-by: Greg Kroah-Hartman <>

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 ee2822a..6e25524 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2312,6 +2312,8 @@ int tcp_disconnect(struct sock *sk, int flags)
    sk->sk_rx_dst = NULL;
+   tp->bytes_acked = 0;
+   tp->bytes_received = 0;

    WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);

Leave a Reply

Your email address will not be published. Required fields are marked *