]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset
authorJason Xing <kernelxing@tencent.com>
Fri, 2 Aug 2024 10:21:06 +0000 (18:21 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Aug 2024 09:24:45 +0000 (10:24 +0100)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/rstreason.h
net/ipv4/tcp.c

index 2575c85d7f7ab0168593d2e736a82f2001f394a4..fa6bfd0d7d69c7ddc4388353f9951283bea74518 100644 (file)
@@ -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
index e03a342c9162b65b49551ffdb6302519bc473441..2e010add0317da21b747be76fbf535293d821832 100644 (file)
@@ -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);