linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 net-next 0/7] net: pass receive socket to drop tracepoint
@ 2024-06-11 20:11 Yan Zhai
  2024-06-11 20:11 ` [PATCH v4 net-next 1/7] net: add rx_sk to trace_kfree_skb Yan Zhai
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Yan Zhai @ 2024-06-11 20:11 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, David Ahern, Abhishek Chauhan, Mina Almasry,
	Florian Westphal, Alexander Lobakin, David Howells, Jiri Pirko,
	Daniel Borkmann, Sebastian Andrzej Siewior, Lorenzo Bianconi,
	Pavel Begunkov, linux-kernel, kernel-team, Jesper Dangaard Brouer,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Neil Horman,
	linux-trace-kernel, Dan Carpenter

We set up our production packet drop monitoring around the kfree_skb
tracepoint. While this tracepoint is extremely valuable for diagnosing
critical problems, it also has some limitation with drops on the local
receive path: this tracepoint can only inspect the dropped skb itself,
but such skb might not carry enough information to:

1. determine in which netns/container this skb gets dropped
2. determine by which socket/service this skb oughts to be received

The 1st issue is because skb->dev is the only member field with valid
netns reference. But skb->dev can get cleared or reused. For example,
tcp_v4_rcv will clear skb->dev and in later processing it might be reused
for OFO tree.

The 2nd issue is because there is no reference on an skb that reliably
points to a receiving socket. skb->sk usually points to the local
sending socket, and it only points to a receive socket briefly after
early demux stage, yet the socket can get stolen later. For certain drop
reason like TCP OFO_MERGE, Zerowindow, UDP at PROTO_MEM error, etc, it
is hard to infer which receiving socket is impacted. This cannot be
overcome by simply looking at the packet header, because of
complications like sk lookup programs. In the past, single purpose
tracepoints like trace_udp_fail_queue_rcv_skb, trace_sock_rcvqueue_full,
etc are added as needed to provide more visibility. This could be
handled in a more generic way.

In this change set we propose a new 'sk_skb_reason_drop' call as a drop-in
replacement for kfree_skb_reason at various local input path. It accepts
an extra receiving socket argument. Both issues above can be resolved
via this new argument.

V3->V4: adjusted the TP_STRUCT field order to align better, suggested by
Steven Rostedt.

V2->V3: fixed drop_monitor function signatures; fixed a few uninitialized sks;
Added a few missing report tags from test bots (also noticed by Dan
Carpenter and Simon Horman).

V1->V2: instead of using skb->cb, directly add the needed argument to
trace_kfree_skb tracepoint. Also renamed functions as Eric Dumazet
suggested.

V3: https://lore.kernel.org/netdev/cover.1717529533.git.yan@cloudflare.com/
V2: https://lore.kernel.org/linux-kernel/cover.1717206060.git.yan@cloudflare.com/
V1: https://lore.kernel.org/netdev/cover.1717105215.git.yan@cloudflare.com/

Yan Zhai (7):
  net: add rx_sk to trace_kfree_skb
  net: introduce sk_skb_reason_drop function
  ping: use sk_skb_reason_drop to free rx packets
  net: raw: use sk_skb_reason_drop to free rx packets
  tcp: use sk_skb_reason_drop to free rx packets
  udp: use sk_skb_reason_drop to free rx packets
  af_packet: use sk_skb_reason_drop to free rx packets

 include/linux/skbuff.h     | 10 ++++++++--
 include/trace/events/skb.h | 11 +++++++----
 net/core/dev.c             |  2 +-
 net/core/drop_monitor.c    |  9 ++++++---
 net/core/skbuff.c          | 22 ++++++++++++----------
 net/ipv4/ping.c            |  2 +-
 net/ipv4/raw.c             |  4 ++--
 net/ipv4/syncookies.c      |  2 +-
 net/ipv4/tcp_input.c       |  2 +-
 net/ipv4/tcp_ipv4.c        |  6 +++---
 net/ipv4/udp.c             | 10 +++++-----
 net/ipv6/raw.c             |  8 ++++----
 net/ipv6/syncookies.c      |  2 +-
 net/ipv6/tcp_ipv6.c        |  6 +++---
 net/ipv6/udp.c             | 10 +++++-----
 net/packet/af_packet.c     | 10 +++++-----
 16 files changed, 65 insertions(+), 51 deletions(-)

-- 
2.30.2



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-14 19:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11 20:11 [PATCH v4 net-next 0/7] net: pass receive socket to drop tracepoint Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 1/7] net: add rx_sk to trace_kfree_skb Yan Zhai
2024-06-12  7:59   ` Jesper Dangaard Brouer
2024-06-14 10:15     ` Paolo Abeni
2024-06-14 19:40       ` Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 2/7] net: introduce sk_skb_reason_drop function Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 3/7] ping: use sk_skb_reason_drop to free rx packets Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 4/7] net: raw: " Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 5/7] tcp: " Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 6/7] udp: " Yan Zhai
2024-06-11 20:11 ` [PATCH v4 net-next 7/7] af_packet: " Yan Zhai

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).