tcp: record pkts sent and retransmistted
authorYuchung Cheng <ycheng@google.com>
Sat, 28 Jan 2017 00:24:38 +0000 (16:24 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Jan 2017 00:17:23 +0000 (19:17 -0500)
Add two stats in SCM_TIMESTAMPING_OPT_STATS:

TCP_NLA_DATA_SEGS_OUT: total data packets sent including retransmission
TCP_NLA_TOTAL_RETRANS: total data packets retransmitted

The names are picked to be consistent with corresponding fields in
TCP_INFO. This allows applications that are using the timestamping
API to measure latency stats to also retrive retransmission rate
of application write.

Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/tcp.h
net/ipv4/tcp.c

index 6ff35eb48d104c4128e13b41d772a09178a95bac..38a2b07afdff255914d29c7906321c19338786c0 100644 (file)
@@ -227,6 +227,8 @@ enum {
        TCP_NLA_BUSY,           /* Time (usec) busy sending data */
        TCP_NLA_RWND_LIMITED,   /* Time (usec) limited by receive window */
        TCP_NLA_SNDBUF_LIMITED, /* Time (usec) limited by send buffer */
+       TCP_NLA_DATA_SEGS_OUT,  /* Data pkts sent including retransmission */
+       TCP_NLA_TOTAL_RETRANS,  /* Data pkts retransmitted */
 };
 
 /* for TCP_MD5SIG socket option */
index 2ed472ebf3b5b445107723d66ed4f821a0bcb284..b751abc56935efa4e7e3ca9aa71e478f60b4b3fd 100644 (file)
@@ -2870,7 +2870,7 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)
        struct sk_buff *stats;
        struct tcp_info info;
 
-       stats = alloc_skb(3 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC);
+       stats = alloc_skb(5 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC);
        if (!stats)
                return NULL;
 
@@ -2881,6 +2881,10 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)
                          info.tcpi_rwnd_limited, TCP_NLA_PAD);
        nla_put_u64_64bit(stats, TCP_NLA_SNDBUF_LIMITED,
                          info.tcpi_sndbuf_limited, TCP_NLA_PAD);
+       nla_put_u64_64bit(stats, TCP_NLA_DATA_SEGS_OUT,
+                         tp->data_segs_out, TCP_NLA_PAD);
+       nla_put_u64_64bit(stats, TCP_NLA_TOTAL_RETRANS,
+                         tp->total_retrans, TCP_NLA_PAD);
        return stats;
 }