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 0C0045A0269 for ; Thu, 03 Dec 2026 23:44:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796337875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7d1QGfS5RORPGAaZXcME3odkwMQ+sk78wGo6dyWGQ10=; b=SavUhyF73hGK/6lq3cwHs90CrW+PW3j9GQDB3dJ/YzSNH2Qngbgc59oYyXua3SoW0EwDhg OM8IW2sQ1Mkoh1qXtwBYtR5DKhTY4qh2iq2GF7xGGkf7BILqPP7AuJwxeuHOgWaJUiEmgu K0872cjgGLDak4aLbwzBCD+SlsJNz2c= X-MC-Rep: binary re single Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-R6QnmWvlMDGlyh6B2-sYNA-1; Thu, 3 Dec 2026 22:44:34 +0000 X-MC-Unique: R6QnmWvlMDGlyh6B2-sYNA-1 X-Mimecast-MFC-AGG-ID: R6QnmWvlMDGlyh6B2-sYNA_1796337873 Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b588e4bd7fso115992c88.0 for ; Thu, 03 Dec 2026 14:44:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796337873; x=1796942673; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:re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2e2KTv7/7AMs6vuKigAWJv CYQWrNmnAvlE/qA7KSnLlpamLPdQOQT9pKKK2ngQtGRaJKfozr/P/dP8UKALPCoSjMZL/Mjb8w2 iFJHYTEL0j41eD9x9D2yRvnmsB9r/a9yvRZlSbWrI= X-Received: by 2002:a05:701b:4502:20b0:1b5:481:ff0f with SMTP id a92af1059eb24-1b5d725d196mr270400c88.32.1796337872935; Thu, 03 Dec 2026 14:44:32 -0800 (PST) X-Received: by 2002:a05:701b:4502:20b0:1b5:481:ff0f with SMTP id a92af1059eb24-1b5d725d196mr270384c88.32.1796337872364; Thu, 03 Dec 2026 14:44:32 -0800 (PST) Received: from [192.168.2.15] (lnsm6-montreal02-142-122-43-105.internet.virginmobile.ca. [142.122.43.105]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d646ce0fsm1169061c88.12.2026.12.03.14.44.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2026 14:44:32 -0800 (PST) Message-ID: <97cd8209-6545-484b-9956-9fe16e455ec6@redhat.com> Date: Thu, 3 Dec 2026 17:44:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] migrate, tcp: Account for bytes acknowledged before migration To: Laurent Vivier , passt-dev@passt.top References: <20261203171808.445429-1-lvivier@redhat.com> From: Jon Maloy In-Reply-To: <20261203171808.445429-1-lvivier@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ILW7C8FWcsHd-cyDD7TjQUKhxufeH3HZsBclBv40Kmw_1796337873 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: 6TZS7GFZDG2DNC7TLKX7P3EHMZ2KZCFY X-Message-ID-Hash: 6TZS7GFZDG2DNC7TLKX7P3EHMZ2KZCFY X-MailFrom: jmaloy@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 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 2026-12-03 12:18, 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. This seems to be the issue that kept Stefano from merging Lynxes' "tcp: Don't add peers to low RTT table before RTT is measured", from the thread at: https://archives.passt.top/passt-dev/avz8R6lrK91ZS4qJ@gractus.seuss/ where migrate/rampstream_out started failing with it. That one can now be applied as soon as this one is in place. It's also nice that this doesn't need the low RTT table to be migrated, which David had objections to. > > To fix that, we add a per-flow offset, bytes_acked, to the target > socket's tcpi_bytes_acked when computing seq_ack_to_tap. > > We can avoid migrating tcpi_bytes_acked by reconstructing the offset > on each migration from the existing state: > > bytes_acked = (seq_from_tap - t.sndq) - seq_init_from_tap > > 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. Subtracting seq_init_from_tap expresses that position as > an offset from the sequence base passt uses for its ACK calculation. > > This works with the existing v2 migration format. > > Signed-off-by: Laurent Vivier > --- > tcp.c | 9 +++++++++ > tcp_conn.h | 1 + > 2 files changed, 10 insertions(+) > > diff --git a/tcp.c b/tcp.c > index b1065545aeea..7f3e5a0309ad 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1192,6 +1192,7 @@ int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn, > /* cppcheck bug 14191 again, see above */ > /* cppcheck-suppress [uninitvar,unmatchedSuppression] */ > conn->seq_ack_to_tap = tinfo->tcpi_bytes_acked + > + conn->bytes_acked + > conn->seq_init_from_tap; > } > [...] > --- a/tcp_conn.h > +++ b/tcp_conn.h > @@ -116,6 +116,7 @@ struct tcp_tap_conn { > uint32_t seq_from_tap; > uint32_t seq_ack_to_tap; > uint32_t seq_init_from_tap; > + uint32_t bytes_acked; There should be a @bytes_acked line in the comment above the struct. Maybe also a name that makes it clearer it's an offset added to tcpi_bytes_acked, such as bytes_acked_base? The fix itself looks correct: (seq_from_tap - sndq) - seq_init_from_tap is exactly what the peer acknowledged at migration time. Since it is recomputed on each migration, it should also work if we migrate again. With the struct comment fixed: Reviewed-by: Jon Maloy