From: Jon Maloy <jmaloy@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, passt-dev@passt.top
Subject: Re: [PATCH] migrate, tcp: Account for bytes acknowledged before migration
Date: Thu, 3 Dec 2026 17:44:29 -0500 [thread overview]
Message-ID: <97cd8209-6545-484b-9956-9fe16e455ec6@redhat.com> (raw)
In-Reply-To: <20261203171808.445429-1-lvivier@redhat.com>
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 <lvivier@redhat.com>
> ---
> 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 <jmaloy@redhat.com>
prev parent reply other threads:[~2026-12-03 22:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:18 Laurent Vivier
2026-12-03 22:44 ` Jon Maloy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97cd8209-6545-484b-9956-9fe16e455ec6@redhat.com \
--to=jmaloy@redhat.com \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).