tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for active reset
authorJason Xing <kernelxing@tencent.com>
Fri, 2 Aug 2024 10:21:07 +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_LINGER for tcp reset reason to handle
negative linger value case.

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 fa6bfd0d7d69c7ddc4388353f9951283bea74518..fbbaeb969e6aa9ecef1c307efd13a559a4623cac 100644 (file)
@@ -18,6 +18,7 @@
        FN(TCP_TIMEWAIT_SOCKET)         \
        FN(INVALID_SYN)                 \
        FN(TCP_ABORT_ON_CLOSE)          \
+       FN(TCP_ABORT_ON_LINGER)         \
        FN(MPTCP_RST_EUNSPEC)           \
        FN(MPTCP_RST_EMPTCP)            \
        FN(MPTCP_RST_ERESOURCE)         \
@@ -90,6 +91,11 @@ enum sk_rst_reason {
         * corresponding to LINUX_MIB_TCPABORTONCLOSE
         */
        SK_RST_REASON_TCP_ABORT_ON_CLOSE,
+       /**
+        * @SK_RST_REASON_TCP_ABORT_ON_LINGER: abort on linger
+        * corresponding to LINUX_MIB_TCPABORTONLINGER
+        */
+       SK_RST_REASON_TCP_ABORT_ON_LINGER,
 
        /* Copy from include/uapi/linux/mptcp.h.
         * These reset fields will not be changed since they adhere to
index 2e010add0317da21b747be76fbf535293d821832..5b0f1d1fc69784ead5d1dca6709508ca180b1cac 100644 (file)
@@ -2908,7 +2908,7 @@ adjudge_to_death:
                if (READ_ONCE(tp->linger2) < 0) {
                        tcp_set_state(sk, TCP_CLOSE);
                        tcp_send_active_reset(sk, GFP_ATOMIC,
-                                             SK_RST_REASON_NOT_SPECIFIED);
+                                             SK_RST_REASON_TCP_ABORT_ON_LINGER);
                        __NET_INC_STATS(sock_net(sk),
                                        LINUX_MIB_TCPABORTONLINGER);
                } else {