tcp: add tcpi_segs_in and tcpi_segs_out to tcp_info
authorMarcelo Ricardo Leitner <mleitner@redhat.com>
Wed, 20 May 2015 23:35:41 +0000 (16:35 -0700)
committerDanny Wood <danwood76@gmail.com>
Thu, 15 Jul 2021 09:45:36 +0000 (10:45 +0100)
commitb1bba9adb7c7f3c66af1245ecaec9c23803339a0
treeec664ed697c8c7ccc9d3bd32f77a8ebaf552228d
parentd2c87ba15cfc3d323c1745103a6b75e1ef60f3e3
tcp: add tcpi_segs_in and tcpi_segs_out to tcp_info

This patch tracks the total number of inbound and outbound segments on a
TCP socket. One may use this number to have an idea on connection
quality when compared against the retransmissions.

RFC4898 named these : tcpEStatsPerfSegsIn and tcpEStatsPerfSegsOut

These are a 32bit field each and can be fetched both from TCP_INFO
getsockopt() if one has a handle on a TCP socket, or from inet_diag
netlink facility (iproute2/ss patch will follow)

Note that tp->segs_out was placed near tp->snd_nxt for good data
locality and minimal performance impact, while tp->segs_in was placed
near tp->bytes_received for the same reason.

Join work with Eric Dumazet.

Note that received SYN are accounted on the listener, but sent SYNACK
are not accounted.

Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Change-Id: I7bf746ad3f9fcc01f672f7dc110aa0c43d9ee042
include/linux/tcp.h
include/uapi/linux/tcp.h
net/ipv4/tcp.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv6/tcp_ipv6.c