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.133.124]) by passt.top (Postfix) with ESMTPS id BC16C5A0269 for ; Thu, 03 Dec 2026 18:18:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796318295; 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; bh=FcJztuo7BVAAmjH9R4CBKB3pFJPpm0hSQWVTQzAzyms=; b=QZOUoAYlgWGITSIjFdMoF1+feCDvDout/5903IUk4nxO5spqpVUv/SxhhA25qisGJDtF5w OBm6dEpF8tdXxY/rnxTxqYJkDfN96wJRLVobyKVn+5HTsslfLtr4/mSJpJFs7nMkg9jtG7 8GPvNqJ+axPpZtg0cRPeJ8sQNKaSTvc= X-MC-Rep: binary re single Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-jmdG3N_YPWqKsUFFwM36dA-1; Thu, 3 Dec 2026 17:18:12 +0000 X-MC-Unique: jmdG3N_YPWqKsUFFwM36dA-1 X-Mimecast-MFC-AGG-ID: jmdG3N_YPWqKsUFFwM36dA_1796318291 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16C79190EFC6 for ; Thu, 3 Dec 2026 17:18:11 +0000 (UTC) Received: from lvivier-thinkpadp1gen8.rmtfr.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46A81195605B; Thu, 3 Dec 2026 17:18:09 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH] migrate, tcp: Account for bytes acknowledged before migration Date: Thu, 3 Dec 2026 18:18:08 +0100 Message-ID: <20261203171808.445429-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ie3mPQGdJgl28dyFKVEZS6W55w5GYdkat6DLK5y8y5M_1796318291 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: OWZEB476JTOH5ZXTQK5DLTICMGQZLPK6 X-Message-ID-Hash: OWZEB476JTOH5ZXTQK5DLTICMGQZLPK6 X-MailFrom: lvivier@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: Laurent Vivier 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: 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 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; } @@ -3936,6 +3937,14 @@ 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 source send queue from the accepted guest data to recover + * the offset for bytes the peer had already acknowledged. + */ + conn->bytes_acked = conn->seq_from_tap - + t.sndq - + conn->seq_init_from_tap; + 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..5b37204652fa 100644 --- 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; }; /** -- 2.56.0