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 C5EBE5A0269 for ; Thu, 19 Nov 2026 20:01:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795114867; 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: in-reply-to:in-reply-to:references:references; bh=Fdmt3hOZaveeYPmjtYkJsYTNJrMRCTjVwtFt0aPQX7w=; b=ATAJ5Lu+bHITy6mlxVhGb1whqPM6M/rXufuzjLR1+wsXXhBfFDLqfhNZ4NvIFq7P8+STia z/QG/HhXKUQeCQHodqc35hignGJGxSD7+HsD697HmKJFL31cjgUKk/wbT52jbqA2UR5sWi up2DKy1i+JntvNiXLDtb2SKgHMNT/+A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-ZQFzL_gqOoa8Hpx44EsgZg-1; Thu, 19 Nov 2026 14:01:03 -0500 X-MC-Unique: ZQFzL_gqOoa8Hpx44EsgZg-1 X-Mimecast-MFC-AGG-ID: ZQFzL_gqOoa8Hpx44EsgZg_1795114862 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4bb6bac1e84so191555e9.0 for ; Thu, 19 Nov 2026 11:01:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795114862; x=1795719662; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; b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bb:6519:477e with SMTP id 5b1f17b1804b1-4bb88813b35mr9781015e9.17.1795114862072; Thu, 19 Nov 2026 11:01:02 -0800 (PST) X-Received: by 2002:a05:600c:1389:b0:4bb:6519:477e with SMTP id 5b1f17b1804b1-4bb88813b35mr9780015e9.17.1795114861335; Thu, 19 Nov 2026 11:01:01 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a12acsm57439475e9.8.2026.11.19.11.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 11:01:00 -0800 (PST) From: Stefano Brivio To: Anshu Kumari Subject: Re: [PATCH] tcp: Limit fast retransmit to one per loss event Message-ID: <20261119200058.1d9a4bf3@elisabeth> In-Reply-To: <20261119125752.1418394-1-anskuma@redhat.com> References: <20261119125752.1418394-1-anskuma@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 19 Nov 2026 20:01:00 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZoZIqtgZpODD7s1uY-5k5DghlnVCXpTtcXr3Gqv6Gtw_1795114862 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: NU7UUXOJQSDPJHAJPAAMTTAEUNLV5XAS X-Message-ID-Hash: NU7UUXOJQSDPJHAJPAAMTTAEUNLV5XAS X-MailFrom: sbrivio@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: passt-dev@passt.top, ada.urbaniec+bugzilla@gmail.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: On Thu, 19 Nov 2026 18:27:52 +0530 Anshu Kumari wrote: > 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. Is this change really doing what the title says? To me it looks like a mix of two things, but the second one is not complete, so it might actually break fast retransmit. That is, limiting the retransmissions to one per retransmit request is one part, that I was indicating as "quick fix" for #224 (I thought it was two lines, it turns out to be four), and that looks correct, and the most critical part of the fix, that we want to have soon. But the part counting three duplicate ACKs to implement better compliance to RFC 5681 is just a partial implementation (which I would leave as a second step, as I was suggesting, because it's definitely more involved). The concrete issue with that is: > 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++; ...that when we set 'retr' in the loop above, we're typically in the middle of a batch. We might have four segments there, with the same ACK sequence, but 'retr' is a boolean, so it can only convey the fact that there was at least one duplicate ACK. A 'true' value won't distinguish between one, two, or three. If we reach this point, we'll increment conn->retries once, and that's it. We might have several duplicate ACKs but never trigger the retransmission, below. Tracking 'retr' in the loop is a bit more complicated than this and I'd leave it to a later stage. > + > + 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; I would suggest to use a union here, so that this can be called something like 'dup_acks' if it's counting duplicate ACKs, and 'retries' if it's counting retries. > + uint8_t retransmitting; > uint8_t ws_from_tap; > uint8_t ws_to_tap; > uint8_t events; -- Stefano