From: Thomas Higdon <tph@fb.com> To: "netdev@vger.kernel.org" <netdev@vger.kernel.org> Cc: Jonathan Lemon <jonathan.lemon@gmail.com>, Dave Jones <dsj@fb.com>, "Eric Dumazet" <edumazet@google.com>, Neal Cardwell <ncardwell@google.com>, "Dave Taht" <dave.taht@gmail.com>, Yuchung Cheng <ycheng@google.com>, "Soheil Hassas Yeganeh" <soheil@google.com> Subject: [PATCH v5 1/2] tcp: Add TCP_INFO counter for packets received out-of-order Date: Fri, 13 Sep 2019 23:23:34 +0000 [thread overview] Message-ID: <20190913232332.44036-1-tph@fb.com> (raw) For receive-heavy cases on the server-side, we want to track the connection quality for individual client IPs. This counter, similar to the existing system-wide TCPOFOQueue counter in /proc/net/netstat, tracks out-of-order packet reception. By providing this counter in TCP_INFO, it will allow understanding to what degree receive-heavy sockets are experiencing out-of-order delivery and packet drops indicating congestion. Please note that this is similar to the counter in NetBSD TCP_INFO, and has the same name. Also note that we avoid increasing the size of the tcp_sock struct by taking advantage of a hole. Signed-off-by: Thomas Higdon <tph@fb.com> --- changes since v4: - optimize placement of rcv_ooopack to avoid increasing tcp_sock struct size include/linux/tcp.h | 2 ++ include/uapi/linux/tcp.h | 2 ++ net/ipv4/tcp.c | 2 ++ net/ipv4/tcp_input.c | 1 + 4 files changed, 7 insertions(+) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index f3a85a7fb4b1..99617e528ea2 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -354,6 +354,8 @@ struct tcp_sock { #define BPF_SOCK_OPS_TEST_FLAG(TP, ARG) 0 #endif + u32 rcv_ooopack; /* Received out-of-order packets, for tcpinfo */ + /* Receiver side RTT estimation */ u32 rcv_rtt_last_tsecr; struct { diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index b3564f85a762..20237987ccc8 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -270,6 +270,8 @@ struct tcp_info { __u64 tcpi_bytes_retrans; /* RFC4898 tcpEStatsPerfOctetsRetrans */ __u32 tcpi_dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups */ __u32 tcpi_reord_seen; /* reordering events seen */ + + __u32 tcpi_rcv_ooopack; /* Out-of-order packets received */ }; /* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 94df48bcecc2..4cf58208270e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2653,6 +2653,7 @@ int tcp_disconnect(struct sock *sk, int flags) tp->rx_opt.saw_tstamp = 0; tp->rx_opt.dsack = 0; tp->rx_opt.num_sacks = 0; + tp->rcv_ooopack = 0; /* Clean up fastopen related fields */ @@ -3295,6 +3296,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) info->tcpi_bytes_retrans = tp->bytes_retrans; info->tcpi_dsack_dups = tp->dsack_dups; info->tcpi_reord_seen = tp->reord_seen; + info->tcpi_rcv_ooopack = tp->rcv_ooopack; unlock_sock_fast(sk, slow); } EXPORT_SYMBOL_GPL(tcp_get_info); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 706cbb3b2986..2ef333354026 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4555,6 +4555,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) tp->pred_flags = 0; inet_csk_schedule_ack(sk); + tp->rcv_ooopack += max_t(u16, 1, skb_shinfo(skb)->gso_segs); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOQUEUE); seq = TCP_SKB_CB(skb)->seq; end_seq = TCP_SKB_CB(skb)->end_seq; -- 2.17.1
next reply other threads:[~2019-09-13 23:23 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-13 23:23 Thomas Higdon [this message] 2019-09-13 23:23 ` [PATCH v5 2/2] tcp: Add snd_wnd to TCP_INFO Thomas Higdon 2019-09-13 23:36 ` Yuchung Cheng 2019-09-14 15:45 ` Neal Cardwell 2019-09-14 17:57 ` Soheil Hassas Yeganeh 2019-09-16 14:39 ` David Miller 2019-09-14 15:43 ` [PATCH v5 1/2] tcp: Add TCP_INFO counter for packets received out-of-order Neal Cardwell 2019-09-16 17:42 ` Thomas Higdon 2019-09-16 14:39 ` David Miller
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190913232332.44036-1-tph@fb.com \ --to=tph@fb.com \ --cc=dave.taht@gmail.com \ --cc=dsj@fb.com \ --cc=edumazet@google.com \ --cc=jonathan.lemon@gmail.com \ --cc=ncardwell@google.com \ --cc=netdev@vger.kernel.org \ --cc=soheil@google.com \ --cc=ycheng@google.com \ --subject='Re: [PATCH v5 1/2] tcp: Add TCP_INFO counter for packets received out-of-order' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).