git: dae632dfe305 - stable/14 - tcp: improve ISS checking for ghost ACKs

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 08:25:24 UTC
The branch stable/14 has been updated by tuexen:

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

commit dae632dfe30569a4d4a05430c565263ad4bbac3e
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-11-24 13:45:27 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-11-26 07:23:38 +0000

    tcp: improve ISS checking for ghost ACKs
    
    The check in tcp_adapt_iss_check() depends on SND.UNA and therefore
    should be performed whenever SND.UNA is incremented.
    
    PR:                     298560
    Reviewed by:            Peter Lei
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D61749
    
    (cherry picked from commit 9e345ca583f702e7472f836136e766d3346c049d)
---
 sys/netinet/tcp_input.c       | 3 ++-
 sys/netinet/tcp_stacks/bbr.c  | 3 ++-
 sys/netinet/tcp_stacks/rack.c | 5 ++++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 69dda0f99961..65b4953625f1 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1908,6 +1908,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th,
 				cc_ack_received(tp, th, nsegs, CC_ACK);
 
 				tp->snd_una = th->th_ack;
+				tcp_adapt_iss_check(tp);
 				/*
 				 * Pull snd_wl2 up to prevent seq wrap relative
 				 * to th_ack.
@@ -2488,7 +2489,6 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th,
 	/*
 	 * Ack processing.
 	 */
-	tcp_adapt_iss_check(tp);
 	if (!V_tcp_insecure_ack) {
 		tcp_seq seq_min;
 		bool ghost_ack_check;
@@ -3091,6 +3091,7 @@ process_ACK:
 		    SEQ_LEQ(th->th_ack, tp->snd_recover))
 			tp->snd_recover = th->th_ack - 1;
 		tp->snd_una = th->th_ack;
+		tcp_adapt_iss_check(tp);
 		if (IN_RECOVERY(tp->t_flags) &&
 		    SEQ_GEQ(th->th_ack, tp->snd_recover)) {
 			cc_post_recovery(tp, th);
diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
index 5346a4869bad..c93464c9d619 100644
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -7677,7 +7677,6 @@ bbr_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 	bbr = (struct tcp_bbr *)tp->t_fb_ptr;
 	lost = bbr->r_ctl.rc_lost;
 	nsegs = max(1, m->m_pkthdr.lro_nsegs);
-	tcp_adapt_iss_check(tp);
 	if (!V_tcp_insecure_ack) {
 		tcp_seq seq_min;
 		bool ghost_ack_check;
@@ -7797,6 +7796,7 @@ bbr_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 		bbr_collapse_rtt(tp, bbr, TCP_REXMTVAL(tp));
 	}
 	tp->snd_una = th->th_ack;
+	tcp_adapt_iss_check(tp);
 	bbr_ack_received(tp, bbr, th, acked, sack_changed, prev_acked, __LINE__, (bbr->r_ctl.rc_lost - lost));
 	if (IN_RECOVERY(tp->t_flags)) {
 		if (SEQ_LT(th->th_ack, tp->snd_recover) &&
@@ -8663,6 +8663,7 @@ bbr_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 	if (SEQ_GT(th->th_ack, tp->snd_una))
 		bbr_collapse_rtt(tp, bbr, TCP_REXMTVAL(tp));
 	tp->snd_una = th->th_ack;
+	tcp_adapt_iss_check(tp);
 	if (tp->snd_wnd < ctf_outstanding(tp))
 		/* The peer collapsed its window on us */
 		bbr_collapsed_window(bbr);
diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index 41c96a054002..245b623327ae 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -12153,7 +12153,6 @@ rack_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 	INP_WLOCK_ASSERT(tptoinpcb(tp));
 
 	rack = (struct tcp_rack *)tp->t_fb_ptr;
-	tcp_adapt_iss_check(tp);
 	if (!V_tcp_insecure_ack) {
 		tcp_seq seq_min;
 		bool ghost_ack_check;
@@ -12369,6 +12368,7 @@ rack_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 		ourfinisacked = 1;
 	}
 	tp->snd_una = th->th_ack;
+	tcp_adapt_iss_check(tp);
 	/* wakeups? */
 	if (acked_amount && sbavail(&so->so_snd))
 		rack_adjust_sendmap_head(rack, &so->so_snd);
@@ -13150,6 +13150,7 @@ rack_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
 		SOCKBUF_LOCK(&so->so_snd);
 		mfree = sbcut_locked(&so->so_snd, acked);
 		tp->snd_una = th->th_ack;
+		tcp_adapt_iss_check(tp);
 		/* Note we want to hold the sb lock through the sendmap adjust */
 		rack_adjust_sendmap_head(rack, &so->so_snd);
 		/* Wake up the socket if we have room to write more */
@@ -16344,6 +16345,7 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb
 			 * should be).
 			 */
 			tp->snd_una = high_seq;
+			tcp_adapt_iss_check(tp);
 		}
 		/* Did we make a RTO error? */
 		if ((tp->t_flags & TF_PREVVALID) &&
@@ -16363,6 +16365,7 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb
 			SOCKBUF_LOCK(&so->so_snd);
 			mfree = sbcut_locked(&so->so_snd, acked_amount);
 			tp->snd_una = high_seq;
+			tcp_adapt_iss_check(tp);
 			/* Note we want to hold the sb lock through the sendmap adjust */
 			rack_adjust_sendmap_head(rack, &so->so_snd);
 			/* Wake up the socket if we have room to write more */