Patch "net: Replace the limit of TCP_LINGER2 with TCP_FIN_TIMEOUT_MAX" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: Replace the limit of TCP_LINGER2 with TCP_FIN_TIMEOUT_MAX

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-replace-the-limit-of-tcp_linger2-with-tcp_fin_ti.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b1ff776eeefc168d9e591f6d3c7d58f3c7ac80f8
Author: Cambda Zhu <cambda@xxxxxxxxxxxxxxxxx>
Date:   Fri Apr 24 16:06:16 2020 +0800

    net: Replace the limit of TCP_LINGER2 with TCP_FIN_TIMEOUT_MAX
    
    [ Upstream commit f0628c524fd188c3f9418e12478dfdfadacba815 ]
    
    This patch changes the behavior of TCP_LINGER2 about its limit. The
    sysctl_tcp_fin_timeout used to be the limit of TCP_LINGER2 but now it's
    only the default value. A new macro named TCP_FIN_TIMEOUT_MAX is added
    as the limit of TCP_LINGER2, which is 2 minutes.
    
    Since TCP_LINGER2 used sysctl_tcp_fin_timeout as the default value
    and the limit in the past, the system administrator cannot set the
    default value for most of sockets and let some sockets have a greater
    timeout. It might be a mistake that let the sysctl to be the limit of
    the TCP_LINGER2. Maybe we can add a new sysctl to set the max of
    TCP_LINGER2, but FIN-WAIT-2 timeout is usually no need to be too long
    and 2 minutes are legal considering TCP specs.
    
    Changes in v3:
    - Remove the new socket option and change the TCP_LINGER2 behavior so
      that the timeout can be set to value between sysctl_tcp_fin_timeout
      and 2 minutes.
    
    Changes in v2:
    - Add int overflow check for the new socket option.
    
    Changes in v1:
    - Add a new socket option to set timeout greater than
      sysctl_tcp_fin_timeout.
    
    Signed-off-by: Cambda Zhu <cambda@xxxxxxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Stable-dep-of: 9df5335ca974 ("tcp: annotate data-races around tp->linger2")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 81300a04b5808..22cca858f2678 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -128,6 +128,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
 				  * to combine FIN-WAIT-2 timeout with
 				  * TIME-WAIT timer.
 				  */
+#define TCP_FIN_TIMEOUT_MAX (120 * HZ) /* max TCP_LINGER2 value (two minutes) */
 
 #define TCP_DELACK_MAX	((unsigned)(HZ/5))	/* maximal time to delay before sending an ACK */
 #if HZ >= 100
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cb96775fc86f6..9f3cdcbbb7590 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3001,8 +3001,8 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 	case TCP_LINGER2:
 		if (val < 0)
 			tp->linger2 = -1;
-		else if (val > net->ipv4.sysctl_tcp_fin_timeout / HZ)
-			tp->linger2 = 0;
+		else if (val > TCP_FIN_TIMEOUT_MAX / HZ)
+			tp->linger2 = TCP_FIN_TIMEOUT_MAX;
 		else
 			tp->linger2 = val * HZ;
 		break;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux