netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: [PATCH net-next 01/10] tcp: consume incoming skb leading to a reset
Date: Fri, 15 Apr 2022 17:10:39 -0700	[thread overview]
Message-ID: <20220416001048.2218911-2-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20220416001048.2218911-1-eric.dumazet@gmail.com>

From: Eric Dumazet <edumazet@google.com>

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.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_input.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 1595b76ea2bea195b8896f4cd533beb14b56dd96..d4bc717791704795a9a159baf4ccd501a9471609 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -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;
 }
 
 /*
-- 
2.36.0.rc0.470.gd361397f0d-goog


  reply	other threads:[~2022-04-16  0:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  0:10 [PATCH net-next 00/10] tcp: drop reason additions Eric Dumazet
2022-04-16  0:10 ` Eric Dumazet [this message]
2022-04-16  0:10 ` [PATCH net-next 02/10] tcp: get rid of rst_seq_match Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 03/10] tcp: add drop reason support to tcp_validate_incoming() Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 04/10] tcp: make tcp_rcv_state_process() drop monitor friendly Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 05/10] tcp: add drop reasons to tcp_rcv_state_process() Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 06/10] tcp: add two drop reasons for tcp_ack() Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 07/10] tcp: add drop reason support to tcp_prune_ofo_queue() Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 08/10] tcp: make tcp_rcv_synsent_state_process() drop monitor friend Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 09/10] tcp: add drop reasons to tcp_rcv_synsent_state_process() Eric Dumazet
2022-04-16  0:10 ` [PATCH net-next 10/10] tcp: add drop reason support to tcp_ofo_queue() Eric Dumazet
2022-04-17 12:40 ` [PATCH net-next 00/10] tcp: drop reason additions patchwork-bot+netdevbpf

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=20220416001048.2218911-2-eric.dumazet@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.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).