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 9DE865A0271 for ; Fri, 04 Dec 2026 23:31:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796423501; 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=N4BsfutNz4vNalE5/eEQMcK2io/0qpwjcYEPDjDhtH8=; b=OHv4VobRZjMx0/I8U3GQ/y6prEWldv27L1aYqyvMlVph81ZvQpZaIGbTFAf3dPkJ9cUChD F1Pe6K5IWvGq4IEwn/q96H0JoG8RBNxG0dgxsaat3ypJRxMdGFOP0SdwBQcUX4yLApbtCq d5I0Npjtn7cM9mgu3vpbtDQj7s9QsdI= X-MC-Rep: binary re single Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-hmK6HR-2N6agT65fnO0ZUw-1; Fri, 4 Dec 2026 22:31:39 +0000 X-MC-Unique: hmK6HR-2N6agT65fnO0ZUw-1 X-Mimecast-MFC-AGG-ID: hmK6HR-2N6agT65fnO0ZUw_1796423498 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4ab855a8c21so1280772f8f.1 for ; Fri, 04 Dec 2026 14:31:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796423498; x=1797028298; 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 :re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5:b0:4b9:8ac3:f5fa with SMTP id ffacd0b85a97d-4d1ec16d4b7mr6597255f8f.48.1796423498264; Fri, 04 Dec 2026 14:31:38 -0800 (PST) X-Received: by 2002:a05:6000:18a5:b0:4b9:8ac3:f5fa with SMTP id ffacd0b85a97d-4d1ec16d4b7mr6597220f8f.48.1796423497706; Fri, 04 Dec 2026 14:31:37 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d173ab8e3fsm8108655f8f.42.2026.12.04.14.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 14:31:37 -0800 (PST) From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration Message-ID: <20261204233135.32dfdf98@elisabeth> In-Reply-To: <20261204122802.1235595-1-lvivier@redhat.com> References: <20261204122802.1235595-1-lvivier@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: Fri, 04 Dec 2026 23:31:36 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AIlA41Hp26eqw2hzCSmp-hOpqQNJ6GuZUaWgVVvfmV0_1796423498 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: FXVRV2RCNLWY2MTK45Q7H62AKR2G6XNW X-Message-ID-Hash: FXVRV2RCNLWY2MTK45Q7H62AKR2G6XNW 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, David Gibson , Lynxes Exe , Jon Maloy 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 Fri, 4 Dec 2026 13:28:02 +0100 Laurent Vivier wrote: > The repaired socket starts with tcpi_bytes_acked at zero. Even though > seq_ack_to_tap is migrated, ACKs computed afterward from tcpi_bytes_acked > are missing the progress made on the source. > > If the target uses this counter, it can send an ACK older than the last > ACK the guest received before migration. The guest keeps retransmitting > the first segment it is still waiting for passt to acknowledge, and > rampstream_out can stall. > > A bug in tcp_rtt_dst_check() hid this in our tests. On a repaired > socket, tcpi_min_rtt is ~0U until the first RTT sample. The cast to > int turned ~0U into -1, so the target added the peer to low_rtt_dst[] > and used seq_from_tap for ACKs. > > To fix that, we set seq_init_from_tap on the target using the state > already sent by the source: > > seq_init_from_tap = seq_from_tap - t.sndq > > seq_from_tap is the next sequence number passt expects from the guest. > t.sndq includes both unsent bytes and sent bytes awaiting an ACK, so > subtracting it gives the guest sequence at the head of the restored > send queue. tcp_update_seqack_wnd() adds the repaired socket's > tcpi_bytes_acked to this base when computing the ACK sent to the guest. > > This also works when migrating from an older passt using the v2 format. > > Signed-off-by: Laurent Vivier Applied, I just took the liberty, on merge, to... > --- > > Notes: > v2: Reuse seq_init_from_tap on the target and drop bytes_acked > > tcp.c | 14 +++++++++++++- > tcp_conn.h | 4 ++-- > 2 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/tcp.c b/tcp.c > index b1065545aeea..1267af02d359 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -220,7 +220,7 @@ > * @seq_from_tap: next sequence for packets from tap/guest (expected) > * @seq_ack_to_tap: last ACK number sent to tap/guest > * > - * @seq_init_from_tap: initial sequence number from tap/guest > + * @seq_init_from_tap: guest sequence base for bytes acknowledged by the peer > * @seq_init_to_tap: initial sequence number from tap/guest > * > * @wnd_from_tap: last window size received from tap, never scaled > @@ -3936,6 +3936,18 @@ int tcp_flow_migrate_target_ext(struct ctx *c, struct tcp_tap_conn *conn, > return -EINVAL; > } > > + /* The target socket's tcpi_bytes_acked starts at zero after migration. > + * Subtract the length of the current sending queue from the accepted > + * guest sequence to recover the amount of bytes the peer had already > + * acknowledged. > + * > + * Add this offset to the initial sequence number, to correctly adjust > + * the acknowledgement sequence number we send to the guest, as > + * calculated by tcp_update_seqack_wnd(). > + */ > + ...amend this comment, hopefully addressing the issue raised by Jon. > + conn->seq_init_from_tap = conn->seq_from_tap - t.sndq; > + > if (read_all_buf(fd, tcp_migrate_snd_queue, t.sndq)) { > rc = -errno; > flow_perror(conn, "Failed to read send queue data"); > diff --git a/tcp_conn.h b/tcp_conn.h > index 3173ddb945e3..89994530dc23 100644 > --- a/tcp_conn.h > +++ b/tcp_conn.h > @@ -34,7 +34,7 @@ > * @seq_ack_from_tap: Last ACK number received from tap > * @seq_from_tap: Next sequence for packets from tap (not actually sent) > * @seq_ack_to_tap: Last ACK number sent to tap > - * @seq_init_from_tap: Initial sequence number from tap > + * @seq_init_from_tap: Guest sequence base for bytes acknowledged by the peer > */ > struct tcp_tap_conn { > /* Must be first element */ > @@ -136,7 +136,7 @@ struct tcp_tap_conn { > * @seq_ack_from_tap: Last ACK number received from tap > * @seq_from_tap: Next sequence for packets from tap (not actually sent) > * @seq_ack_to_tap: Last ACK number sent to tap > - * @seq_init_from_tap: Initial sequence number from tap > + * @seq_init_from_tap: Guest sequence base for bytes acknowledged by the peer > */ > struct tcp_tap_transfer { > uint8_t pif[SIDES]; -- Stefano