git: fcea1cc9711a - main - tcp: fix RTO ssthresh for non-6675 pipe calculation

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Wed, 14 Feb 2024 13:58:19 UTC
The branch main has been updated by rscheff:

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

commit fcea1cc9711aa774f6fac305418db4d42b64a5bd
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2024-02-14 13:51:39 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2024-02-14 13:51:53 +0000

    tcp: fix RTO ssthresh for non-6675 pipe calculation
    
    Follow up on D43768 to properly deal with the non-default
    pipe calculation. When CC_RTO is processed, the timeout
    will have already pulled back snd_nxt. Further, snd_fack
    is not pulled along with snd_una.
    
    Reviewed By:            tuexen, #transport
    Sponsored by:           NetApp, Inc.
    Differential Revision:  https://reviews.freebsd.org/D43876
---
 sys/netinet/cc/cc.c         | 2 +-
 sys/netinet/cc/cc_cubic.c   | 2 +-
 sys/netinet/cc/cc_dctcp.c   | 2 +-
 sys/netinet/cc/cc_htcp.c    | 2 +-
 sys/netinet/cc/cc_newreno.c | 2 +-
 sys/netinet/tcp_input.c     | 4 ++++
 6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/sys/netinet/cc/cc.c b/sys/netinet/cc/cc.c
index a3d19e31d438..c2965b1e6a48 100644
--- a/sys/netinet/cc/cc.c
+++ b/sys/netinet/cc/cc.c
@@ -492,7 +492,7 @@ newreno_cc_cong_signal(struct cc_var *ccv, uint32_t type)
 			if (V_tcp_do_newsack) {
 				pipe = tcp_compute_pipe(ccv->ccvc.tcp);
 			} else {
-				pipe = CCV(ccv, snd_nxt) -
+				pipe = CCV(ccv, snd_max) -
 					CCV(ccv, snd_fack) +
 					CCV(ccv, sackhint.sack_bytes_rexmit);
 			}
diff --git a/sys/netinet/cc/cc_cubic.c b/sys/netinet/cc/cc_cubic.c
index dcb096af6cbf..eb1587d44427 100644
--- a/sys/netinet/cc/cc_cubic.c
+++ b/sys/netinet/cc/cc_cubic.c
@@ -479,7 +479,7 @@ cubic_cong_signal(struct cc_var *ccv, uint32_t type)
 			if (V_tcp_do_newsack) {
 				pipe = tcp_compute_pipe(ccv->ccvc.tcp);
 			} else {
-				pipe = CCV(ccv, snd_nxt) -
+				pipe = CCV(ccv, snd_max) -
 					CCV(ccv, snd_fack) +
 					CCV(ccv, sackhint.sack_bytes_rexmit);
 			}
diff --git a/sys/netinet/cc/cc_dctcp.c b/sys/netinet/cc/cc_dctcp.c
index 41db7e0811aa..ae0a56839449 100644
--- a/sys/netinet/cc/cc_dctcp.c
+++ b/sys/netinet/cc/cc_dctcp.c
@@ -296,7 +296,7 @@ dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
 				if (V_tcp_do_newsack) {
 					pipe = tcp_compute_pipe(ccv->ccvc.tcp);
 				} else {
-					pipe = CCV(ccv, snd_nxt) -
+					pipe = CCV(ccv, snd_max) -
 						CCV(ccv, snd_fack) +
 						CCV(ccv, sackhint.sack_bytes_rexmit);
 				}
diff --git a/sys/netinet/cc/cc_htcp.c b/sys/netinet/cc/cc_htcp.c
index 7500446d3051..949715a69c67 100644
--- a/sys/netinet/cc/cc_htcp.c
+++ b/sys/netinet/cc/cc_htcp.c
@@ -327,7 +327,7 @@ htcp_cong_signal(struct cc_var *ccv, uint32_t type)
 			if (V_tcp_do_newsack) {
 				pipe = tcp_compute_pipe(ccv->ccvc.tcp);
 			} else {
-				pipe = CCV(ccv, snd_nxt) -
+				pipe = CCV(ccv, snd_max) -
 					CCV(ccv, snd_fack) +
 					CCV(ccv, sackhint.sack_bytes_rexmit);
 			}
diff --git a/sys/netinet/cc/cc_newreno.c b/sys/netinet/cc/cc_newreno.c
index 4f55fb7e0f7a..71f2764ef4bc 100644
--- a/sys/netinet/cc/cc_newreno.c
+++ b/sys/netinet/cc/cc_newreno.c
@@ -431,7 +431,7 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type)
 			if (V_tcp_do_newsack) {
 				pipe = tcp_compute_pipe(ccv->ccvc.tcp);
 			} else {
-				pipe = CCV(ccv, snd_nxt) -
+				pipe = CCV(ccv, snd_max) -
 					CCV(ccv, snd_fack) +
 					CCV(ccv, sackhint.sack_bytes_rexmit);
 			}
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index b3201750c1e6..f023d7477790 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -461,6 +461,10 @@ cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type)
 		tp->t_badrxtwin = 0;
 		break;
 	}
+	if (SEQ_LT(tp->snd_fack, tp->snd_una) ||
+	    SEQ_GT(tp->snd_fack, tp->snd_max)) {
+		tp->snd_fack = tp->snd_una;
+	}
 
 	if (CC_ALGO(tp)->cong_signal != NULL) {
 		if (th != NULL)