tcp: drop reason additions
Subsystems (4)
cover tcp: drop reason additions
From: Eric Dumazet <[email protected]>
Currently, TCP is either missing drop reasons, or pretending that some useful packets are dropped.
This patch series makes "perf record -a -e skb:kfree_skb" much more usable.
Eric Dumazet (10):
tcp: consume incoming skb leading to a reset
tcp: get rid of rst_seq_match
tcp: add drop reason support to tcp_validate_incoming()
tcp: make tcp_rcv_state_process() drop monitor friendly
tcp: add drop reasons to tcp_rcv_state_process()
tcp: add two drop reasons for tcp_ack()
tcp: add drop reason support to tcp_prune_ofo_queue()
tcp: make tcp_rcv_synsent_state_process() drop monitor friend
tcp: add drop reasons to tcp_rcv_synsent_state_process()
tcp: add drop reason support to tcp_ofo_queue()
include/linux/skbuff.h | 13 ++++ include/trace/events/skb.h | 14 ++++ net/ipv4/tcp_input.c | 127 +++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 54 deletions(-)
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 1/10 tcp: consume incoming skb leading to a reset
From: Eric Dumazet <[email protected]>
Whenever tcp_validate_incoming() handles a valid RST packet, we should not pretend the packet was dropped.
Create a special section at the end of tcp_validate_incoming() to handle this case.
--- net/ipv4/tcp_input.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
net/ipv4/tcp_input.c +16 -12
@@ -5700,7 +5700,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, &tp->last_oow_ack_time))tcp_send_dupack (sk, skb); }else if (tcp_reset_check (sk, skb)) { -tcp_reset (sk, skb); + goto reset; } goto discard; }
@@ -5736,17 +5736,16 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, }if (rst_seq_match) -tcp_reset (sk, skb); -else { -/* Disable TFO if RST is out-of-order -* and no data has been received -* for current active TFO socket -*/ -if (tp->syn_fastopen && !tp->data_segs_in && - sk->sk_state ==TCP_ESTABLISHED ) -tcp_fastopen_active_disable (sk); -tcp_send_challenge_ack (sk); - } + goto reset; + +/* Disable TFO if RST is out-of-order +* and no data has been received +* for current active TFO socket +*/ +if (tp->syn_fastopen && !tp->data_segs_in && + sk->sk_state ==TCP_ESTABLISHED ) +tcp_fastopen_active_disable (sk); +tcp_send_challenge_ack (sk); goto discard; }
@@ -5771,6 +5770,11 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, discard:tcp_drop (sk, skb);return false; + +reset: +tcp_reset (sk, skb); +__kfree_skb (skb); +return false; }/*
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 2/10 tcp: get rid of rst_seq_match
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Small cleanup in tcp_validate_incoming(), no need for rst_seq_match setting and testing.
--- net/ipv4/tcp_input.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
net/ipv4/tcp_input.c +5 -8
@@ -5667,7 +5667,6 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th, int syn_inerr) {struct tcp_sock *tp =tcp_sk (sk); -bool rst_seq_match = false;/* RFC1323: H1. Apply PAWS check first. */ if (tcp_fast_parse_options(sock_net(sk), skb, th, tp) &&
@@ -5717,9 +5716,10 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,* Send a challenge ACK */ if (TCP_SKB_CB (skb)->seq == tp->rcv_nxt || -tcp_reset_check (sk, skb)) { - rst_seq_match = true; - }else if (tcp_is_sack (tp) && tp->rx_opt.num_sacks >0 ) { +tcp_reset_check (sk, skb)) + goto reset; + +if (tcp_is_sack (tp) && tp->rx_opt.num_sacks >0 ) {struct tcp_sack_block *sp = &tp->selective_acks[0 ];int max_sack = sp[0 ].end_seq;int this_sack;
@@ -5732,12 +5732,9 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, }if (TCP_SKB_CB (skb)->seq == max_sack) - rst_seq_match = true; + goto reset; } -if (rst_seq_match) - goto reset; -/* Disable TFO if RST is out-of-order * and no data has been received * for current active TFO socket
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 3/10 tcp: add drop reason support to tcp_validate_incoming()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Creates four new drop reasons for the following cases:
1) packet being rejected by RFC 7323 PAWS check
2) packet being rejected by SEQUENCE check
3) Invalid RST packet
4) Invalid SYN packet
--- include/linux/skbuff.h | 6 ++++++ include/trace/events/skb.h | 5 +++++ net/ipv4/tcp_input.c | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-)
include/linux/skbuff.h +6 -0
@@ -381,6 +381,12 @@ enum skb_drop_reason {* the ofo queue, corresponding to * LINUX_MIB_TCPOFOMERGE */ +SKB_DROP_REASON_TCP_RFC7323_PAWS ,/* PAWS check, corresponding to +* LINUX_MIB_PAWSESTABREJECTED +*/ +SKB_DROP_REASON_TCP_INVALID_SEQUENCE ,/* Not acceptable SEQ field */ +SKB_DROP_REASON_TCP_RESET ,/* Invalid RST packet */ +SKB_DROP_REASON_TCP_INVALID_SYN ,/* Incoming packet has unexpected SYN flag */ SKB_DROP_REASON_IP_OUTNOROUTES ,/* route lookup failed */ SKB_DROP_REASON_BPF_CGROUP_EGRESS, /* dropped by* BPF_PROG_TYPE_CGROUP_SKB
include/trace/events/skb.h +5 -0
@@ -37,6 +37,11 @@ EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA) \ EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW) \ EM(SKB_DROP_REASON_TCP_OFOMERGE, TCP_OFOMERGE) \ + EM(SKB_DROP_REASON_TCP_RFC7323_PAWS, TCP_RFC7323_PAWS) \ +EM (SKB_DROP_REASON_TCP_INVALID_SEQUENCE , \ + TCP_INVALID_SEQUENCE) \ + EM(SKB_DROP_REASON_TCP_RESET, TCP_RESET) \ + EM(SKB_DROP_REASON_TCP_INVALID_SYN, TCP_INVALID_SYN) \ EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES) \EM (SKB_DROP_REASON_BPF_CGROUP_EGRESS , \BPF_CGROUP_EGRESS ) \
net/ipv4/tcp_input.c +6 -1
@@ -5667,6 +5667,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th, int syn_inerr) {struct tcp_sock *tp =tcp_sk (sk); +SKB_DR (reason);/* RFC1323: H1. Apply PAWS check first. */ if (tcp_fast_parse_options(sock_net(sk), skb, th, tp) &&
@@ -5678,6 +5679,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, LINUX_MIB_TCPACKSKIPPEDPAWS, &tp->last_oow_ack_time))tcp_send_dupack (sk, skb); +SKB_DR_SET (reason,TCP_RFC7323_PAWS ); goto discard; }/* Reset is accepted even if it did not pass PAWS. */
@@ -5701,6 +5703,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, }else if (tcp_reset_check (sk, skb)) { goto reset; } +SKB_DR_SET (reason,TCP_INVALID_SEQUENCE ); goto discard; }
@@ -5743,6 +5746,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, sk->sk_state == TCP_ESTABLISHED)tcp_fastopen_active_disable (sk);tcp_send_challenge_ack (sk); +SKB_DR_SET (reason,TCP_RESET ); goto discard; }
@@ -5757,6 +5761,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk); +SKB_DR_SET (reason,TCP_INVALID_SYN ); goto discard; }
@@ -5765,7 +5770,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,return true; discard: -tcp_drop (sk, skb); +tcp_drop_reason (sk, skb, reason);return false; reset:
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 4/10 tcp: make tcp_rcv_state_process() drop monitor friendly
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
tcp_rcv_state_process() incorrectly drops packets instead of consuming it, making drop monitor very noisy, if not unusable.
Calling tcp_time_wait() or tcp_done() is part of standard behavior, packets triggering these actions were not dropped.
--- net/ipv4/tcp_input.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +7 -3
@@ -6580,7 +6580,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)inet_csk_reset_keepalive_timer (sk, tmo); }else {tcp_time_wait (sk,TCP_FIN_WAIT2 , tmo); - goto discard; + goto consume; }break ; }
@@ -6588,7 +6588,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)case TCP_CLOSING :if (tp->snd_una == tp->write_seq) {tcp_time_wait (sk,TCP_TIME_WAIT ,0 ); - goto discard; + goto consume; }break ;
@@ -6596,7 +6596,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)if (tp->snd_una == tp->write_seq) {tcp_update_metrics (sk);tcp_done (sk); - goto discard; + goto consume; }break ; }
@@ -6650,6 +6650,10 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)tcp_drop (sk, skb); }return 0 ; + +consume: +__kfree_skb (skb); +return 0 ; }EXPORT_SYMBOL (tcp_rcv_state_process);
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 5/10 tcp: add drop reasons to tcp_rcv_state_process()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Add basic support for drop reasons in tcp_rcv_state_process()
--- include/linux/skbuff.h | 3 +++ include/trace/events/skb.h | 3 +++ net/ipv4/tcp_input.c | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-)
include/linux/skbuff.h +3 -0
@@ -387,6 +387,9 @@ enum skb_drop_reason {SKB_DROP_REASON_TCP_INVALID_SEQUENCE ,/* Not acceptable SEQ field */ SKB_DROP_REASON_TCP_RESET ,/* Invalid RST packet */ SKB_DROP_REASON_TCP_INVALID_SYN ,/* Incoming packet has unexpected SYN flag */ +SKB_DROP_REASON_TCP_CLOSE ,/* TCP socket in CLOSE state */ +SKB_DROP_REASON_TCP_FASTOPEN ,/* dropped by FASTOPEN request socket */ +SKB_DROP_REASON_TCP_OLD_ACK ,/* TCP ACK is old, but in window */ SKB_DROP_REASON_IP_OUTNOROUTES ,/* route lookup failed */ SKB_DROP_REASON_BPF_CGROUP_EGRESS ,/* dropped by * BPF_PROG_TYPE_CGROUP_SKB
include/trace/events/skb.h +3 -0
@@ -42,6 +42,9 @@ TCP_INVALID_SEQUENCE) \ EM(SKB_DROP_REASON_TCP_RESET, TCP_RESET) \ EM(SKB_DROP_REASON_TCP_INVALID_SYN, TCP_INVALID_SYN) \ + EM(SKB_DROP_REASON_TCP_CLOSE, TCP_CLOSE) \ + EM(SKB_DROP_REASON_TCP_FASTOPEN, TCP_FASTOPEN) \ + EM(SKB_DROP_REASON_TCP_OLD_ACK, TCP_OLD_ACK) \ EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES) \ EM(SKB_DROP_REASON_BPF_CGROUP_EGRESS, \ BPF_CGROUP_EGRESS) \
net/ipv4/tcp_input.c +17 -7
@@ -6413,21 +6413,26 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)struct request_sock *req;int queued =0 ;bool acceptable; +SKB_DR (reason);switch (sk->sk_state) {case TCP_CLOSE : +SKB_DR_SET (reason,TCP_CLOSE ); goto discard;case TCP_LISTEN :if (th->ack)return 1 ; -if (th->rst) +if (th->rst) { +SKB_DR_SET (reason,TCP_RESET ); goto discard; - + }if (th->syn) { -if (th->fin) +if (th->fin) { +SKB_DR_SET (reason,TCP_FLAGS ); goto discard; + }/* It is possible that we process SYN packets from backlog, * so we need to make sure to disable BH and RCU right there. */
@@ -6442,6 +6447,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)consume_skb (skb);return 0 ; } +SKB_DR_SET (reason,TCP_FLAGS ); goto discard;case TCP_SYN_SENT :
@@ -6468,13 +6474,16 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)WARN_ON_ONCE (sk->sk_state !=TCP_SYN_RECV && sk->sk_state !=TCP_FIN_WAIT1 ); -if (!tcp_check_req (sk, skb, req, true, &req_stolen)) +if (!tcp_check_req (sk, skb, req, true, &req_stolen)) { +SKB_DR_SET (reason,TCP_FASTOPEN ); goto discard; + } } -if (!th->ack && !th->rst && !th->syn) +if (!th->ack && !th->rst && !th->syn) { +SKB_DR_SET (reason,TCP_FLAGS ); goto discard; - + }if (!tcp_validate_incoming (sk, skb, th,0 ))return 0 ;
@@ -6487,6 +6496,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)if (sk->sk_state ==TCP_SYN_RECV )return 1 ;/* send one RST */ tcp_send_challenge_ack (sk); +SKB_DR_SET (reason,TCP_OLD_ACK ); goto discard; }switch (sk->sk_state) {
@@ -6647,7 +6657,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)if (!queued) { discard: -tcp_drop (sk, skb); +tcp_drop_reason (sk, skb, reason); }return 0 ;
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 6/10 tcp: add two drop reasons for tcp_ack()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Add TCP_TOO_OLD_ACK and TCP_ACK_UNSENT_DATA drop
reasons so that tcp_rcv_established() can report
them.
--- include/linux/skbuff.h | 2 ++ include/trace/events/skb.h | 3 +++ net/ipv4/tcp_input.c | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-)
include/linux/skbuff.h +2 -0
@@ -390,6 +390,8 @@ enum skb_drop_reason {SKB_DROP_REASON_TCP_CLOSE ,/* TCP socket in CLOSE state */ SKB_DROP_REASON_TCP_FASTOPEN ,/* dropped by FASTOPEN request socket */ SKB_DROP_REASON_TCP_OLD_ACK ,/* TCP ACK is old, but in window */ +SKB_DROP_REASON_TCP_TOO_OLD_ACK ,/* TCP ACK is too old */ +SKB_DROP_REASON_TCP_ACK_UNSENT_DATA ,/* TCP ACK for data we haven't sent yet */ SKB_DROP_REASON_IP_OUTNOROUTES ,/* route lookup failed */ SKB_DROP_REASON_BPF_CGROUP_EGRESS ,/* dropped by * BPF_PROG_TYPE_CGROUP_SKB
include/trace/events/skb.h +3 -0
@@ -45,6 +45,9 @@ EM(SKB_DROP_REASON_TCP_CLOSE, TCP_CLOSE) \ EM(SKB_DROP_REASON_TCP_FASTOPEN, TCP_FASTOPEN) \ EM(SKB_DROP_REASON_TCP_OLD_ACK, TCP_OLD_ACK) \ + EM(SKB_DROP_REASON_TCP_TOO_OLD_ACK, TCP_TOO_OLD_ACK) \ +EM (SKB_DROP_REASON_TCP_ACK_UNSENT_DATA , \ + TCP_ACK_UNSENT_DATA) \ EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES) \EM (SKB_DROP_REASON_BPF_CGROUP_EGRESS , \BPF_CGROUP_EGRESS ) \
net/ipv4/tcp_input.c +4 -3
@@ -3766,7 +3766,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)if (before (ack, prior_snd_una - tp->max_window)) {if (!(flag &FLAG_NO_CHALLENGE_ACK ))tcp_send_challenge_ack (sk); -return -1 ; +return -SKB_DROP_REASON_TCP_TOO_OLD_ACK ; } goto old_ack; }
@@ -3775,7 +3775,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)* this segment (RFC793 Section 3.9). */ if (after (ack, tp->snd_nxt)) -return -1 ; +return -SKB_DROP_REASON_TCP_ACK_UNSENT_DATA ;if (after (ack, prior_snd_una)) { flag |=FLAG_SND_UNA_ADVANCED ;
@@ -5962,7 +5962,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)return ; step5: -if (tcp_ack (sk, skb,FLAG_SLOWPATH |FLAG_UPDATE_TS_RECENT ) <0 ) + reason =tcp_ack (sk, skb,FLAG_SLOWPATH |FLAG_UPDATE_TS_RECENT ); +if (reason <0 ) goto discard;tcp_rcv_rtt_measure_ts (sk, skb);
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 7/10 tcp: add drop reason support to tcp_prune_ofo_queue()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Add one reason for packets dropped from OFO queue because of memory pressure.
--- include/linux/skbuff.h | 1 + include/trace/events/skb.h | 2 ++ net/ipv4/tcp_input.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-)
include/linux/skbuff.h +1 -0
@@ -392,6 +392,7 @@ enum skb_drop_reason {SKB_DROP_REASON_TCP_OLD_ACK ,/* TCP ACK is old, but in window */ SKB_DROP_REASON_TCP_TOO_OLD_ACK ,/* TCP ACK is too old */ SKB_DROP_REASON_TCP_ACK_UNSENT_DATA ,/* TCP ACK for data we haven't sent yet */ +SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE ,/* pruned from TCP OFO queue */ SKB_DROP_REASON_IP_OUTNOROUTES ,/* route lookup failed */ SKB_DROP_REASON_BPF_CGROUP_EGRESS, /* dropped by* BPF_PROG_TYPE_CGROUP_SKB
include/trace/events/skb.h +2 -0
@@ -48,6 +48,8 @@ EM(SKB_DROP_REASON_TCP_TOO_OLD_ACK, TCP_TOO_OLD_ACK) \EM (SKB_DROP_REASON_TCP_ACK_UNSENT_DATA , \ TCP_ACK_UNSENT_DATA) \ +EM (SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE , \ + TCP_OFO_QUEUE_PRUNE) \ EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES) \EM (SKB_DROP_REASON_BPF_CGROUP_EGRESS , \BPF_CGROUP_EGRESS ) \
net/ipv4/tcp_input.c +2 -1
@@ -5334,7 +5334,8 @@ static bool tcp_prune_ofo_queue(struct sock *sk) prev =rb_prev (node);rb_erase (node, &tp->out_of_order_queue); goal -=rb_to_skb (node)->truesize; -tcp_drop (sk,rb_to_skb (node)); +tcp_drop_reason (sk,rb_to_skb (node), +SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE );if (!prev || goal <=0 ) {sk_mem_reclaim (sk); if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 8/10 tcp: make tcp_rcv_synsent_state_process() drop monitor friend
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
1) A valid RST packet should be consumed, to not confuse drop monitor.
2) Same remark for packet validating cross syn setup, even if we might ignore part of it.
3) When third packet of 3WHS is delayed, do not pretend the SYNACK was dropped.
--- net/ipv4/tcp_input.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
net/ipv4/tcp_input.c +8 -9
@@ -6186,7 +6186,9 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,if (th->rst) {tcp_reset (sk, skb); - goto discard; +consume: +__kfree_skb (skb); +return 0 ; }/* rfc793:
@@ -6275,13 +6277,9 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,tcp_enter_quickack_mode (sk,TCP_MAX_QUICKACKS );inet_csk_reset_xmit_timer (sk,ICSK_TIME_DACK ,TCP_DELACK_MAX ,TCP_RTO_MAX ); - -discard: -tcp_drop (sk, skb); -return 0 ; - }else { -tcp_send_ack (sk); + goto consume; } +tcp_send_ack (sk);return -1 ; }
@@ -6350,7 +6348,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,*/ return -1 ;#else - goto discard; + goto consume;#endif }/* "fifth, if neither of the SYN or RST bits is set then
@@ -6360,7 +6358,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, discard_and_undo:tcp_clear_options (&tp->rx_opt); tp->rx_opt.mss_clamp = saved_clamp; - goto discard; +tcp_drop (sk, skb); +return 0 ; reset_and_undo:tcp_clear_options (&tp->rx_opt);
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 9/10 tcp: add drop reasons to tcp_rcv_synsent_state_process()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Re-use existing reasons.
--- net/ipv4/tcp_input.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/ipv4/tcp_input.c +9 -6
@@ -6144,6 +6144,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,struct tcp_fastopen_cookie foc = { .len =-1 };int saved_clamp = tp->rx_opt.mss_clamp;bool fastopen_fail; +SKB_DR (reason);tcp_parse_options (sock_net (sk), skb, &tp->rx_opt,0 , &foc);if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr)
@@ -6198,9 +6199,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,* See note below! * --ANK(990513) */ -if (!th->syn) +if (!th->syn) { +SKB_DR_SET (reason,TCP_FLAGS ); goto discard_and_undo; - + }/* rfc793: * "If the SYN bit is on ... * are acceptable then ...
@@ -6291,15 +6293,16 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,* * Otherwise (no ACK) drop the segment and return." */ - +SKB_DR_SET (reason,TCP_RESET ); goto discard_and_undo; }/* PAWS check. */ if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp && -tcp_paws_reject (&tp->rx_opt,0 )) +tcp_paws_reject (&tp->rx_opt,0 )) { +SKB_DR_SET (reason,TCP_RFC7323_PAWS ); goto discard_and_undo; - + }if (th->syn) {/* We see SYN without ACK. It is attempt of * simultaneous connect with crossed SYNs.
@@ -6358,7 +6361,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, discard_and_undo:tcp_clear_options (&tp->rx_opt); tp->rx_opt.mss_clamp = saved_clamp; -tcp_drop (sk, skb); +tcp_drop_reason (sk, skb, reason);return 0 ; reset_and_undo:
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
PATCH 10/10 tcp: add drop reason support to tcp_ofo_queue()
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
packets in OFO queue might be redundant, and dropped.
tcp_drop() is no longer needed.
--- include/linux/skbuff.h | 1 + include/trace/events/skb.h | 1 + net/ipv4/tcp_input.c | 9 ++------- 3 files changed, 4 insertions(+), 7 deletions(-)
include/linux/skbuff.h +1 -0
@@ -393,6 +393,7 @@ enum skb_drop_reason {SKB_DROP_REASON_TCP_TOO_OLD_ACK ,/* TCP ACK is too old */ SKB_DROP_REASON_TCP_ACK_UNSENT_DATA ,/* TCP ACK for data we haven't sent yet */ SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE ,/* pruned from TCP OFO queue */ +SKB_DROP_REASON_TCP_OFO_DROP ,/* data already in receive queue */ SKB_DROP_REASON_IP_OUTNOROUTES ,/* route lookup failed */ SKB_DROP_REASON_BPF_CGROUP_EGRESS, /* dropped by* BPF_PROG_TYPE_CGROUP_SKB
include/trace/events/skb.h +1 -0
@@ -37,6 +37,7 @@ EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA) \ EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW) \ EM(SKB_DROP_REASON_TCP_OFOMERGE, TCP_OFOMERGE) \ + EM(SKB_DROP_REASON_TCP_OFO_DROP, TCP_OFO_DROP) \ EM(SKB_DROP_REASON_TCP_RFC7323_PAWS, TCP_RFC7323_PAWS) \EM (SKB_DROP_REASON_TCP_INVALID_SEQUENCE , \TCP_INVALID_SEQUENCE ) \
net/ipv4/tcp_input.c +2 -7
@@ -4674,7 +4674,7 @@ static bool tcp_ooo_try_coalesce(struct sock *sk, {bool res =tcp_try_coalesce (sk, to, from, fragstolen); -/* In case tcp_drop() is called later, update to->gso_segs */ +/* In case tcp_drop_reason() is called later, update to->gso_segs */ if (res) {u32 gso_segs =max_t (u16,1 ,skb_shinfo (to)->gso_segs) +max_t (u16,1 ,skb_shinfo (from)->gso_segs);
@@ -4691,11 +4691,6 @@ static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,kfree_skb_reason (skb, reason); } -static void tcp_drop (struct sock *sk,struct sk_buff *skb) -{ -tcp_drop_reason (sk, skb,SKB_DROP_REASON_NOT_SPECIFIED ); -} -/* This one checks to see if we can put data from the * out_of_order queue into the receive_queue. */
@@ -4723,7 +4718,7 @@ static void tcp_ofo_queue(struct sock *sk)rb_erase (&skb->rbnode, &tp->out_of_order_queue);if (unlikely (!after (TCP_SKB_CB (skb)->end_seq, tp->rcv_nxt))) { -tcp_drop (sk, skb); +tcp_drop_reason (sk, skb,SKB_DROP_REASON_TCP_OFO_DROP );continue ; }
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 9 lines · On Fri, 15 Apr 2022 17:10:38 -0700 you wrote:
From: Eric Dumazet <[email protected]>
Currently, TCP is either missing drop reasons, or pretending that some useful packets are dropped.
This patch series makes "perf record -a -e skb:kfree_skb" much more usable.
[...]
Here is the summary with links:
- [net-next,01/10] tcp: consume incoming skb leading to a reset
https://git.kernel.org/netdev/net-next/c/d9d024f96609 - [net-next,02/10] tcp: get rid of rst_seq_match https://git.kernel.org/netdev/net-next/c/b5ec1e6205a1 - [net-next,03/10] tcp: add drop reason support to tcp_validate_incoming() https://git.kernel.org/netdev/net-next/c/da40b613f89c - [net-next,04/10] tcp: make tcp_rcv_state_process() drop monitor friendly https://git.kernel.org/netdev/net-next/c/37fd4e842391 - [net-next,05/10] tcp: add drop reasons to tcp_rcv_state_process() https://git.kernel.org/netdev/net-next/c/669da7a71890 - [net-next,06/10] tcp: add two drop reasons for tcp_ack() https://git.kernel.org/netdev/net-next/c/4b506af9c5b8 - [net-next,07/10] tcp: add drop reason support to tcp_prune_ofo_queue() https://git.kernel.org/netdev/net-next/c/e7c89ae4078e - [net-next,08/10] tcp: make tcp_rcv_synsent_state_process() drop monitor friend https://git.kernel.org/netdev/net-next/c/c337578a6592 - [net-next,09/10] tcp: add drop reasons to tcp_rcv_synsent_state_process() https://git.kernel.org/netdev/net-next/c/659affdb5140 - [net-next,10/10] tcp: add drop reason support to tcp_ofo_queue() https://git.kernel.org/netdev/net-next/c/8fbf195798b5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html