From b6453be585bd224451ae42dea3e1a4dc2f271d95 Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Wed, 25 Nov 2026 19:13:27 -0500 Subject: tcp_buf: Don't fill the slot reserved for duplicate ACKs with data Since commit db7fb06f710e ("tcp_buf: Always reserve slot for possible duplicate ACK flag in the same batch"), tcp_data_to_tap() flushes the batch when only one free slot is left. However, in passt mode, tcp_buf_data_from_sock() can still receive into all TCP_FRAMES_MEM buffers at once, meaning that if it gets more than TCP_FRAMES_MEM - 1 segments, tcp_data_to_tap() flushes after the second last one, and then continues with building the last frame in slot 0. This has the consequence that the last segment is forwarded to the guest with the payload of the first segment, which we just sent, instead of the one we received into the last slot. We limit the number of buffers we receive into to TCP_FRAMES_MEM - 1, so that a whole batch of data frames always fits before the reserved slot. This also fixes a clang-tidy 23 warning in tcp_buf_data_from_sock(), as the check on available slots there can now be false. Fixes: db7fb06f710e ("tcp_buf: Always reserve slot for possible duplicate ACK flag in the same batch") Signed-off-by: Jon Maloy Signed-off-by: Stefano Brivio --- tcp_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcp_buf.c b/tcp_buf.c index 0780a32..c9d675e 100644 --- a/tcp_buf.c +++ b/tcp_buf.c @@ -35,7 +35,7 @@ #define TCP_FRAMES_MEM 128 #define TCP_FRAMES \ - (c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM) + (c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM - 1) /* Static buffers */ -- cgit v1.2.3