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 9B7D65A0265 for ; Fri, 20 Nov 2026 08:43:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795160598; 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=+gZ19sUOdmXhDOGcl37zEquYQc103UbiO/0uwyngFDM=; b=X6rbMDvp044dYHlpFz3UymaoPEzEpKwkdqR6xyxUinw2DtGC3CZWM3p6g7ZzLv5kN+riQa cRxOnbXQLec65SopoBmtZA9OUDU7djZjy8COeEjdxwwfX20OiHBAJVxz969T8pm5gnXZhM xl/dPIIyTPO9G4JNXbht/fhNQPywFws= Received: from mx-prod-mc-01.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-94-a2z_phpnOQGL-BlG0VP1zg-1; Fri, 20 Nov 2026 07:43:16 +0000 X-MC-Unique: a2z_phpnOQGL-BlG0VP1zg-1 X-Mimecast-MFC-AGG-ID: a2z_phpnOQGL-BlG0VP1zg_1795160595 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 95494195DE4B; Fri, 20 Nov 2026 07:43:08 +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 4738D30000D3; Fri, 20 Nov 2026 07:43:05 +0000 (UTC) From: Anshu Kumari To: ada.urbaniec+bugzilla@gmail.com, passt-dev@passt.top, sbrivio@redhat.com Subject: [PATCH v2] tcp: Limit fast retransmit to one per loss event Date: Fri, 20 Nov 2026 13:13:04 +0530 Message-ID: <20261120074304.1698961-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: opZk26WhXz46CjfCcKrRkSzDN4rBbQnDqeZpDDcyWBw_1795160595 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 5DVCWNKDJXLVN74BIKHUUVCAWCSXHCJ6 X-Message-ID-Hash: 5DVCWNKDJXLVN74BIKHUUVCAWCSXHCJ6 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 dup_acks counter (as a union with retries) to tcp_tap_conn and tcp_tap_transfer that gets incremented on the first fast retransmit and cleared when the ACK sequence advances. 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. Link: https://bugs.passt.top/show_bug.cgi?id=224 Signed-off-by: Anshu Kumari --- v2: - added union for retries and dup_acks. - removed retransmitting flag. --- tcp.c | 12 ++++++++---- tcp_conn.h | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tcp.c b/tcp.c index 95f4f3e1..d205cd41 100644 --- a/tcp.c +++ b/tcp.c @@ -242,7 +242,7 @@ * - 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 + * resend with steps listed above, once per loss event * * - from tap/guest to socket: * - on packet from tap/guest: @@ -1263,7 +1263,7 @@ static void tcp_update_seqack_from_tap(const struct ctx *c, if (SEQ_LT(seq, conn->seq_to_tap)) conn_flag(c, conn, ACK_FROM_TAP_DUE, now); - conn->retries = 0; + conn->dup_acks = 0; conn->seq_ack_from_tap = seq; } } @@ -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->dup_acks) { + conn->dup_acks++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", conn->seq_ack_from_tap, conn->seq_to_tap); @@ -2443,7 +2445,9 @@ 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->dup_acks) { + conn->dup_acks++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", ntohl(th->ack_seq), conn->seq_to_tap); diff --git a/tcp_conn.h b/tcp_conn.h index 3173ddb9..ba175a3e 100644 --- a/tcp_conn.h +++ b/tcp_conn.h @@ -16,7 +16,8 @@ /** * 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 due to timeouts + * @dup_acks: Number of duplicate ACKs (union with @retries) * @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 @@ -41,7 +42,10 @@ struct tcp_tap_conn { struct flow_common f; #define TCP_RETRIES_BITS 3 - unsigned int retries :TCP_RETRIES_BITS; + union { + unsigned int retries :TCP_RETRIES_BITS; + unsigned int dup_acks :TCP_RETRIES_BITS; + }; #define TCP_MAX_RETRIES MAX_FROM_BITS(TCP_RETRIES_BITS) #define TCP_WS_BITS 4 /* RFC 7323 */ @@ -122,7 +126,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 due to timeouts + * @dup_acks: Number of duplicate ACKs (union with @retries) * @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 @@ -142,7 +147,10 @@ struct tcp_tap_transfer { uint8_t pif[SIDES]; struct flowside side[SIDES]; - uint8_t retries; + union { + uint8_t retries; + uint8_t dup_acks; + }; uint8_t ws_from_tap; uint8_t ws_to_tap; uint8_t events; -- 2.55.0