public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jason Xing <kerneljasonxing@gmail•com>
To: davem@davemloft•net, edumazet@google•com, kuba@kernel•org,
	pabeni@redhat•com, dsahern@kernel•org, kuniyu@amazon•com
Cc: netdev@vger•kernel.org, Jason Xing <kernelxing@tencent•com>
Subject: [PATCH net-next v3 1/7] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset
Date: Thu,  1 Aug 2024 22:54:38 +0800	[thread overview]
Message-ID: <20240801145444.22988-2-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20240801145444.22988-1-kerneljasonxing@gmail.com>

From: Jason Xing <kernelxing@tencent•com>

Introducing a new type TCP_ABORT_ON_CLOSE for tcp reset reason to handle
the case where more data is unread in closing phase.

Signed-off-by: Jason Xing <kernelxing@tencent•com>
Reviewed-by: Eric Dumazet <edumazet@google•com>
---
 include/net/rstreason.h | 6 ++++++
 net/ipv4/tcp.c          | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/net/rstreason.h b/include/net/rstreason.h
index 2575c85d7f7a..fa6bfd0d7d69 100644
--- a/include/net/rstreason.h
+++ b/include/net/rstreason.h
@@ -17,6 +17,7 @@
 	FN(TCP_ABORT_ON_DATA)		\
 	FN(TCP_TIMEWAIT_SOCKET)		\
 	FN(INVALID_SYN)			\
+	FN(TCP_ABORT_ON_CLOSE)		\
 	FN(MPTCP_RST_EUNSPEC)		\
 	FN(MPTCP_RST_EMPTCP)		\
 	FN(MPTCP_RST_ERESOURCE)		\
@@ -84,6 +85,11 @@ enum sk_rst_reason {
 	 * an error, send a reset"
 	 */
 	SK_RST_REASON_INVALID_SYN,
+	/**
+	 * @SK_RST_REASON_TCP_ABORT_ON_CLOSE: abort on close
+	 * corresponding to LINUX_MIB_TCPABORTONCLOSE
+	 */
+	SK_RST_REASON_TCP_ABORT_ON_CLOSE,
 
 	/* Copy from include/uapi/linux/mptcp.h.
 	 * These reset fields will not be changed since they adhere to
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e03a342c9162..2e010add0317 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2833,7 +2833,7 @@ void __tcp_close(struct sock *sk, long timeout)
 		NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE);
 		tcp_set_state(sk, TCP_CLOSE);
 		tcp_send_active_reset(sk, sk->sk_allocation,
-				      SK_RST_REASON_NOT_SPECIFIED);
+				      SK_RST_REASON_TCP_ABORT_ON_CLOSE);
 	} else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) {
 		/* Check zero linger _after_ checking for unread data. */
 		sk->sk_prot->disconnect(sk, 0);
-- 
2.37.3


  reply	other threads:[~2024-08-01 14:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01 14:54 [PATCH net-next v3 0/7] tcp: completely support active reset Jason Xing
2024-08-01 14:54 ` Jason Xing [this message]
2024-08-01 14:54 ` [PATCH net-next v3 2/7] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for " Jason Xing
2024-08-01 14:54 ` [PATCH net-next v3 3/7] tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY " Jason Xing
2024-08-01 14:54 ` [PATCH net-next v3 4/7] tcp: rstreason: introduce SK_RST_REASON_TCP_STATE " Jason Xing
2024-08-02  9:41   ` Eric Dumazet
2024-08-02  9:49     ` Jason Xing
2024-08-01 14:54 ` [PATCH net-next v3 5/7] tcp: rstreason: introduce SK_RST_REASON_TCP_KEEPALIVE_TIMEOUT " Jason Xing
2024-08-02  9:35   ` Eric Dumazet
2024-08-02  9:45     ` Jason Xing
2024-08-01 14:54 ` [PATCH net-next v3 6/7] tcp: rstreason: introduce SK_RST_REASON_TCP_DISCONNECT_WITH_DATA " Jason Xing
2024-08-02  9:32   ` Eric Dumazet
2024-08-01 14:54 ` [PATCH net-next v3 7/7] tcp: rstreason: let it work finally in tcp_send_active_reset() Jason Xing
2024-08-02  9:32   ` Eric Dumazet

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=20240801145444.22988-2-kerneljasonxing@gmail.com \
    --to=kerneljasonxing@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dsahern@kernel$(echo .)org \
    --cc=edumazet@google$(echo .)com \
    --cc=kernelxing@tencent$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=kuniyu@amazon$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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