The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c3fc0db3bc50df18a724e6e6b12ea4e060fd9255
commit c3fc0db3bc50df18a724e6e6b12ea4e060fd9255 Author: Michael Tuexen <tue...@freebsd.org> AuthorDate: 2025-06-27 20:47:21 +0000 Commit: Michael Tuexen <tue...@freebsd.org> CommitDate: 2025-06-27 20:47:21 +0000 tcp: set net.inet.tcp.nolocaltimewait to 0 and deprecate it Set the default value of the sysctl-variable net.inet.tcp.nolocaltimewait to 0. This will make the behavior compliant with RFC 9293. Furthermore document that using the sysctl-variable is deprecated and will be removed in FreeBSD 16. Reviewed by: glebius, Peter Lei Relnotes: yes Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D5106 --- share/man/man4/tcp.4 | 14 ++++++++++---- sys/netinet/tcp_timewait.c | 24 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index f19b6cb2ae14..fcfda42908d8 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 26, 2025 +.Dd June 27, 2025 .Dt TCP 4 .Os .Sh NAME @@ -785,8 +785,8 @@ The Maximum Segment Lifetime, in milliseconds, for a packet when both endpoints are local. .Va msl_local is only used if -.Va nolocaltimewait -is zero. +.Va nolocaltimewait , +which is deprecated, is zero. .It Va mssdflt The default value used for the TCP Maximum Segment Size .Pq Dq MSS @@ -798,10 +798,16 @@ application limited and the network bandwidth is not utilized completely. That prevents self-inflicted packet losses once the application starts to transmit data at a higher speed. .It Va nolocaltimewait -Suppress creation of TCP +Suppress the creation of TCP .Dv TIME_WAIT states for connections in which both endpoints are local. +The default is 0. +.Va nolocaltimewait +is deprecated and will be removed in +.Fx 16 . +.Va msl_local +can be used instead. .It Va path_mtu_discovery Enable Path MTU Discovery. .It Va pcbcount diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 08673ddd1152..7c6c55909215 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -87,10 +87,28 @@ #include <security/mac/mac_framework.h> -VNET_DEFINE_STATIC(bool, nolocaltimewait) = true; +VNET_DEFINE_STATIC(bool, nolocaltimewait) = false; #define V_nolocaltimewait VNET(nolocaltimewait) -SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, nolocaltimewait, - CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nolocaltimewait), 0, + +static int +sysctl_net_inet_tcp_nolocaltimewait(SYSCTL_HANDLER_ARGS) +{ + int error; + bool new; + + new = V_nolocaltimewait; + error = sysctl_handle_bool(oidp, &new, 0, req); + if (error == 0 && req->newptr) { + V_nolocaltimewait = new; + gone_in(16, "net.inet.tcp.nolocaltimewait is obsolete." + " Use net.inet.tcp.local_msl instead.\n"); + } + return (error); +} + +SYSCTL_PROC(_net_inet_tcp, OID_AUTO, nolocaltimewait, + CTLFLAG_VNET | CTLFLAG_RW | CTLTYPE_U8, + &VNET_NAME(nolocaltimewait), 0, sysctl_net_inet_tcp_nolocaltimewait, "CU", "Do not create TCP TIME_WAIT state for local connections"); static u_int