git: aacae7b35a22 - stable/15 - tcp: count only the SACK blocks that fit in tcp_maxseg()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 19:57:04 UTC
The branch stable/15 has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=aacae7b35a22a56e187a0a41db231d63ca9cefb6
commit aacae7b35a22a56e187a0a41db231d63ca9cefb6
Author: Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-11-13 20:27:46 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-26 19:55:44 +0000
tcp: count only the SACK blocks that fit in tcp_maxseg()
tcp_addoptions() sends only the SACK blocks that fit in TCP_MAXOLEN.
tcp_maxseg() counted every pending block and clamped the total, so
without timestamps and with five or more blocks pending it came out 4
bytes below the segment tcp_output() sends. Limited transmit after an
RTO then sent one full segment and failed the "sent too much" KASSERT.
PR: 282605
Approved by: adrian (mentor)
Signed-off-by: Nick Price <nprice@FreeBSD.org>
Reviewed by: tuexen, glebius, adrian
Differential Revision: https://reviews.freebsd.org/D60460
(cherry picked from commit d3b02115d4b373c719d9a716da38d94511de3f07)
---
sys/netinet/tcp_subr.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 533f19699074..b787f9b527ba 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -3789,9 +3789,12 @@ tcp_maxseg(const struct tcpcb *tp)
optlen += PADTCPOLEN(TCPOLEN_SIGNATURE);
#endif
if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) {
- optlen += TCPOLEN_SACKHDR;
- optlen += tp->rcv_numsacks * TCPOLEN_SACK;
- optlen = PADTCPOLEN(optlen);
+ u_int sackblks;
+
+ sackblks = min(tp->rcv_numsacks, (TCP_MAXOLEN - optlen -
+ PADTCPOLEN(TCPOLEN_SACKHDR)) / TCPOLEN_SACK);
+ optlen += PADTCPOLEN(TCPOLEN_SACKHDR +
+ sackblks * TCPOLEN_SACK);
}
} else {
if (tp->t_flags & TF_REQ_TSTMP)