git: 8f5a2e216f4c - main - tcp: fix cwnd recalculation during limited transmit

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Thu, 14 Nov 2024 17:59:42 UTC
The branch main has been updated by rscheff:

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

commit 8f5a2e216f4cb955150c8f88ab21eaecc5adc8b9
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2024-11-14 08:19:34 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2024-11-14 08:19:49 +0000

    tcp: fix cwnd recalculation during limited transmit
    
    Properly calculate the expected flight size (cwnd) during
    limited transmit. Exclude the SACK scoreboard from
    consideration when still in limited transmit.
    
    PR: 282605
    Reviewed By: tuexen, #transport
    Sponsored by: NetApp, Inc.
    Differential Revision: https://reviews.freebsd.org/D47541
---
 sys/netinet/tcp_input.c  | 2 +-
 sys/netinet/tcp_output.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 3dfdb13994a5..7ef480d949e4 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -2813,7 +2813,7 @@ enter_recovery:
 							tcp_sack_adjust(tp);
 					tp->snd_cwnd +=
 					    (tp->t_dupacks - tp->snd_limited) *
-					    maxseg;
+					    maxseg - tcp_sack_adjust(tp);
 					/*
 					 * Only call tcp_output when there
 					 * is new data available to be sent
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 38ce2e3f3145..854cce2a0cc1 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -292,7 +292,8 @@ again:
 	len = 0;
 	p = NULL;
 	if ((tp->t_flags & TF_SACK_PERMIT) &&
-	    (IN_FASTRECOVERY(tp->t_flags) || SEQ_LT(tp->snd_nxt, tp->snd_max)) &&
+	    (IN_FASTRECOVERY(tp->t_flags) ||
+	     (SEQ_LT(tp->snd_nxt, tp->snd_max) && (tp->t_dupacks >= tcprexmtthresh))) &&
 	    (p = tcp_sack_output(tp, &sack_bytes_rxmt))) {
 		int32_t cwin;