From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id C75A95A0269 for ; Mon, 30 Nov 2026 07:44:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796021064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Iaw9xcvIuJxJnpVWgwE04BPXFszfwNvSq6EwlyrBsE=; b=Bv6nB/WXmn+hE05feiUZs16lOC++Ph9LW3MJBhkn0YQliX4TGaAxHiISl1MJfNdFxI39f2 ZfLSaBhhafyxGupHj/Ts4C7SdTDpNYRjT4Btm32erTYtPEeUL2+1F3nA5UZea3JwqdFyxV bU7sOS7Mf88X7sr06oM1PIwqn1jojuc= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-HOJtgz88PUOI6jf4r2GmKg-1; Mon, 30 Nov 2026 06:44:22 +0000 X-MC-Unique: HOJtgz88PUOI6jf4r2GmKg-1 X-Mimecast-MFC-AGG-ID: HOJtgz88PUOI6jf4r2GmKg_1796021061 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B20C71800548; Mon, 30 Nov 2026 06:44:18 +0000 (UTC) Received: from anskuma-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46282300022B; Mon, 30 Nov 2026 06:44:15 +0000 (UTC) From: Anshu Kumari To: passt-dev@passt.top, ada.urbaniec+bugzilla@gmail.com, sbrivio@redhat.com Subject: [PATCH v5] tcp: Limit fast retransmit to one per loss event Date: Mon, 30 Nov 2026 12:14:14 +0530 Message-ID: <20261130064414.768566-1-anskuma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Rz2QAGKMgx4DIVQ1lRccQqp6WLilbE7L9kVdgwg4o2g_1796021061 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: OKOPM5MB6QIILQMTMFHUSNFQ62FPQCIO X-Message-ID-Hash: OKOPM5MB6QIILQMTMFHUSNFQ62FPQCIO X-MailFrom: anskuma@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: anskuma@redhat.com, Ada Urbaniec X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Every duplicate ACK unconditionally triggered a fast retransmit, even when the ACK sequence hadn't advanced. Guard fast retransmit on !conn->retries, and increment retries after the first retransmit. This is a quick fix to stop the amplification storm. Full compliance with RFC 5681 Section 3.2 (three duplicate ACKs) is left to a later patch. As a fast retransmit is now accounted in conn->retries, the next retransmission timeout is doubled (tcp_timer_ctl() uses conn->retries as backoff exponent). In TAP_FIN_RECVD path, tcp_tap_window_update() returns true for any non-zero window because of which tcp_data_from_sock() gets called for every ACKs(even for unchanged duplicate ACK). If the send window is full calling tcp_data_from_sock() re-armed the retransmission timer via conn_flag(),so periodic duplicate ACKs could delay retransmission indefinitely and prevent a half-closed connection from recovering. Therefore, only call tcp_data_from_sock() when the ACK or window actually changed. Link: https://bugs.passt.top/show_bug.cgi?id=224 Reported-by: Ada Urbaniec Signed-off-by: Anshu Kumari --- v5: - Expand the commit message to describe the half-close timer issue fixed by the ACK/window check - Added the comment for same v4: - Move !conn->retries into the retr check in TAP_FIN_RCVD - Add previous ACK/window snapshots in TAP_FIN_RCVD - includes Reported-by --- tcp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tcp.c b/tcp.c index 95f4f3e1..e8693818 100644 --- a/tcp.c +++ b/tcp.c @@ -2082,7 +2082,9 @@ static int tcp_data_from_tap(const struct ctx *c, struct tcp_tap_conn *conn, tcp_tap_window_update(c, conn, max_ack_seq_wnd, now); - if (retr) { + if (retr && !conn->retries) { + conn->retries++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", conn->seq_ack_from_tap, conn->seq_to_tap); @@ -2417,6 +2419,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, /* Established connections not accepting data from tap */ if (conn->events & TAP_FIN_RCVD) { + uint32_t prev_ack = conn->seq_ack_from_tap; + uint16_t prev_wnd = conn->wnd_from_tap; bool fin_only, retr; size_t dlen; @@ -2432,7 +2436,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, fin_only = (conn->events & TAP_FIN_SENT) && conn->seq_to_tap == conn->seq_ack_from_tap + 1; - retr = th->ack && !th->fin && !fin_only && + retr = th->ack && !th->fin && !fin_only && !conn->retries && ntohl(th->ack_seq) == conn->seq_ack_from_tap && ntohs(th->window) == conn->wnd_from_tap; @@ -2444,6 +2448,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, now); if (retr) { + conn->retries++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", ntohl(th->ack_seq), conn->seq_to_tap); @@ -2452,8 +2458,11 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, return -1; } - if (tcp_tap_window_update(c, conn, ntohs(th->window), now) || - retr) + /* An unchanged ACK and window must not restart the timer. */ + if (tcp_tap_window_update(c, conn, ntohs(th->window), now) && + (retr || + prev_ack != conn->seq_ack_from_tap || + prev_wnd != conn->wnd_from_tap)) tcp_data_from_sock(c, conn, now); if (conn->seq_ack_from_tap == conn->seq_to_tap) { -- 2.55.0