Skip to content

net: pass receive socket to drop tracepoint

Yan Zhai linux-trace-kernel lkml netdev 5 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest7 patches 7 repliesApplied 7/7
  2. v47 patches 3 repliesSuperseded
  3. v3 RFC7 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC7 patches2 repliesSuperseded
v1 RFC6 patches8 repliesSuperseded

Patches in v5 All 7 applied

#Subject and filesSizeRepliesApplied
1/7net: add rx_sk to trace_kfree_skbinclude/trace/events/skb.h net/core/dev.c net/core/drop_monitor.c +1 more+15 -91 replyApplied
2/7net: introduce sk_skb_reason_drop functioninclude/linux/skbuff.h net/core/skbuff.c+20 -121 replyApplied
3/7ping: use sk_skb_reason_drop to free rx packetsnet/ipv4/ping.c+1 -11 replyApplied
4/7net: raw: use sk_skb_reason_drop to free rx packetsnet/ipv4/raw.c net/ipv6/raw.c+6 -61 replyApplied
5/7tcp: use sk_skb_reason_drop to free rx packetsnet/ipv4/syncookies.c net/ipv4/tcp_input.c net/ipv4/tcp_ipv4.c +2 more+9 -91 replyApplied
6/7udp: use sk_skb_reason_drop to free rx packetsnet/ipv4/udp.c net/ipv6/udp.c+10 -101 replyApplied
7/7af_packet: use sk_skb_reason_drop to free rx packetsnet/packet/af_packet.c+5 -51 replyApplied

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchJesper Dangaard Brouer
1/7A-b
2/7A-b
3/7A-b
4/7A-b
5/7A-b
6/7A-b
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH net-next v5 0/7] net: pass receive socket to drop tracepoint

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.

V4->V5: rename rx_skaddr to rx_sk to be more clear visually, suggested by Jesper Dangaard Brouer.

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.

V4: https://lore.kernel.org/netdev/[email protected]/
V3: https://lore.kernel.org/netdev/[email protected]/
V2: https://lore.kernel.org/linux-kernel/[email protected]/
V1: https://lore.kernel.org/netdev/[email protected]/

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(-)
Signature · 1 line
2.30.2