* [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
@ 2026-12-04 10:49 Laurent Vivier
2026-12-04 12:14 ` Stefano Brivio
0 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2026-12-04 10:49 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
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 <lvivier@redhat.com>
---
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().
+ */
+
+ 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];
--
2.56.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
2026-12-04 10:49 [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration Laurent Vivier
@ 2026-12-04 12:14 ` Stefano Brivio
0 siblings, 0 replies; 7+ messages in thread
From: Stefano Brivio @ 2026-12-04 12:14 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
On Fri, 4 Dec 2026 11:49:48 +0100
Laurent Vivier <lvivier@redhat.com> 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 <lvivier@redhat.com>
> ---
>
> Notes:
> v2: Reuse seq_init_from_tap on the target and drop bytes_acked
Thanks, I haven't tested this yet but it all looks reasonable to me
now.
Would you have a chance to resend with all relevant Cc's, that is, Jon
as he reviewed v1, Lynxes as their patch is blocked on it, and David as
well?
--
Stefano
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
@ 2026-12-04 12:28 Laurent Vivier
2026-12-04 19:24 ` Jon Maloy
2026-12-04 22:31 ` Stefano Brivio
0 siblings, 2 replies; 7+ messages in thread
From: Laurent Vivier @ 2026-12-04 12:28 UTC (permalink / raw)
To: passt-dev
Cc: David Gibson, Lynxes Exe, Jon Maloy, Stefano Brivio, Laurent Vivier
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 <lvivier@redhat.com>
---
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().
+ */
+
+ 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];
--
2.56.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
2026-12-04 12:28 Laurent Vivier
@ 2026-12-04 19:24 ` Jon Maloy
2026-12-04 20:56 ` Stefano Brivio
2026-12-04 22:31 ` Stefano Brivio
1 sibling, 1 reply; 7+ messages in thread
From: Jon Maloy @ 2026-12-04 19:24 UTC (permalink / raw)
To: Laurent Vivier, passt-dev; +Cc: David Gibson, Lynxes Exe, Stefano Brivio
On 2026-12-04 07:28, 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.
Strictly speaking, we never send an older ACK, because
tcp_update_seqack_wnd() doesn't let seq_ack_to_tap go backwards. The
ACK instead gets stuck at the migrated value until the new socket has
acknowledged as much data as the old one did, and that's what makes
the guest 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[]
[...]
> --- 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().
> + */
The code doesn't actually add anything to the initial sequence number, it
just replaces it with a sequence that already includes the offset.
> +
> + conn->seq_init_from_tap = conn->seq_from_tap - t.sndq;
> +
[...]
I tested with the migrate tests, on top of a local change dropping the
(int) cast in tcp_rtt_dst_check(), so that the bug isn't hidden.
- without your patch, migrate/rampstream_out ==> hangs
- with it, migrate/rampstream_out ==> passes
migrate/iperf3_many_out6 (host to guest part) and migrate/rampstream_in
fail here with and without your patch, also on plain master, and
migrate/iperf3_bidir6 seems to be flaky either way. That last issue
seems to come from tcp_flow_repair_queue() failing with EAGAIN on the
non-blocking target socket, for 77 of 128 flows in one run. I believe
this is because the queues don't fit in the new socket's send buffer yet.
I can look into this separately, it's not related to this patch.
With or without updated comments:
Reviewed-by: Jon Maloy <jmaloy@redhat.com>
Tested-by: Jon Maloy <jmaloy@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
2026-12-04 19:24 ` Jon Maloy
@ 2026-12-04 20:56 ` Stefano Brivio
2026-12-04 21:15 ` Jon Maloy
0 siblings, 1 reply; 7+ messages in thread
From: Stefano Brivio @ 2026-12-04 20:56 UTC (permalink / raw)
To: Jon Maloy; +Cc: Laurent Vivier, passt-dev, David Gibson, Lynxes Exe
On Fri, 4 Dec 2026 14:24:21 -0500
Jon Maloy <jmaloy@redhat.com> wrote:
> On 2026-12-04 07:28, 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.
>
> Strictly speaking, we never send an older ACK, because
> tcp_update_seqack_wnd() doesn't let seq_ack_to_tap go backwards. The
> ACK instead gets stuck at the migrated value until the new socket has
> acknowledged as much data as the old one did, and that's what makes
> the guest stall.
Oops, you're right. Let me just add your note on merge, at this point
of the commit message, as "Jon's note".
> > 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[]
>
> [...]
>
> > --- 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().
> > + */
>
> The code doesn't actually add anything to the initial sequence number, it
> just replaces it with a sequence that already includes the offset.
I still think that, conceptually, it does that, even though we don't
have an addition below. And if the sequence didn't wrap yet, it's also
what happens in practice. But if it wrapped, the comment might be
misleading, my bad for suggesting this phrasing.
Let me amend that on merge to:
* Replace the initial sequence number with this quantity to adjust the
* acknowledgement sequence number we send to the guest, as calculated by
* tcp_update_seqack_wnd().
...does it make sense?
> > +
> > + conn->seq_init_from_tap = conn->seq_from_tap - t.sndq;
> > +
>
> [...]
>
> I tested with the migrate tests, on top of a local change dropping the
> (int) cast in tcp_rtt_dst_check(), so that the bug isn't hidden.
>
> - without your patch, migrate/rampstream_out ==> hangs
> - with it, migrate/rampstream_out ==> passes
>
> migrate/iperf3_many_out6 (host to guest part) and migrate/rampstream_in
> fail here with and without your patch, also on plain master, and
> migrate/iperf3_bidir6 seems to be flaky either way. That last issue
> seems to come from tcp_flow_repair_queue() failing with EAGAIN on the
> non-blocking target socket, for 77 of 128 flows in one run. I believe
> this is because the queues don't fit in the new socket's send buffer yet.
> I can look into this separately, it's not related to this patch.
They all work reliably on my setup, but:
- I have rather large values for /proc/sys/net/core/[rw]mem_max
- regardless of how we try to keep things running here, there's this
fundamental kernel issue:
https://lore.kernel.org/netdev/20260518183424.3144867-1-sbrivio@redhat.com/
for which I didn't manage to get a fix accepted, yet. You might need
it.
Maybe it's something completely different entirely, though. It might
also very well be issues in the tests, their main goal is showing
regressions rather than being entirely correct or stable.
> With or without updated comments:
>
> Reviewed-by: Jon Maloy <jmaloy@redhat.com>
> Tested-by: Jon Maloy <jmaloy@redhat.com>
Adding regardless.
--
Stefano
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
2026-12-04 20:56 ` Stefano Brivio
@ 2026-12-04 21:15 ` Jon Maloy
0 siblings, 0 replies; 7+ messages in thread
From: Jon Maloy @ 2026-12-04 21:15 UTC (permalink / raw)
To: Stefano Brivio; +Cc: Laurent Vivier, passt-dev, David Gibson, Lynxes Exe
On 2026-12-04 15:56, Stefano Brivio wrote:
> On Fri, 4 Dec 2026 14:24:21 -0500
> Jon Maloy <jmaloy@redhat.com> wrote:
>
>> On 2026-12-04 07:28, 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.
>>
>> Strictly speaking, we never send an older ACK, because
>> tcp_update_seqack_wnd() doesn't let seq_ack_to_tap go backwards. The
>> ACK instead gets stuck at the migrated value until the new socket has
>> acknowledged as much data as the old one did, and that's what makes
>> the guest stall.
>
> Oops, you're right. Let me just add your note on merge, at this point
> of the commit message, as "Jon's note".
>
>>> 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[]
>>
>> [...]
>>
>>> --- 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().
>>> + */
>>
>> The code doesn't actually add anything to the initial sequence number, it
>> just replaces it with a sequence that already includes the offset.
>
> I still think that, conceptually, it does that, even though we don't
> have an addition below. And if the sequence didn't wrap yet, it's also
> what happens in practice. But if it wrapped, the comment might be
> misleading, my bad for suggesting this phrasing.
>
> Let me amend that on merge to:
>
> * Replace the initial sequence number with this quantity to adjust the
> * acknowledgement sequence number we send to the guest, as calculated by
> * tcp_update_seqack_wnd().
>
> ...does it make sense?
Yes.
>
>>> +
>>> + conn->seq_init_from_tap = conn->seq_from_tap - t.sndq;
>>> +
>>
>> [...]
>>
>> I tested with the migrate tests, on top of a local change dropping the
>> (int) cast in tcp_rtt_dst_check(), so that the bug isn't hidden.
>>
>> - without your patch, migrate/rampstream_out ==> hangs
>> - with it, migrate/rampstream_out ==> passes
>>
>> migrate/iperf3_many_out6 (host to guest part) and migrate/rampstream_in
>> fail here with and without your patch, also on plain master, and
>> migrate/iperf3_bidir6 seems to be flaky either way. That last issue
>> seems to come from tcp_flow_repair_queue() failing with EAGAIN on the
>> non-blocking target socket, for 77 of 128 flows in one run. I believe
>> this is because the queues don't fit in the new socket's send buffer yet.
>> I can look into this separately, it's not related to this patch.
>
> They all work reliably on my setup, but:
>
> - I have rather large values for /proc/sys/net/core/[rw]mem_max
>
> - regardless of how we try to keep things running here, there's this
> fundamental kernel issue:
>
> https://lore.kernel.org/netdev/20260518183424.3144867-1-sbrivio@redhat.com/
>
> for which I didn't manage to get a fix accepted, yet. You might need
> it.
>
> Maybe it's something completely different entirely, though. It might
> also very well be issues in the tests, their main goal is showing
> regressions rather than being entirely correct or stable.
Agreed. I don't think I'll jump on this right now.
/jon
>
>> With or without updated comments:
>>
>> Reviewed-by: Jon Maloy <jmaloy@redhat.com>
>> Tested-by: Jon Maloy <jmaloy@redhat.com>
>
> Adding regardless.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration
2026-12-04 12:28 Laurent Vivier
2026-12-04 19:24 ` Jon Maloy
@ 2026-12-04 22:31 ` Stefano Brivio
1 sibling, 0 replies; 7+ messages in thread
From: Stefano Brivio @ 2026-12-04 22:31 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev, David Gibson, Lynxes Exe, Jon Maloy
On Fri, 4 Dec 2026 13:28:02 +0100
Laurent Vivier <lvivier@redhat.com> 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 <lvivier@redhat.com>
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-04 22:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 10:49 [PATCH v2] migrate, tcp: Account for bytes acknowledged before migration Laurent Vivier
2026-12-04 12:14 ` Stefano Brivio
2026-12-04 12:28 Laurent Vivier
2026-12-04 19:24 ` Jon Maloy
2026-12-04 20:56 ` Stefano Brivio
2026-12-04 21:15 ` Jon Maloy
2026-12-04 22:31 ` Stefano Brivio
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).