git: d174085f9f89 - main - tcp: improve sender side SWS avoidance

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Mon, 16 Nov 2026 17:29:40 UTC
The branch main has been updated by tuexen:

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

commit d174085f9f895ed444bd95120da3eff481a58f1a
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-11-16 17:25:32 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-16 17:25:32 +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
    MFC after:              3 days
    MFC to:                 stable/15
    MFC to:                 stable/14
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D61605
---
 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 2ed2a7319aba..b37edfa35248 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