tcp: add SNMP counter for no. of duplicate segments reported by DSACK
authorPriyaranjan Jha <priyarjha@google.com>
Thu, 16 Jul 2020 19:12:35 +0000 (12:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 Jul 2020 19:54:30 +0000 (12:54 -0700)
There are two existing SNMP counters, TCPDSACKRecv and TCPDSACKOfoRecv,
which are incremented depending on whether the DSACKed range is below
the cumulative ACK sequence number or not. Unfortunately, these both
implicitly assume each DSACK covers only one segment. This makes these
counters unusable for estimating spurious retransmit rates,
or real/non-spurious loss rate.

This patch introduces a new SNMP counter, TCPDSACKRecvSegs, which tracks
the estimated number of duplicate segments based on:
(DSACKed sequence range) / MSS. This counter is usable for estimating
spurious retransmit rates, or real/non-spurious loss rate.

Signed-off-by: Priyaranjan Jha <priyarjha@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/snmp.h
net/ipv4/proc.c
net/ipv4/tcp_input.c

index 7d91f4debc483f28632b9070be231331ffc51ed6..cee9f8e6fce31589acb03529a5c5fce9ed8676f7 100644 (file)
@@ -287,6 +287,7 @@ enum
        LINUX_MIB_TCPFASTOPENPASSIVEALTKEY,     /* TCPFastOpenPassiveAltKey */
        LINUX_MIB_TCPTIMEOUTREHASH,             /* TCPTimeoutRehash */
        LINUX_MIB_TCPDUPLICATEDATAREHASH,       /* TCPDuplicateDataRehash */
+       LINUX_MIB_TCPDSACKRECVSEGS,             /* TCPDSACKRecvSegs */
        __LINUX_MIB_MAX
 };
 
index 75545a829a2ba55cae7c0c06c69c605a98ba1b99..1074df726ec0cd977a61d76e93592a7553784176 100644 (file)
@@ -292,6 +292,7 @@ static const struct snmp_mib snmp4_net_list[] = {
        SNMP_MIB_ITEM("TCPFastOpenPassiveAltKey", LINUX_MIB_TCPFASTOPENPASSIVEALTKEY),
        SNMP_MIB_ITEM("TcpTimeoutRehash", LINUX_MIB_TCPTIMEOUTREHASH),
        SNMP_MIB_ITEM("TcpDuplicateDataRehash", LINUX_MIB_TCPDUPLICATEDATAREHASH),
+       SNMP_MIB_ITEM("TCPDSACKRecvSegs", LINUX_MIB_TCPDSACKRECVSEGS),
        SNMP_MIB_SENTINEL
 };
 
index 5d6bbcb1e570c97aeeaa3f53c669271fa5108ac5..82906deb7874e5f333c63cd4c393195c9f7bc854 100644 (file)
@@ -1153,6 +1153,7 @@ static bool tcp_check_dsack(struct sock *sk, const struct sk_buff *ack_skb,
        }
 
        dup_segs = tcp_dsack_seen(tp, start_seq_0, end_seq_0, state);
+       NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDSACKRECVSEGS, dup_segs);
 
        /* D-SACK for already forgotten data... Do dumb counting. */
        if (tp->undo_marker && tp->undo_retrans > 0 &&