* [PATCH] tcp_buf: Don't fill the slot reserved for duplicate ACKs with data
@ 2026-11-26 0:13 Jon Maloy
2026-11-27 8:29 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Jon Maloy @ 2026-11-26 0:13 UTC (permalink / raw)
To: sbrivio, david, jmaloy, passt-dev
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 <jmaloy@redhat.com>
---
tcp_buf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tcp_buf.c b/tcp_buf.c
index 0780a327..c9d675e3 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 */
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] tcp_buf: Don't fill the slot reserved for duplicate ACKs with data
2026-11-26 0:13 [PATCH] tcp_buf: Don't fill the slot reserved for duplicate ACKs with data Jon Maloy
@ 2026-11-27 8:29 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2026-11-27 8:29 UTC (permalink / raw)
To: Jon Maloy; +Cc: david, passt-dev
On Wed, 25 Nov 2026 19:13:27 -0500
Jon Maloy <jmaloy@redhat.com> wrote:
> 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")
Whoops.
> Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Applied.
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 8:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 0:13 [PATCH] tcp_buf: Don't fill the slot reserved for duplicate ACKs with data Jon Maloy
2026-11-27 8:29 ` 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).