diff options
| author | Laurent Vivier <lvivier@redhat.com> | 2026-12-04 13:28:02 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-04 22:54:33 +0100 |
| commit | 1d3afa7c3a4532055bd841fcf669b89345557c87 (patch) | |
| tree | b10147364e0e4cf505bcaa9871997451bfdee6e6 | |
| parent | 0ae06bb610806d3f7567da5c8115076b14b82ef5 (diff) | |
| download | passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar.gz passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar.bz2 passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar.lz passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar.xz passt-1d3afa7c3a4532055bd841fcf669b89345557c87.tar.zst passt-1d3afa7c3a4532055bd841fcf669b89345557c87.zip | |
migrate, tcp: Account for bytes acknowledged before migration
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.
[Note from Jon:
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[]
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>
Reviewed-by: Jon Maloy <jmaloy@redhat.com>
Tested-by: Jon Maloy <jmaloy@redhat.com>
[sbrivio: Reworded comment in tcp_flow_migrate_target_ext()]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | tcp.c | 13 | ||||
| -rw-r--r-- | tcp_conn.h | 4 |
2 files changed, 14 insertions, 3 deletions
@@ -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 @@ -3942,6 +3942,17 @@ 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. + * + * 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(). + */ + 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"); @@ -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]; |
