From nobody Fri Jun 27 21:19:14 2025 X-Original-To: dev-commits-src-main@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 4bTT2Z0HQLz60GmS; Fri, 27 Jun 2025 21:19:18 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 4bTT2Y4Kljz3Jv2; Fri, 27 Jun 2025 21:19:17 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751059157; 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=mpRvMsxE+qvVmOf1qVcYitS2oMEY1cngi8YXuUlQoS0=; b=D86JcRjPNjYkYqGosW+DwETsaMSsrlCqoipZ1FVCYyq7JBli2PJ3e0QRNksW7tx1ZdlLkp 8MfRILALKleAfjoRMGZcTdWLdgvsjy8/nyl0vAsqjispqlUeB9ELWIv4XVnWna/ik9w1Bn auOtljTdhHOk/r9aqWSlkiwQBFZ3cfFnXXzXR9Kxv+m57uY/CSXS5IqM217hUM88Y2sENB epNFZqMWHd/H7W/2IwPh/4St7+FcvRhJIo+DBScxOLq3o9L7H5l1xtzts7CRDUAByy/SQt zPhGlrnY0L81ZfVPRklBux0pkgyUnrvU4zVQnQE+By85bHQbtfOwyXDC0Dw9zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751059157; 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=mpRvMsxE+qvVmOf1qVcYitS2oMEY1cngi8YXuUlQoS0=; b=WW4v6SiSWstK16s269tfRJV92La/a7GqiMEhEgYtGjl+NUx8GJQKgksdzukiIlQVA86EPu PUlLKvNwj+UndjoahZI0ZnMdD8dwANE5OcBIUYMqz/tN055p/9Q42XYW+UPiXKmc75IS30 5YhluHvgIwfOsv6Z9c8xNBUgi4G9pQgUYeYioBXCjprcll0DaX+xZEAhgY6pcutsIn1i1g hnmPmm5DYB0fJH9G98+0OKonNi5zDLph6Ji3j/RvqqcZFu7oeu4nY7pv7WPhSI4mfqa7jb ZdiQ1I6n5UA5YCBd7FOVAPTsDaA2KmvyRb+NolR6NtfrAOygiGJks6DUToEr2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751059157; a=rsa-sha256; cv=none; b=Kgi9wre9KKvp5j3sR/9VC80E77yR2M09HDy0tO7+7XXLA1QlhgnhTKuYi35cVMz6u4Wf9z AjUTPGAPvirGmcAhqGHMYquUoWTplJXCZjrmyKUaDY6K8Gtt6CG4fI49y7eZBH/b8ABNoX w5OZdLW9M3UfH2r0EclfxZGs5g8uqLmRsUVXuagy1JaTsi44gkmzHihkOg5TaZo8/nhq1u +I/4z9u3Fg1dVI3VISz63EgM4hni4LVP+C1ieBLjTdDTn88oeVuMTsfjH70YQ5MU7e18S7 hwzKbsH+YqmEoeJTjrCtz0QG7xqg+DcoesSdL+H725C1WBJr5ihTrU+QYd3sEQ== Received: from smtpclient.apple (unknown [IPv6:2a02:8109:1101:be00:519:b945:b630:ea4d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: tuexen) by smtp.freebsd.org (Postfix) with ESMTPSA id 4bTT2X4VD9zFkp; Fri, 27 Jun 2025 21:19:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Content-Type: text/plain; charset=utf-8 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: git: 5fb4b091e835 - main - tcp: allow specifying a MSL for local communications From: Michael Tuexen In-Reply-To: <8EF254D7-A8D7-4031-BAC0-FDC36DE22754@FreeBSD.org> Date: Fri, 27 Jun 2025 23:19:14 +0200 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <202506261703.55QH3fqK060218@gitrepo.freebsd.org> <8EF254D7-A8D7-4031-BAC0-FDC36DE22754@FreeBSD.org> To: Kristof Provost X-Mailer: Apple Mail (2.3826.600.51.1.1) > On 27. Jun 2025, at 16:17, Kristof Provost wrote: >=20 > On 26 Jun 2025, at 19:03, Michael Tuexen wrote: >> The branch main has been updated by tuexen: >>=20 >> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D5fb4b091e8352602894fc2b7284c8e1e= 3d8a8729 >>=20 >> commit 5fb4b091e8352602894fc2b7284c8e1e3d8a8729 >> Author: Michael Tuexen >> AuthorDate: 2025-06-26 16:59:36 +0000 >> Commit: Michael Tuexen >> CommitDate: 2025-06-26 16:59:36 +0000 >>=20 >> tcp: allow specifying a MSL for local communications >>=20 >> When setting the sysctl-variable net.inet.tcp.nolocaltimewait to = 1, >> which is the default, a TCP endpoint does not enter the TIME-WAIT = state, >> 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-variable >> 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. >>=20 >> 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(-) >>=20 >> 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); >>=20 >> 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"); >>=20 >> +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 | = CTLFLAG_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) >>=20 >> #endif /* _KERNEL */ >>=20 >> 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"); >>=20 >> +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 = becomes tcp_msl then, and a function and a variable with the same name = confuses the poor compiler. >=20 > LINT-NOVIMAGE: >=20 > --- tcp_timewait.o --- > /usr/src/sys/netinet/tcp_timewait.c:97:1: error: redefinition of = 'tcp_msl' as different kind of symbol > 97 | tcp_msl(struct tcpcb *tp) > | ^ > /usr/src/sys/netinet/tcp_timer.h:185:19: note: previous definition is = here > 185 | VNET_DECLARE(int, tcp_msl); > | ^ > /usr/src/sys/netinet/tcp_timewait.c:165:45: error: called object type = 'int' 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 = 'int' is not a function or function pointer > 308 | tcp_timer_activate(tp, TT_2MSL, 2 * = tcp_msl(tp)); > | = ~~~~~~~^ > 3 errors generated. Hi Kristof, thank you very much for reporting the issue. It should be fixed by: = https://cgit.FreeBSD.org/src/commit/?id=3Dea6376adc8b969936259537ed8942131= 62b376e8 = Sorry for the breakage. Best regards Michael >=20 > =E2=80=94 > Kristof