Skip to content

net: tcp: add skb drop reasons to tcp state change

[email protected] lkml netdev 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest8 patches 1 replyIn review
  2. v39 patches 4 repliesSuperseded
  3. v29 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v19 patches2 repliesSuperseded

Changes in v4 from the cover letter

- Eric says what I did to tcp_rcv_state_process() is too invasive, so I removed that part (for now).
- As Eric suggested, make kfree_skb_reason(skb, SKB_NOT_DROPPED) the same as consume_skb(skb), which make code simplier. This is used in 5th and 6th patch.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8net: skb: use SKB_NOT_DROPPED in kfree_skb_reason() as consume_skb()net/core/skbuff.c+9 -20 replies
2/8net: skb: introduce __skb_queue_purge_reason()include/linux/skbuff.h+9 -30 replies
3/8net: sock: introduce sk_stream_kill_queues_reason()include/net/sock.h net/core/stream.c+11 -40 replies
4/8net: inet: add skb drop reason to inet_csk_destroy_sock()include/net/dropreason.h net/ipv4/inet_connection_sock.c+6 -10 replies
5/8net: tcp: add skb drop reasons to tcp connect requestinginclude/net/dropreason.h include/net/inet_connection_sock.h include/net/tcp.h +8 more+59 -280 replies
6/8net: tcp: add skb drop reasons to tcp tw code pathinclude/net/dropreason.h include/net/tcp.h net/ipv4/tcp_ipv4.c +2 more+40 -110 replies
7/8net: tcp: add skb drop reasons to route_req()include/net/dropreason.h include/net/tcp.h net/ipv4/tcp_input.c +3 more+33 -120 replies
8/8net: tcp: use LINUX_MIB_TCPABORTONLINGER in tcp_rcv_state_process()net/ipv4/tcp_input.c+1 -10 replies

Reviews trailers per patch

6 of 8 patches have a Reviewed-by or Acked-by.

PatchJiang BiaoHao Peng
1/8
2/8R-b R-b
3/8R-b R-b
4/8R-b R-b
5/8R-b R-b
6/8R-b R-b
7/8R-b R-b
8/8

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

Read the v4 thread

Cover letter [PATCH net-next v4 0/8] net: tcp: add skb drop reasons to tcp state change

From: Menglong Dong <[email protected]>

In this series patches, skb drop reasons are add to code path of TCP state change, which we have not done before. It is hard to pass these reasons from the function to its caller, where skb is dropped. In order to do this, we have to make some functions return skb drop reasons, or pass the pointer of 'reason' to these function as an new function argument.

=============================
In order to get skb drop reasons during tcp connect requesting code path, we have to pass the pointer of the 'reason' as a new function argument of conn_request() in 'struct inet_connection_sock_af_ops'. As the return value of conn_request() can be positive or negative or 0, it's not flexible to make it return drop reasons. This work is done in the 7th patch, and functions that used as conn_request() is also modified:

dccp_v4_conn_request()
dccp_v6_conn_request()
tcp_v4_conn_request()
tcp_v6_conn_request()
subflow_v4_conn_request()
subflow_v6_conn_request()

As our target is TCP, dccp and mptcp are not handled more.

=============================
In the 6th patch, skb drop reasons are add to tcp_timewait_state_process() by adding a function argument to it. In the origin code, all skb are dropped for tw socket. In order to make less noise, use consume_skb() for the 'good' skb. This can be checked by the caller of tcp_timewait_state_process() from the value of drop reason. If the drop reason is SKB_NOT_DROPPED_YET, it means this skb should not be dropped.

=============================
In the 7th patch, skb drop reasons are add to the route_req() in struct tcp_request_sock_ops. Following functions are involved:

tcp_v4_route_req()
tcp_v6_route_req()
subflow_v4_route_req()
subflow_v6_route_req()

In this series patches, following new drop reasons are added:

- SOCKET_DESTROYED
- LISTENOVERFLOWS
- TCP_REQQFULLDROP
- TIMEWAIT
- LSM

Changes since v3:
- Eric says what I did to tcp_rcv_state_process() is too invasive, so I removed that part (for now).
- As Eric suggested, make kfree_skb_reason(skb, SKB_NOT_DROPPED) the same as consume_skb(skb), which make code simplier. This is used in 5th and 6th patch.

Changes since v2:
- move drop reasons to standalone header in another series

Changes since v1:
6/9 - fix the compile errors of dccp and mptcp (kernel test robot) 7/9 - skb is not freed on TCP_TW_ACK and 'ret' is not initizalized, fix
it (Eric Dumazet)

Menglong Dong (8):
net: skb: use SKB_NOT_DROPPED in kfree_skb_reason() as consume_skb()
net: skb: introduce __skb_queue_purge_reason()
net: sock: introduce sk_stream_kill_queues_reason()
net: inet: add skb drop reason to inet_csk_destroy_sock()
net: tcp: add skb drop reasons to tcp connect requesting
net: tcp: add skb drop reasons to tcp tw code path
net: tcp: add skb drop reasons to route_req()
net: tcp: use LINUX_MIB_TCPABORTONLINGER in tcp_rcv_state_process()

 include/linux/skbuff.h             | 12 ++++++++---
 include/net/dropreason.h           | 23 +++++++++++++++++++++
 include/net/inet_connection_sock.h |  3 ++-
 include/net/sock.h                 |  8 +++++++-
 include/net/tcp.h                  | 19 +++++++++--------
 net/core/skbuff.c                  | 11 ++++++++--
 net/core/stream.c                  |  7 ++++---
 net/dccp/dccp.h                    |  3 ++-
 net/dccp/input.c                   |  3 ++-
 net/dccp/ipv4.c                    |  3 ++-
 net/dccp/ipv6.c                    |  5 +++--
 net/ipv4/inet_connection_sock.c    |  2 +-
 net/ipv4/tcp_input.c               | 26 ++++++++++++++---------
 net/ipv4/tcp_ipv4.c                | 31 ++++++++++++++++++++--------
 net/ipv4/tcp_minisocks.c           | 23 +++++++++++++++++----
 net/ipv6/tcp_ipv6.c                | 33 ++++++++++++++++++++++--------
 net/mptcp/subflow.c                | 18 +++++++++-------
 17 files changed, 168 insertions(+), 62 deletions(-)
Signature · 1 line
2.36.1