Messages in this thread Patch in this message | | | From | menglong8.dong@gmail ... | Subject | [PATCH net-next v3 4/9] net: tcp: make tcp_rcv_synsent_state_process() return drop reasons | Date | Fri, 10 Jun 2022 11:41:59 +0800 |
| |
From: Menglong Dong <imagedong@tencent.com>
The return value of tcp_rcv_synsent_state_process() can be -1, 0 or 1:
- -1: free skb silently - 0: success and skb is already freed - 1: drop packet and send a RST
Therefore, we can make it return skb drop reasons instead of '1' on 'reset_and_undo' path, which will not impact the caller.
The new reason 'TCP_PAWSACTIVEREJECTED' is added, which is corresponding to LINUX_MIB_PAWSACTIVEREJECTED.
Reviewed-by: Jiang Biao <benbjiang@tencent.com> Reviewed-by: Hao Peng <flyingpeng@tencent.com> Signed-off-by: Menglong Dong <imagedong@tencent.com> --- include/net/dropreason.h | 6 ++++++ net/ipv4/tcp_input.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 3c6f1e299c35..c60913aba0e9 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -236,6 +236,12 @@ enum skb_drop_reason { * skb in its receive or send queue are all dropped */ SKB_DROP_REASON_SOCKET_DESTROYED, + /** + * @SKB_DROP_REASON_TCP_PAWSACTIVEREJECTED: PAWS check failed for + * active TCP connection, corresponding to + * LINUX_MIB_PAWSACTIVEREJECTED + */ + SKB_DROP_REASON_TCP_PAWSACTIVEREJECTED, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2e2a9ece9af2..9254f14def43 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6177,6 +6177,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, TCP_TIMEOUT_MIN, TCP_RTO_MAX); + if (after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) + SKB_DR_SET(reason, TCP_ACK_UNSENT_DATA); + else + SKB_DR_SET(reason, TCP_TOO_OLD_ACK); goto reset_and_undo; } @@ -6185,6 +6189,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, tcp_time_stamp(tp))) { NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSACTIVEREJECTED); + SKB_DR_SET(reason, TCP_PAWSACTIVEREJECTED); goto reset_and_undo; } @@ -6378,7 +6383,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, reset_and_undo: tcp_clear_options(&tp->rx_opt); tp->rx_opt.mss_clamp = saved_clamp; - return 1; + return reason; } static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) -- 2.36.1
| |