git: f3364d3c8c87 - main - tcp: improve handling of segments in TIME WAIT

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Wed, 25 Feb 2026 13:09:24 UTC
The branch main has been updated by tuexen:

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

commit f3364d3c8c876074a9a6f68168e5eb8bd60207de
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-02-25 13:06:15 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-02-25 13:06:15 +0000

    tcp: improve handling of segments in TIME WAIT
    
    The check for excluding duplicate ACKs needs to consider only TH_SYN
    and TH_FIN. We know that TH_ACK is set and TH_RST is cleared. All
    other flags, in particular TH_ECE, TH_CWR, and TH_AE needs to be
    ignored for the check.
    
    PR:                     292293
    Reviewed by:            rrs
    MFC after:              3 days
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D55489
---
 sys/netinet/tcp_timewait.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 847598422da5..ba5c90c91e43 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -287,7 +287,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
 	/*
 	 * Acknowledge the segment if it has data or is not a duplicate ACK.
 	 */
-	if (thflags != TH_ACK || tlen != 0 ||
+	if ((thflags & (TH_SYN | TH_FIN)) != 0 || tlen != 0 ||
 	    th->th_seq != tp->rcv_nxt || th->th_ack != tp->snd_nxt) {
 		TCP_LOG_EVENT(tp, th, NULL, NULL, TCP_LOG_IN, 0, tlen, NULL,
 		    true);