All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: netdev@vger.kernel.org
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	Kuniyuki Iwashima <kuniyu@google.com>
Subject: [PATCH net v2] tcp: rstreason: introduce SK_RST_REASON_TCP_LISTEN_OVERFLOW
Date: Fri,  4 Dec 2026 18:44:35 +0800	[thread overview]
Message-ID: <20261204104437.47753-1-jiayuan.chen@linux.dev> (raw)

In tcp_check_req(), the RST sent when the child socket can not be
created (e.g. the accept queue is full) and the RST sent for a SYN in
window both use SK_RST_REASON_INVALID_SYN, so the tcp_send_reset
tracepoint can not tell them apart.

Add SK_RST_REASON_TCP_LISTEN_OVERFLOW for the former. It is only sent
when net.ipv4.tcp_abort_on_overflow is set.

Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
v1 -> v2 : resend after net tree is merged.
v1: https://lore.kernel.org/netdev/axFM0APnT45iKmR9@google.com/
---
 include/net/rstreason.h  | 7 +++++++
 net/ipv4/tcp_minisocks.c | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/net/rstreason.h b/include/net/rstreason.h
index 979ac87b5d994..39537af1d0524 100644
--- a/include/net/rstreason.h
+++ b/include/net/rstreason.h
@@ -23,6 +23,7 @@
 	FN(TCP_STATE)			\
 	FN(TCP_KEEPALIVE_TIMEOUT)	\
 	FN(TCP_DISCONNECT_WITH_DATA)	\
+	FN(TCP_LISTEN_OVERFLOW)		\
 	FN(MPTCP_RST_EUNSPEC)		\
 	FN(MPTCP_RST_EMPTCP)		\
 	FN(MPTCP_RST_ERESOURCE)		\
@@ -123,6 +124,12 @@ enum sk_rst_reason {
 	 * disconnecting, so we have to send an RST.
 	 */
 	SK_RST_REASON_TCP_DISCONNECT_WITH_DATA,
+	/**
+	 * @SK_RST_REASON_TCP_LISTEN_OVERFLOW: child socket could not be
+	 * created, e.g. accept queue is full. Only sent when
+	 * net.ipv4.tcp_abort_on_overflow is set.
+	 */
+	SK_RST_REASON_TCP_LISTEN_OVERFLOW,
 
 	/* Copy from include/uapi/linux/mptcp.h.
 	 * These reset fields will not be changed since they adhere to
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 934012cdac276..f15068b615f9a 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -689,6 +689,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
 			   bool fastopen, bool *req_stolen,
 			   enum skb_drop_reason *drop_reason)
 {
+	enum sk_rst_reason rst_reason = SK_RST_REASON_INVALID_SYN;
 	struct tcp_options_received tmp_opt;
 	struct sock *child;
 	const struct tcphdr *th = tcp_hdr(skb);
@@ -960,6 +961,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
 		inet_rsk(req)->acked = 1;
 		return NULL;
 	}
+	rst_reason = SK_RST_REASON_TCP_LISTEN_OVERFLOW;
 
 embryonic_reset:
 	if (!fastopen) {
@@ -975,7 +977,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
 		 * avoid becoming vulnerable to outside attack aiming at
 		 * resetting legit local connections.
 		 */
-		req->rsk_ops->send_reset(sk, skb, SK_RST_REASON_INVALID_SYN);
+		req->rsk_ops->send_reset(sk, skb, rst_reason);
 	} else if (fastopen) { /* received a valid RST pkt */
 		reqsk_fastopen_remove(sk, req, true);
 		tcp_reset(sk, skb);
-- 
2.43.0


             reply	other threads:[~2026-12-04 10:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 10:44 Jiayuan Chen [this message]
2026-12-05  2:29 ` [PATCH net v2] tcp: rstreason: introduce SK_RST_REASON_TCP_LISTEN_OVERFLOW 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=20261204104437.47753-1-jiayuan.chen@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.