git: b35cfae75b60 - stable/14 - tcp: improve sender side SWS avoidance

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

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

commit b35cfae75b60543799d83494cf1ccdc37a8bf851
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-11-16 17:25:32 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-24 19:12:43 +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 6da1dbd1ea24..a9fa3490d308 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -598,19 +598,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