Skip to content

net: add skb drop reasons to TCP packet receive

[email protected] bpf lkml netdev 3 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 0 repliesApplied 9/9
  2. v29 patches 3 repliesSuperseded
  3. v19 patches 8 repliesSuperseded

Changes in v3 from the cover letter

- remove the 'inline' of tcp_drop() in the 1th patch, as Jakub suggested

Patches in v3 All 9 applied

#Subject and filesSizeRepliesApplied
1/9net: tcp: introduce tcp_drop_reason()net/ipv4/tcp_input.c+8 -20 repliesApplied
2/9net: tcp: add skb drop reasons to tcp_v4_rcv()net/ipv4/tcp_ipv4.c+6 -10 repliesApplied
3/9net: tcp: use kfree_skb_reason() for tcp_v6_rcv()net/ipv6/tcp_ipv6.c+17 -40 repliesApplied
4/9net: tcp: add skb drop reasons to tcp_v{4,6}_inbound_md5_hash()include/linux/skbuff.h include/trace/events/skb.h net/ipv4/tcp_ipv4.c +1 more+33 -70 repliesApplied
5/9net: tcp: add skb drop reasons to tcp_add_backlog()include/linux/skbuff.h include/net/tcp.h include/trace/events/skb.h +2 more+13 -40 repliesApplied
6/9net: tcp: use kfree_skb_reason() for tcp_v{4,6}_do_rcv()net/ipv4/tcp_ipv4.c net/ipv6/tcp_ipv6.c+8 -20 repliesApplied
7/9net: tcp: use tcp_drop_reason() for tcp_rcv_established()include/linux/skbuff.h include/trace/events/skb.h net/ipv4/tcp_input.c+9 -20 repliesApplied
8/9net: tcp: use tcp_drop_reason() for tcp_data_queue()include/linux/skbuff.h include/trace/events/skb.h net/ipv4/tcp_input.c+27 -20 repliesApplied
9/9net: tcp: use tcp_drop_reason() for tcp_data_queue_ofo()include/linux/skbuff.h include/trace/events/skb.h net/ipv4/tcp_input.c+11 -40 repliesApplied

Reviews trailers per patch

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

PatchMengen SunHao PengEric DumazetDavid Ahern
1/9R-b R-b R-b R-b
2/9R-b R-b R-b R-b
3/9R-b R-b R-b R-b
4/9R-b R-b R-b R-b
5/9R-b R-b R-b R-b
6/9R-b R-b R-b R-b
7/9R-b R-b R-b R-b
8/9R-b R-b R-b R-b
9/9R-b R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH net-next v3 0/9] net: add skb drop reasons to TCP packet receive

From: Menglong Dong <[email protected]>

In the commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()"), we added the support of reporting the reasons of skb drops to kfree_skb tracepoint. And in this series patches, reasons for skb drops are added to TCP layer (both TCPv4 and TCPv6 are considered). Following functions are processed:

tcp_v4_rcv()
tcp_v6_rcv()
tcp_v4_inbound_md5_hash()
tcp_v6_inbound_md5_hash()
tcp_add_backlog()
tcp_v4_do_rcv()
tcp_v6_do_rcv()
tcp_rcv_established()
tcp_data_queue()
tcp_data_queue_ofo()

The functions we handled are mostly for packet ingress, as skb drops hardly happens in the egress path of TCP layer. However, it's a little complex for TCP state processing, as I find that it's hard to report skb drop reasons to where it is freed. For example, when skb is dropped in tcp_rcv_state_process(), the reason can be caused by the call of tcp_v4_conn_request(), and it's hard to return a drop reason from tcp_v4_conn_request(). So such cases are skipped for this moment.

Following new drop reasons are introduced (what they mean can be see in the document for them):

/* SKB_DROP_REASON_TCP_MD5* corresponding to LINUX_MIB_TCPMD5* */ SKB_DROP_REASON_TCP_MD5NOTFOUND SKB_DROP_REASON_TCP_MD5UNEXPECTED SKB_DROP_REASON_TCP_MD5FAILURE SKB_DROP_REASON_SOCKET_BACKLOG SKB_DROP_REASON_TCP_FLAGS SKB_DROP_REASON_TCP_ZEROWINDOW SKB_DROP_REASON_TCP_OLD_DATA SKB_DROP_REASON_TCP_OVERWINDOW
/* corresponding to LINUX_MIB_TCPOFOMERGE */ SKB_DROP_REASON_TCP_OFOMERGE

Here is a example to get TCP packet drop reasons from ftrace:

$ echo 1 > /sys/kernel/debug/tracing/events/skb/kfree_skb/enable
$ cat /sys/kernel/debug/tracing/trace
$ <idle>-0       [036] ..s1.   647.428165: kfree_skb: skbaddr=000000004d037db6 protocol=2048 location=0000000074cd1243 reason: NO_SOCKET
$ <idle>-0       [020] ..s2.   639.676674: kfree_skb: skbaddr=00000000bcbfa42d protocol=2048 location=00000000bfe89d35 reason: PROTO_MEM

From the reason 'PROTO_MEM' we can know that the skb is dropped because the memory configured in net.ipv4.tcp_mem is up to the limition.

Changes since v2:
- remove the 'inline' of tcp_drop() in the 1th patch, as Jakub suggested

Changes since v1:
- enrich the document for this series patches in the cover letter, as Eric suggested
- fix compile warning report by Jakub in the 6th patch
- let NO_SOCKET trump the XFRM failure in the 2th and 3th patches

Menglong Dong (9):
net: tcp: introduce tcp_drop_reason()
net: tcp: add skb drop reasons to tcp_v4_rcv()
net: tcp: use kfree_skb_reason() for tcp_v6_rcv()
net: tcp: add skb drop reasons to tcp_v{4,6}_inbound_md5_hash()
net: tcp: add skb drop reasons to tcp_add_backlog()
net: tcp: use kfree_skb_reason() for tcp_v{4,6}_do_rcv()
net: tcp: use tcp_drop_reason() for tcp_rcv_established()
net: tcp: use tcp_drop_reason() for tcp_data_queue()
net: tcp: use tcp_drop_reason() for tcp_data_queue_ofo()

 include/linux/skbuff.h     | 34 ++++++++++++++++++++++++++++++
 include/net/tcp.h          |  3 ++-
 include/trace/events/skb.h | 10 +++++++++
 net/ipv4/tcp_input.c       | 42 +++++++++++++++++++++++++++++---------
 net/ipv4/tcp_ipv4.c        | 32 +++++++++++++++++++++--------
 net/ipv6/tcp_ipv6.c        | 39 +++++++++++++++++++++++++++--------
 6 files changed, 132 insertions(+), 28 deletions(-)
Signature · 1 line
2.34.1