From nobody Mon May 18 14:55:18 2026 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 4gK17c32LHz6fTGB for ; Mon, 18 May 2026 14:55:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gK17c12YHz3XBB for ; Mon, 18 May 2026 14:55:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779116124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=67ynpaMnse+4MtesaNI1RhPUHmmQ1TlQLR+pxbxZ01M=; b=XT3Siv6hH2T0laooqAbk93fxL70+lT1nQHwJskivFnEx3UU98yTI6oFnk8PrwG1mzlTAjQ diZK4ElIBhe7EbnWN8atcuRszmSxX3i54aaHgRhQXhOi4GqQjGcmjBrndKVM03FnJXrkM8 anLeVYGI+LaBFonZPTRwJdh+ZhiszYO5PtW5EiQf19SAlQ1nr2bb55KyHiTJ6Ub5FZ6/dh pxCaXS04iqLygmczFE9DyOMRotXrxyFQRsYvNUj+Lz7svkRUWYk4kdCb2zEaXGPuCXz3ut Gg8rkIsJILmvpjF6iMdeMAbph7GmozVDtmHtHB0MeD0ULFZkb3pInRHdB195Fg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779116124; a=rsa-sha256; cv=none; b=pYyWxquMxBbNYm1O4lUJVbuCm784Z9yK7x13pIS7O16Zog5n2+0Ceu8vfrw8WoYpX4PLAF Udrf80qJNHivUPODqmEP8x9EPbN8B/2V8B32KWbq/1mTb5nd2fuFxnEWq6DSnHxMro7Klm vdIHIPqDeAGXujA8jrGN9Ha09cch/YslD5+XFkcxt9NFCVF7bXmzxwn/yJPnp4+aLlrZ1I aq/+2+A5OSjKv57SukvebbwZEFwm8fc8vY8QBhv0qxig821KkGvj/KB8GZj1Cp5jYBPnF4 tsEfb7GSAazJvFQ0bX3UbzVYy0eHt3j9h9rZlpKxbRLEdF0SDO7OoQOiXCnENQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779116124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=67ynpaMnse+4MtesaNI1RhPUHmmQ1TlQLR+pxbxZ01M=; b=gEq82oFhO8euaUpq8O6gYfYuCaUg2RXkkUYTVfj4OEOr53dfixTxxdwz4on0A1GpBZCqHR MJkvPWLwzO6wLsTLzv6jAvZnQ4yWPMc28IEDCQbNTV6pp8GBCQllEiBDPuCEZVxovRjlt3 VszBNWxBsKIl4GjUiIsUx9wfNvZgwHI61W7mq7a0NtyrCgGMWWDqXYOfG939NbO7rnFnSF +inKtBAKE9Yi3i0Hv/9IPAKk0NAJrnJwWLsMp5p5GOOTItQC7NNLu63VvBbhKZB/FWuPbN yjZvTfjd5KlGnBnywhqlmvduhtRPAAK1AeD+7G30mCr7nFtwmvqbTlmcMHvizA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gK17c0PlxzYky for ; Mon, 18 May 2026 14:55:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cf65 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 18 May 2026 14:55:18 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 2af70d7a3849 - main - tcp: Make RFC 6191 support configurable 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2af70d7a384934cee497fb6d75678e04f1416287 Auto-Submitted: auto-generated Date: Mon, 18 May 2026 14:55:18 +0000 Message-Id: <6a0b2856.3cf65.c81425b@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=2af70d7a384934cee497fb6d75678e04f1416287 commit 2af70d7a384934cee497fb6d75678e04f1416287 Author: Dag-Erling Smørgrav AuthorDate: 2026-05-18 14:50:14 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-05-18 14:50:14 +0000 tcp: Make RFC 6191 support configurable Add a default-on per-VIMAGE sysctl for RFC 6191 connection recycling. This makes it possible to merge the change to older branches where it can be switched off by default to minimize risk. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Modirum MDPay Reviewed by: pouria, marius.h_lden.org, tuexen Differential Revision: https://reviews.freebsd.org/D57045 --- share/man/man4/tcp.4 | 11 ++++++++- sys/netinet/tcp_timewait.c | 58 +++++++++++++++++++++++++++++----------------- sys/netinet/tcp_var.h | 2 ++ 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index 4c01daf4e14e..8bc1eb858a07 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 May 7, 2026 +.Dd May 17, 2026 .Dt TCP 4 .Os .Sh NAME @@ -940,6 +940,10 @@ maximum segment size. This helps throughput in general, but particularly affects short transfers and high-bandwidth large propagation-delay connections. +.It Va rfc6191 +Enable RFC 6191 connection recycling, which allows faster connection +recycling in certain circumstances when the new connection has TCP +timestamps enabled. .It Va sack.enable Enable support for RFC 2018, TCP Selective Acknowledgment option, which allows the receiver to inform the sender about all successfully @@ -1145,6 +1149,11 @@ when trying to use a TCP function block that is not available; .%T "Improving TCP's Robustness to Blind In-Window Attacks" .%O "RFC 5961" .Re +.Rs +.%A "F. Gont" +.%T "Reducing the TIME-WAIT State Using TCP Timestamps" +.%O "RFC 6191" +.Re .Sh HISTORY The .Tn TCP diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 4f4ca445fa46..276733066c30 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -91,6 +91,11 @@ #include +VNET_DEFINE(int, tcp_do_rfc6191) = 1; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(tcp_do_rfc6191), 0, + "Enable RFC 6191 (Reduced TIME-WAIT State)"); + static u_int tcp_eff_msl(struct tcpcb *tp) { @@ -223,29 +228,40 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, } /* - * If a new connection request is received - * while in TIME_WAIT, drop the old connection - * and start over if allowed by RFC 6191. + * If a new connection request is received while in TIME_WAIT, + * drop the old connection and start over if appropriate. + * + * The original rule is to start over if and only if the sequence + * number of the new connection is greater than the last sequence + * number seen on the old connection. + * + * Additionally, RFC 6191 allows restarting if the new connection + * has TCP timestamps enabled and either the old one didn't, or it + * did but the timestamp on the incoming SYN is greater than the + * last timestamp seen on the old connection. + * * Allow UDP port number changes in this case. */ - if (((thflags & (TH_SYN | TH_ACK)) == TH_SYN) && - ((((tp->t_flags & TF_RCVD_TSTMP) != 0) && - ((to->to_flags & TOF_TS) != 0) && - TSTMP_LT(tp->ts_recent, to->to_tsval)) || - (((tp->t_flags & TF_RCVD_TSTMP) == 0) && - ((to->to_flags & TOF_TS) != 0) && - (V_tcp_tolerate_missing_ts == 0)) || - SEQ_GT(th->th_seq, tp->rcv_nxt))) { - /* - * In case we can't upgrade our lock just pretend we have - * lost this packet. - */ - if (INP_TRY_UPGRADE(inp) == 0) - goto drop; - if ((tp = tcp_close(tp)) != NULL) - INP_WUNLOCK(inp); - TCPSTAT_INC(tcps_tw_recycles); - return (true); + if ((thflags & (TH_SYN | TH_ACK)) == TH_SYN) { + bool rfc6191 = false; + + if ((to->to_flags & TOF_TS) != 0 && V_tcp_do_rfc6191) { + rfc6191 = (tp->t_flags & TF_RCVD_TSTMP) != 0 ? + TSTMP_LT(tp->ts_recent, to->to_tsval) : + V_tcp_tolerate_missing_ts == 0; + } + if (rfc6191 || SEQ_GT(th->th_seq, tp->rcv_nxt)) { + /* + * In case we can't upgrade our lock just pretend + * we have lost this packet. + */ + if (INP_TRY_UPGRADE(inp) == 0) + goto drop; + if ((tp = tcp_close(tp)) != NULL) + INP_WUNLOCK(inp); + TCPSTAT_INC(tcps_tw_recycles); + return (true); + } } /* diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index a1b0519ceac3..5b3733e8e91e 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1308,6 +1308,7 @@ VNET_DECLARE(int, tcp_tolerate_missing_ts); VNET_DECLARE(int, tcp_do_rfc3042); VNET_DECLARE(int, tcp_do_rfc3390); VNET_DECLARE(int, tcp_do_rfc3465); +VNET_DECLARE(int, tcp_do_rfc6191); VNET_DECLARE(int, tcp_do_sack); VNET_DECLARE(int, tcp_do_tso); VNET_DECLARE(int, tcp_ecn_maxretries); @@ -1358,6 +1359,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo); #define V_tcp_do_rfc3042 VNET(tcp_do_rfc3042) #define V_tcp_do_rfc3390 VNET(tcp_do_rfc3390) #define V_tcp_do_rfc3465 VNET(tcp_do_rfc3465) +#define V_tcp_do_rfc6191 VNET(tcp_do_rfc6191) #define V_tcp_do_sack VNET(tcp_do_sack) #define V_tcp_do_tso VNET(tcp_do_tso) #define V_tcp_ecn_maxretries VNET(tcp_ecn_maxretries)