tcp: Reset bytes_acked and bytes_received when disconnecting
authorChristoph Paasch <cpaasch@apple.com>
Sat, 6 Jul 2019 23:13:07 +0000 (16:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:28:46 +0000 (07:28 +0200)
[ 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 <edumazet@google.com>
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 <cpaasch@apple.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/tcp.c

index 2497735f4b03f05825c849c00f78ba06c5d2899e..541686f3f835f24465de3aff95df4c9ebf8a14e3 100644 (file)
@@ -2366,6 +2366,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;
 
        /* Clean up fastopen related fields */
        tcp_free_fastopen_req(tp);