netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kerneljasonxing@gmail.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>,
	<edumazet@google.com>, <kernelxing@tencent.com>,
	<kuba@kernel.org>, <kuniyu@amazon.com>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>
Subject: Re: [PATCH net-next v9 08/10] tcp: add dropreasons in tcp_rcv_state_process()
Date: Fri, 23 Feb 2024 11:41:26 -0800	[thread overview]
Message-ID: <20240223194126.7246-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20240223102851.83749-9-kerneljasonxing@gmail.com>

From: Jason Xing <kerneljasonxing@gmail.com>
Date: Fri, 23 Feb 2024 18:28:49 +0800
> From: Jason Xing <kernelxing@tencent.com>
> 
> In this patch, I equipped this function with more dropreasons, but
> it still doesn't work yet, which I will do later.
> 
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> Reviewed-by: David Ahern <dsahern@kernel.org>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>


> --
> v9
> Link: https://lore.kernel.org/netdev/CAL+tcoCbsbM=HyXRqs2+QVrY8FSKmqYC47m87Axiyk1wk4omwQ@mail.gmail.com/
> Link: https://lore.kernel.org/netdev/c5640fc4-16dc-4058-97c6-bd84bae4fda1@kernel.org/
> 1. nit: remove unnecessary else (David)
> 2. add reviewed-by tag (David)
> 
> v8
> Link: https://lore.kernel.org/netdev/CANn89iJJ9XTVeC=qbSNUnOhQMAsfBfouc9qUJY7MxgQtYGmB3Q@mail.gmail.com/
> 1. add reviewed-by tag (Eric)
> 
> v5:
> Link: https://lore.kernel.org/netdev/3a495358-4c47-4a9f-b116-5f9c8b44e5ab@kernel.org/
> 1. Use new name (TCP_ABORT_ON_DATA) for readability (David)
> ---
>  include/net/tcp.h    |  2 +-
>  net/ipv4/tcp_input.c | 19 ++++++++++++-------
>  2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 58e65af74ad1..e5af9a5b411b 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -348,7 +348,7 @@ void tcp_wfree(struct sk_buff *skb);
>  void tcp_write_timer_handler(struct sock *sk);
>  void tcp_delack_timer_handler(struct sock *sk);
>  int tcp_ioctl(struct sock *sk, int cmd, int *karg);
> -int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb);
> +enum skb_drop_reason tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb);
>  void tcp_rcv_established(struct sock *sk, struct sk_buff *skb);
>  void tcp_rcv_space_adjust(struct sock *sk);
>  int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp);
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 83308cca1610..5d874817a78d 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -6619,7 +6619,8 @@ static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)
>   *	address independent.
>   */
>  
> -int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
> +enum skb_drop_reason
> +tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  {
>  	struct tcp_sock *tp = tcp_sk(sk);
>  	struct inet_connection_sock *icsk = inet_csk(sk);
> @@ -6635,7 +6636,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  
>  	case TCP_LISTEN:
>  		if (th->ack)
> -			return 1;
> +			return SKB_DROP_REASON_TCP_FLAGS;
>  
>  		if (th->rst) {
>  			SKB_DR_SET(reason, TCP_RESET);
> @@ -6704,8 +6705,12 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  				  FLAG_NO_CHALLENGE_ACK);
>  
>  	if ((int)reason <= 0) {
> -		if (sk->sk_state == TCP_SYN_RECV)
> -			return 1;	/* send one RST */
> +		if (sk->sk_state == TCP_SYN_RECV) {
> +			/* send one RST */
> +			if (!reason)
> +				return SKB_DROP_REASON_TCP_OLD_ACK;
> +			return -reason;
> +		}
>  		/* accept old ack during closing */
>  		if ((int)reason < 0) {
>  			tcp_send_challenge_ack(sk);
> @@ -6781,7 +6786,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  		if (READ_ONCE(tp->linger2) < 0) {
>  			tcp_done(sk);
>  			NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
> -			return 1;
> +			return SKB_DROP_REASON_TCP_ABORT_ON_DATA;
>  		}
>  		if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
>  		    after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
> @@ -6790,7 +6795,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  				tcp_fastopen_active_disable(sk);
>  			tcp_done(sk);
>  			NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
> -			return 1;
> +			return SKB_DROP_REASON_TCP_ABORT_ON_DATA;
>  		}
>  
>  		tmo = tcp_fin_time(sk);
> @@ -6855,7 +6860,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
>  			    after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
>  				NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
>  				tcp_reset(sk, skb);
> -				return 1;
> +				return SKB_DROP_REASON_TCP_ABORT_ON_DATA;
>  			}
>  		}
>  		fallthrough;
> -- 
> 2.37.3

  reply	other threads:[~2024-02-23 19:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 10:28 [PATCH net-next v9 00/10] introduce drop reasons for tcp receive path Jason Xing
2024-02-23 10:28 ` [PATCH net-next v9 01/10] tcp: add a dropreason definitions and prepare for cookie check Jason Xing
2024-02-23 19:12   ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 02/10] tcp: directly drop skb in cookie check for ipv4 Jason Xing
2024-02-23 19:17   ` Kuniyuki Iwashima
2024-02-23 19:21     ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 03/10] tcp: use drop reasons " Jason Xing
2024-02-23 19:22   ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 04/10] tcp: directly drop skb in cookie check for ipv6 Jason Xing
2024-02-23 19:25   ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 05/10] tcp: use drop reasons " Jason Xing
2024-02-23 19:28   ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 06/10] tcp: introduce dropreasons in receive path Jason Xing
2024-02-23 19:33   ` Kuniyuki Iwashima
2024-02-24  0:01     ` Jason Xing
2024-02-23 10:28 ` [PATCH net-next v9 07/10] tcp: add more specific possible drop reasons in tcp_rcv_synsent_state_process() Jason Xing
2024-02-23 19:35   ` Kuniyuki Iwashima
2024-02-23 10:28 ` [PATCH net-next v9 08/10] tcp: add dropreasons in tcp_rcv_state_process() Jason Xing
2024-02-23 19:41   ` Kuniyuki Iwashima [this message]
2024-02-23 10:28 ` [PATCH net-next v9 09/10] tcp: make the dropreason really work when calling tcp_rcv_state_process() Jason Xing
2024-02-23 19:44   ` Kuniyuki Iwashima
2024-02-23 23:59     ` Jason Xing
2024-02-26  3:04     ` Jason Xing
2024-02-23 10:28 ` [PATCH net-next v9 10/10] tcp: make dropreason in tcp_child_process() work Jason Xing
2024-02-23 19:47   ` Kuniyuki Iwashima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240223194126.7246-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kernelxing@tencent.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).