* [PATCH net-next] tcp: export drops counter to /proc/net/tcp{,6}
@ 2017-08-18 10:21 Stéphan Gorget
2017-08-18 12:14 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Stéphan Gorget @ 2017-08-18 10:21 UTC (permalink / raw)
To: netdev
Cc: Stéphan Gorget, Jeethu Rao, David S . Miller,
Alexei Starovoitov, Eric Dumazet, kernel-team, linux-kernel
Those counters are exported for raw and udp but not for tcp, though they
are incremented.
An example where it is useful is chasing listen overflow. Listen overflow
are counted as a global counter in LINUX_MIB_LISTENOVERFLOWS accessible
in /proc/net/netstat but there is no way to find related drops in the
information exported for tcp. With this patch it will make possible to
correlate growth of LINUX_MIB_LISTENOVERFLOWS with growth of drops for
a tcp socket.
This patch does it for /proc/net/tcp and /proc/net/tcp6, the drops
counter is being incremented in function like tcp_listendrop() which
would help surface error cases like listen overflow and track them to
the correct socket.
That work has been done for raw sockets (/proc/net/raw and
/proc/net/raw6) by Wang Chen in commit 33c732c36169
("[IPV4]: Add raw drops counter.") and commit a92aa318b4b3
("[IPV6]: Add raw6 drops counter.") and by Eric Dumazet for udp ones
(/proc/net/udp and /proc/net/udp6) in commit cb61cb9b8b5e
("udp: sk_drops handling").
Signed-off-by: Stéphan Gorget <sgorget@fb.com>
Signed-off-by: Jeethu Rao <jeethu@fb.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: kernel-team@fb.com
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
Documentation/networking/proc_net_tcp.txt | 30 ++++++++++++++++--------------
net/ipv4/tcp_ipv4.c | 5 +++--
net/ipv6/tcp_ipv6.c | 7 ++++---
3 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/Documentation/networking/proc_net_tcp.txt b/Documentation/networking/proc_net_tcp.txt
index 4a79209..38bda94 100644
--- a/Documentation/networking/proc_net_tcp.txt
+++ b/Documentation/networking/proc_net_tcp.txt
@@ -24,20 +24,22 @@ up into 3 parts because of the length of the line):
| |----------------------> receive-queue
|-------------------------------> transmit-queue
- 1000 0 54165785 4 cd1e6040 25 4 27 3 -1
- | | | | | | | | | |--> slow start size threshold,
- | | | | | | | | | or -1 if the threshold
- | | | | | | | | | is >= 0xFFFF
- | | | | | | | | |----> sending congestion window
- | | | | | | | |-------> (ack.quick<<1)|ack.pingpong
- | | | | | | |---------> Predicted tick of soft clock
- | | | | | | (delayed ACK control data)
- | | | | | |------------> retransmit timeout
- | | | | |------------------> location of socket in memory
- | | | |-----------------------> socket reference count
- | | |-----------------------------> inode
- | |----------------------------------> unanswered 0-window probes
- |---------------------------------------------> uid
+ 1000 0 54165785 4 cd1e6040 25 4 27 3 -1 0
+ | | | | | | | | | | |--> number of drops
+ | | | | | | | | | |-----> slow start size
+ | | | | | | | | | threshold, or -1 if the
+ | | | | | | | | | threshold is >= 0xFFFF
+ | | | | | | | | |-------> sending congestion window
+ | | | | | | | |----------> (ack.quick<<1) |
+ | | | | | | | ack.pingpong
+ | | | | | | |------------> Predicted tick of soft clock
+ | | | | | | (delayed ACK control data)
+ | | | | | |---------------> retransmit timeout
+ | | | | |---------------------> location of socket in memory
+ | | | |--------------------------> socket reference count
+ | | |--------------------------------> inode
+ | |-------------------------------------> unanswered 0-window probes
+ |------------------------------------------------> uid
timer_active:
0 no timer is pending
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5af8b80..173e20a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2255,7 +2255,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);
seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
- "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
+ "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d %d",
i, src, srcp, dest, destp, state,
tp->write_seq - tp->snd_una,
rx_queue,
@@ -2272,7 +2272,8 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
tp->snd_cwnd,
state == TCP_LISTEN ?
fastopenq->max_qlen :
- (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh));
+ (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh),
+ state == TCP_LISTEN ? atomic_read(&sk->sk_drops) : 0);
}
static void get_timewait4_sock(const struct inet_timewait_sock *tw,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d79a1af..1cd296a 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1795,8 +1795,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
- "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d\n",
+ "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X %02X "
+ "%08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d %d\n",
i,
src->s6_addr32[0], src->s6_addr32[1],
src->s6_addr32[2], src->s6_addr32[3], srcp,
@@ -1818,7 +1818,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
tp->snd_cwnd,
state == TCP_LISTEN ?
fastopenq->max_qlen :
- (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh)
+ (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh),
+ state == TCP_LISTEN ? atomic_read(&sp->sk_drops) : 0
);
}
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] tcp: export drops counter to /proc/net/tcp{,6}
2017-08-18 10:21 [PATCH net-next] tcp: export drops counter to /proc/net/tcp{,6} Stéphan Gorget
@ 2017-08-18 12:14 ` Eric Dumazet
2017-08-18 12:50 ` Stéphan Gorget
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2017-08-18 12:14 UTC (permalink / raw)
To: Stéphan Gorget
Cc: netdev, Jeethu Rao, David S . Miller, Alexei Starovoitov,
Eric Dumazet, kernel-team, linux-kernel
On Fri, 2017-08-18 at 03:21 -0700, Stéphan Gorget wrote:
> Those counters are exported for raw and udp but not for tcp, though they
> are incremented.
>
> An example where it is useful is chasing listen overflow. Listen overflow
> are counted as a global counter in LINUX_MIB_LISTENOVERFLOWS accessible
> in /proc/net/netstat but there is no way to find related drops in the
> information exported for tcp. With this patch it will make possible to
> correlate growth of LINUX_MIB_LISTENOVERFLOWS with growth of drops for
> a tcp socket.
Hi Stéphan.
Eons ago, the decision was taken to declare /proc interface frozen.
In linux-4.7 I provided all the information you need using the modern
inet_diag interface, [1]
Simply use iproute2/ss tool to access this information in a very
efficient way (like filtering done in the kernel, instead having to
parse a gigantic /proc output)
lpaa5:~# ss -tm state listening src :22
Recv-Q Send-Q Local Address:Port Peer Address:Port
0 128 *:ssh *:*
skmem:(r0,rb8388608,t0,tb8388608,f0,w0,o0,bl0,d7)
0 128 :::ssh :::*
skmem:(r0,rb8388608,t0,tb8388608,f0,w0,o0,bl0,d0)
You can see here that the IPv4 listener for ssh had 7 drops.
Thanks.
[1] list of relevant commits.
commit 9caad864151e525929d323de96cad382da49c3b2
Author: Eric Dumazet <edumazet@google.com>
Date: Fri Apr 1 08:52:20 2016 -0700
tcp: increment sk_drops for listeners
Goal: packets dropped by a listener are accounted for.
This adds tcp_listendrop() helper, and clears sk_drops in sk_clone_lock()
so that children do not inherit their parent drop count.
Note that we no longer increment LINUX_MIB_LISTENDROPS counter when
sending a SYNCOOKIE, since the SYN packet generated a SYNACK.
We already have a separate LINUX_MIB_SYNCOOKIESSENT
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
commit 532182cd610782db8c18230c2747626562032205
Author: Eric Dumazet <edumazet@google.com>
Date: Fri Apr 1 08:52:19 2016 -0700
tcp: increment sk_drops for dropped rx packets
Now ss can report sk_drops, we can instruct TCP to increment
this per socket counter when it drops an incoming frame, to refine
monitoring and debugging.
Following patch takes care of listeners drops.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
commit 15239302edd46b184e758048253541fb211e315e
Author: Eric Dumazet <edumazet@google.com>
Date: Fri Apr 1 08:52:18 2016 -0700
sock_diag: add SK_MEMINFO_DROPS
Reporting sk_drops to user space was available for UDP
sockets using /proc interface.
Add this to sock_diag, so that we can have the same information
available to ss users, and we'll be able to add sk_drops
indications for TCP sockets as well.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next] tcp: export drops counter to /proc/net/tcp{,6}
2017-08-18 12:14 ` Eric Dumazet
@ 2017-08-18 12:50 ` Stéphan Gorget
0 siblings, 0 replies; 3+ messages in thread
From: Stéphan Gorget @ 2017-08-18 12:50 UTC (permalink / raw)
To: Eric Dumazet
Cc: netdev, Jeethu Rao, David S . Miller, Alexei Starovoitov,
Eric Dumazet, kernel-team, linux-kernel
On 8/18/17 1:14 PM, Eric Dumazet wrote:
> On Fri, 2017-08-18 at 03:21 -0700, Stéphan Gorget wrote:
>> Those counters are exported for raw and udp but not for tcp, though they
>> are incremented.
>>
>> An example where it is useful is chasing listen overflow. Listen overflow
>> are counted as a global counter in LINUX_MIB_LISTENOVERFLOWS accessible
>> in /proc/net/netstat but there is no way to find related drops in the
>> information exported for tcp. With this patch it will make possible to
>> correlate growth of LINUX_MIB_LISTENOVERFLOWS with growth of drops for
>> a tcp socket.
>
> Simply use iproute2/ss tool to access this information in a very
> efficient way (like filtering done in the kernel, instead having to
> parse a gigantic /proc output)
>
> lpaa5:~# ss -tm state listening src :22
Thanks for the quick response, I'll use ss with those options that's
exactly what I needed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-18 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 10:21 [PATCH net-next] tcp: export drops counter to /proc/net/tcp{,6} Stéphan Gorget
2017-08-18 12:14 ` Eric Dumazet
2017-08-18 12:50 ` Stéphan Gorget
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).