From nobody Fri Jun 27 14:17:18 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bTHgl4v1vz5yr1b; Fri, 27 Jun 2025 14:17:23 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bTHgl37sgz3D92; Fri, 27 Jun 2025 14:17:23 +0000 (UTC) (envelope-from kp@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751033843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=shlFAa+hvPEt+cXOONdVx4TeeOn5fDh/PAcEt0y253E=; b=fEUBE2lROx50dYm+Y9hA+prMqPRpIfe8oe9dnaUq7lr0AdYceTUQhe2oiMcPDIei3nfS45 2KzNHkezJpvqQSTvfqHZKLMEYRXTps0cMzUaWRno66v0WRPs6+mYAAXxdjsloMnfiHXhh8 BcQGj5h8plIAgnxc8WBSf+3sM/T+3/Rm2ob5/EgYAuLW9sQnkNQsBy/QjzEqF9gNxSoCqU 7nrTeLidU+KW1JOs+CkQrZoiNDXoiT2HkvCkT0vB/8U6tToThH3+fLYBPh9S+QNgGJ9Kw/ VFn4MZ9DsAhu5TcRU2Fsz2mT3KOl+w0oXqJvMpleJmSYXL+xCbrh/4KtQLwBLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751033843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=shlFAa+hvPEt+cXOONdVx4TeeOn5fDh/PAcEt0y253E=; b=o4z3zvS1KbDv19d8qiV3VmZg442gyKw501csf7xCDjBaZ4DXaHvAj3IMWcbZ9qU3a+bBLU j22MabubaWYtZBq8ox8TEwvenW6cFtMcWw2FbfTJCLUmwCI00t3Le05Pr48i7X1MM36iTJ eQsPJ1fAlkQn9XR5kAwQfQAkgKgMzt50gHS3E8oeFS4Glow6HBUsHgJwUxKvkTjVvYkZsO GV8h/RwaNFZAJMLI2VscbRJj72rXbn0xrfUMv6myHthskfdnYP2pkzNZ7p0zLmPPHT87ET 7+Zn7s+SAFfXrblrKDiRLasZ6EBgjTg88vuGaBhrpFcMuvuUgUN6JR8SjG0Xqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751033843; a=rsa-sha256; cv=none; b=Jg3/aiiBBUjJAURIq9b125jlydQmsAjhWoXo3lCSzRmbWjv55NJjc/9sQw9tPmaYcl0Qpw iJOl1f8WqT+zlOcj3/siGtX9GP7JIQTez8xkkSzapt0TonrK4PdJtwA1vWPCL6H4hqzAXT 9kZ7djNJ+H+H/3+doIJMie5Bfyowe8ypVwbGeKc8HChctpqxo+/CGTz/lCKkA01xO2BSka O0aQCP0nhOu/4cQdSwC1VbCvJW/U2p5SrA/gJyypiP6HpT6r28/G5fQxsH9MpvdvefkWsN PvjkRx8Z8KOov2YoYenQw5thDsJwOMx/Wv6wxBAsaLO30BhqDdjBODwClBuWrw== Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx1.codepro.be", Issuer "R10" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 4bTHgl153Gz5MM; Fri, 27 Jun 2025 14:17:23 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id ECF03798A; Fri, 27 Jun 2025 16:17:20 +0200 (CEST) From: Kristof Provost To: Michael Tuexen Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 5fb4b091e835 - main - tcp: allow specifying a MSL for local communications Date: Fri, 27 Jun 2025 16:17:18 +0200 X-Mailer: MailMate (2.0r6255) Message-ID: <8EF254D7-A8D7-4031-BAC0-FDC36DE22754@FreeBSD.org> In-Reply-To: <202506261703.55QH3fqK060218@gitrepo.freebsd.org> References: <202506261703.55QH3fqK060218@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 26 Jun 2025, at 19:03, Michael Tuexen wrote: > The branch main has been updated by tuexen: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D5fb4b091e8352602894fc2b7= 284c8e1e3d8a8729 > > commit 5fb4b091e8352602894fc2b7284c8e1e3d8a8729 > Author: Michael Tuexen > AuthorDate: 2025-06-26 16:59:36 +0000 > Commit: Michael Tuexen > CommitDate: 2025-06-26 16:59:36 +0000 > > tcp: allow specifying a MSL for local communications > > When setting the sysctl-variable net.inet.tcp.nolocaltimewait to 1,= > which is the default, a TCP endpoint does not enter the TIME-WAIT s= tate, > when the communication is local. This can result in sending > RST-segments without any error situation. By setting the > sysctl-variable net.inet.tcp.nolocaltimewait to 0, this does not > occur, and the behavior is compliant with the TCP specification. > But there is no reason to stay in the TIME-WAIT state for two times= > the value of the sysctl-variable net.inet.tcp.msl, if the > communication is local. Therefore provide a separate sysctl-variabl= e > net.inet.tcp.msl_local, which controls how long an TCP end-point > stays in the TIME-WAIT state, if the communication is local. > The default value is 10 ms. > > Reviewed by: glebius, Peter Lei > Sponsored by: Netflix, Inc. > Differential Revision: https://reviews.freebsd.org/D50637 > --- > share/man/man4/tcp.4 | 7 +++++++ > sys/netinet/tcp_subr.c | 1 + > sys/netinet/tcp_timer.c | 6 ++++++ > sys/netinet/tcp_timer.h | 3 +++ > sys/netinet/tcp_timewait.c | 26 ++++++++++++++++++++++++-- > 5 files changed, 41 insertions(+), 2 deletions(-) > > diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 > index 536bd904d796..f19b6cb2ae14 100644 > --- a/share/man/man4/tcp.4 > +++ b/share/man/man4/tcp.4 > @@ -780,6 +780,13 @@ Minimum TCP Maximum Segment Size; used to prevent = a denial of service attack > from an unreasonably low MSS. > .It Va msl > The Maximum Segment Lifetime, in milliseconds, for a packet. > +.It Va msl_local > +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. > .It Va mssdflt > The default value used for the TCP Maximum Segment Size > .Pq Dq MSS > diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c > index 6b1907305fb9..bbcd20b715ba 100644 > --- a/sys/netinet/tcp_subr.c > +++ b/sys/netinet/tcp_subr.c > @@ -1455,6 +1455,7 @@ tcp_vnet_init(void *arg __unused) > VNET_PCPUSTAT_ALLOC(tcpstat, M_WAITOK); > > V_tcp_msl =3D TCPTV_MSL; > + V_tcp_msl_local =3D TCPTV_MSL_LOCAL; > arc4rand(&V_ts_offset_secret, sizeof(V_ts_offset_secret), 0); > } > VNET_SYSINIT(tcp_vnet_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, > diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c > index a9046e5725d5..32ce3001929c 100644 > --- a/sys/netinet/tcp_timer.c > +++ b/sys/netinet/tcp_timer.c > @@ -109,6 +109,12 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, msl, > &VNET_NAME(tcp_msl), 0, sysctl_msec_to_ticks, "I", > "Maximum segment lifetime"); > > +VNET_DEFINE(int, tcp_msl_local); > +SYSCTL_PROC(_net_inet_tcp, OID_AUTO, msl_local, > + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_VNET, > + &VNET_NAME(tcp_msl_local), 0, sysctl_msec_to_ticks, "I", > + "Maximum segment lifetime for local communication"); > + > int tcp_rexmit_initial; > SYSCTL_PROC(_net_inet_tcp, OID_AUTO, rexmit_initial, CTLTYPE_INT | CTL= FLAG_RW, > &tcp_rexmit_initial, 0, sysctl_msec_to_ticks, "I", > diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h > index 394207bcb89b..34a0f1375463 100644 > --- a/sys/netinet/tcp_timer.h > +++ b/sys/netinet/tcp_timer.h > @@ -74,6 +74,7 @@ > * Time constants. > */ > #define TCPTV_MSL MSEC_2_TICKS(30000) /* max seg lifetime (hah!) */ > +#define TCPTV_MSL_LOCAL MSEC_2_TICKS(10) /* max seg lifetime for local= comm */ > #define TCPTV_SRTTBASE 0 /* base roundtrip time; > if 0, no idea yet */ > #define TCPTV_RTOBASE MSEC_2_TICKS(1000) /* assumed RTO if no info */ > @@ -183,6 +184,8 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss); > #define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss) > VNET_DECLARE(int, tcp_msl); > #define V_tcp_msl VNET(tcp_msl) > +VNET_DECLARE(int, tcp_msl_local); > +#define V_tcp_msl_local VNET(tcp_msl_local) > > #endif /* _KERNEL */ > > diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c > index 2b4ae462af89..9f2943725ef0 100644 > --- a/sys/netinet/tcp_timewait.c > +++ b/sys/netinet/tcp_timewait.c > @@ -93,6 +93,28 @@ SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, nolocaltimewait= , > CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nolocaltimewait), true, > "Do not create TCP TIME_WAIT state for local connections"); > > +static u_int > +tcp_msl(struct tcpcb *tp) > +{ > + struct inpcb *inp =3D tptoinpcb(tp); > +#ifdef INET6 > + bool isipv6 =3D inp->inp_inc.inc_flags & INC_ISIPV6; > +#endif > + > + if ( > +#ifdef INET6 > + isipv6 ? in6_localip(&inp->in6p_faddr) : > +#endif > +#ifdef INET > + in_localip(inp->inp_faddr)) > +#else > + false) > +#endif > + return (V_tcp_msl_local); > + else > + return (V_tcp_msl); > +} > + This seems to make !VIMAGE builds unhappy, probably because V_tcp_msl bec= omes tcp_msl then, and a function and a variable with the same name confu= ses the poor compiler. LINT-NOVIMAGE: --- tcp_timewait.o --- /usr/src/sys/netinet/tcp_timewait.c:97:1: error: redefinition of 'tcp_ms= l' as different kind of symbol 97 | tcp_msl(struct tcpcb *tp) | ^ /usr/src/sys/netinet/tcp_timer.h:185:19: note: previous definition is he= re 185 | VNET_DECLARE(int, tcp_msl); | ^ /usr/src/sys/netinet/tcp_timewait.c:165:45: error: called object type 'i= nt' is not a function or function pointer 165 | tcp_timer_activate(tp, TT_2MSL, 2 * tcp_msl(tp)); | ~~~~~~~^ /usr/src/sys/netinet/tcp_timewait.c:308:47: error: called object type 'i= nt' is not a function or function pointer 308 | tcp_timer_activate(tp, TT_2MSL, 2 * tcp_= msl(tp)); | ~~~~= ~~~^ 3 errors generated. =E2=80=94 Kristof