git: 13357c1ee34f - stable/15 - tcp: improve sender side SWS avoidance

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Tue, 24 Nov 2026 10:46:13 UTC
The branch stable/15 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=13357c1ee34f9f8655375714c60da8bf4881493a

commit 13357c1ee34f9f8655375714c60da8bf4881493a
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-11-16 17:25:32 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-24 09:57:01 +0000

    tcp: improve sender side SWS avoidance
    
    When checking for a full sized segment, take all TCP options that will
    be included into account. This fixes a bug which can trigger the
    "sent too much" KASSERT related to limited transmit.
    
    Reported by:            olivier
    Reviewed by:            rscheff, Peter Lei
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D61605
    
    (cherry picked from commit d174085f9f895ed444bd95120da3eff481a58f1a)
---
 sys/netinet/tcp_output.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 55a8090cf7e2..fee4aa38f48f 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -587,19 +587,7 @@ after_sack_rexmit:
 	if (len) {
 		if (len >= tp->t_maxseg)
 			goto send;
-		/*
-		 * As the TCP header options are now
-		 * considered when setting up the initial
-		 * window, we would not send the last segment
-		 * if we skip considering the option length here.
-		 * Note: this may not work when tcp headers change
-		 * very dynamically in the future.
-		 */
-		if ((((tp->t_flags & TF_SIGNATURE) ?
-			PADTCPOLEN(TCPOLEN_SIGNATURE) : 0) +
-		    ((tp->t_flags & TF_RCVD_TSTMP) ?
-			PADTCPOLEN(TCPOLEN_TIMESTAMP) : 0) +
-		    len) >= tp->t_maxseg)
+		if (len >= tcp_maxseg(tp))
 			goto send;
 		/*
 		 * NOTE! on localhost connections an 'ack' from the remote