git: d3b02115d4b3 - main - tcp: count only the SACK blocks that fit in tcp_maxseg()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Nov 2026 20:28:19 UTC
The branch main has been updated by nprice:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3b02115d4b373c719d9a716da38d94511de3f07
commit d3b02115d4b373c719d9a716da38d94511de3f07
Author: Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-11-13 20:27:46 +0000
Commit: Nick Price <nprice@FreeBSD.org>
CommitDate: 2026-11-13 20:27:49 +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
---
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 b62bc81ee4fe..aa933572b5f0 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -3797,9 +3797,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)