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.129.124]) by passt.top (Postfix) with ESMTPS id 8865A5A0269 for ; Thu, 19 Nov 2026 13:58:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795093079; 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=0MlFN4PVoPQrs/Kq8PzPI2QDtXLb7EqQhgh/j85FceM=; b=ECipc2mD60SJC820Zb0FpoJSmA3OrPNbWObZbnBcepqtGmUfgYrppE7s5Ngse5+pOlusvl +PZTlv8A92QS5VlMYP0XISYncXrMvyZU442G4bwUnxzvRZnrw+9rsh9P2H1niW/Lecw3uG mGT6fe5aYKyI3h/MghVeS+4Ff1s//u0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-oin3bcL9NB6FVK8ag5_TRg-1; Thu, 19 Nov 2026 07:57:57 -0500 X-MC-Unique: oin3bcL9NB6FVK8ag5_TRg-1 X-Mimecast-MFC-AGG-ID: oin3bcL9NB6FVK8ag5_TRg_1795093077 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DDBB31955BD9; Thu, 19 Nov 2026 12:57:56 +0000 (UTC) Received: from anskuma-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 82BC4195B3C7; Thu, 19 Nov 2026 12:57:54 +0000 (UTC) From: Anshu Kumari To: sbrivio@redhat.com, passt-dev@passt.top, ada.urbaniec+bugzilla@gmail.com Subject: [PATCH] tcp: Limit fast retransmit to one per loss event Date: Thu, 19 Nov 2026 18:27:52 +0530 Message-ID: <20261119125752.1418394-1-anskuma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Lq0CgHoEqx2REeWoXDkEn51MQGGjVhF-JZBxyhPkL9U_1795093077 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: YQJTH76IIEHYT6JDTSCF6OAJIIY57MXC X-Message-ID-Hash: YQJTH76IIEHYT6JDTSCF6OAJIIY57MXC 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 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. Add a retransmitting flag to track whether we are counting duplicate ACKs or actively retransmitting. we trigger fast retransmit after three duplicates ACKs (per RFC 5681, section 3.2). Clear both retransmitting and retries when the ACK sequence advances. Link: https://bugs.passt.top/show_bug.cgi?id=224 Signed-off-by: Anshu Kumari --- tcp.c | 33 +++++++++++++++++++++++++++------ tcp_conn.h | 8 ++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/tcp.c b/tcp.c index 95f4f3e1..ff5d34fa 100644 --- a/tcp.c +++ b/tcp.c @@ -238,11 +238,12 @@ * - on zero read, send FIN to tap/guest, set TAP_FIN_SENT * - on ACK from tap/guest: * - set @ts_ack_from_tap - * - check if it's the second duplicated ACK + * - count duplicate ACKs (same ack_seq and window, no data/FIN) * - consume buffer by difference between new ack_seq and @seq_ack_from_tap * - update @seq_ack_from_tap from ack_seq in header - * - on two duplicated ACKs, reset @seq_to_tap to @seq_ack_from_tap, and - * resend with steps listed above + * - after three duplicate ACKs (RFC 5681), reset @seq_to_tap to + * @seq_ack_from_tap, and resend with steps listed above, once per + * loss event * * - from tap/guest to socket: * - on packet from tap/guest: @@ -1264,6 +1265,7 @@ static void tcp_update_seqack_from_tap(const struct ctx *c, conn_flag(c, conn, ACK_FROM_TAP_DUE, now); conn->retries = 0; + conn->retransmitting = 0; conn->seq_ack_from_tap = seq; } } @@ -2082,7 +2084,13 @@ 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->retransmitting) + conn->retries++; + + if (retr && !conn->retransmitting && conn->retries > 3) { + conn->retransmitting = 1; + conn->retries = 0; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", conn->seq_ack_from_tap, conn->seq_to_tap); @@ -2443,7 +2451,13 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, tcp_update_seqack_from_tap(c, conn, ntohl(th->ack_seq), now); - if (retr) { + if (retr && !conn->retransmitting) + conn->retries++; + + if (retr && !conn->retransmitting && conn->retries > 3) { + conn->retransmitting = 1; + conn->retries = 0; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", ntohl(th->ack_seq), conn->seq_to_tap); @@ -2453,7 +2467,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, } if (tcp_tap_window_update(c, conn, ntohs(th->window), now) || - retr) + (retr && conn->retransmitting)) tcp_data_from_sock(c, conn, now); if (conn->seq_ack_from_tap == conn->seq_to_tap) { @@ -2737,6 +2751,11 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref, if (!conn->wnd_from_tap) conn->wnd_from_tap = 1; /* Zero-window probe */ + if (!conn->retransmitting) { + conn->retries = 0; + conn->retransmitting = 1; + } + conn->retries++; if (tcp_rewind_seq(c, conn, now)) return; @@ -3550,6 +3569,7 @@ int tcp_flow_migrate_source(int fd, struct tcp_tap_conn *conn) { struct tcp_tap_transfer t = { .retries = conn->retries, + .retransmitting = conn->retransmitting, .ws_from_tap = conn->ws_from_tap, .ws_to_tap = conn->ws_to_tap, .events = conn->events, @@ -3826,6 +3846,7 @@ int tcp_flow_migrate_target(struct ctx *c, int fd) conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp); conn->retries = t.retries; + conn->retransmitting = t.retransmitting; conn->ws_from_tap = t.ws_from_tap; conn->ws_to_tap = t.ws_to_tap; conn->events = t.events; diff --git a/tcp_conn.h b/tcp_conn.h index 3173ddb9..e8e2edf0 100644 --- a/tcp_conn.h +++ b/tcp_conn.h @@ -16,12 +16,13 @@ /** * struct tcp_tap_conn - Descriptor for a TCP connection (not spliced) * @f: Generic flow information - * @retries: Number of retries occurred due to timeouts + * @retries: Number of retries or duplicate ACKs, see @retransmitting * @ws_from_tap: Window scaling factor advertised from tap/guest * @ws_to_tap: Window scaling factor advertised to tap/guest * @tap_mss: MSS advertised by tap/guest, rounded to 2 ^ TCP_MSS_BITS * @tapinactive: No tao activity within the current KEEPALIVE_INTERVAL * @inactive: No activity within the current INACTIVITY_INTERVAL + * @retransmitting: 0 if counting duplicate ACKs, 1 if retransmitting * @sock: Socket descriptor number * @events: Connection events, implying connection states * @timer: timerfd descriptor for timeout events @@ -72,6 +73,7 @@ struct tcp_tap_conn { bool tap_inactive :1; bool inactive :1; + bool retransmitting :1; int sock :FD_REF_BITS; @@ -122,7 +124,8 @@ struct tcp_tap_conn { * struct tcp_tap_transfer - Migrated TCP data, flow table part, network order * @pif: Interfaces for each side of the flow * @side: Addresses and ports for each side of the flow - * @retries: Number of retries occurred due to timeouts + * @retries: Number of retries / duplicate ACKs + * @retransmitting: 0 if counting duplicate ACKs, 1 if retransmitting * @ws_from_tap: Window scaling factor advertised from tap/guest * @ws_to_tap: Window scaling factor advertised to tap/guest * @events: Connection events, implying connection states @@ -143,6 +146,7 @@ struct tcp_tap_transfer { struct flowside side[SIDES]; uint8_t retries; + uint8_t retransmitting; uint8_t ws_from_tap; uint8_t ws_to_tap; uint8_t events; -- 2.55.0