<feed xmlns='http://www.w3.org/2005/Atom'>
<title>passt/tcp.c, branch 2026_12_04.a39d958</title>
<subtitle>Plug A Simple Socket Transport</subtitle>
<link rel='alternate' type='text/html' href='https://passt.top/passt/'/>
<entry>
<title>tcp: Don't add peers to low RTT table before RTT is measured</title>
<updated>2026-12-04T21:54:33+00:00</updated>
<author>
<name>Pietro De Domenico</name>
<email>lynxes.exe@gmail.com</email>
</author>
<published>2026-11-12T15:56:44+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=5e7a154aaaa8891afa007e111aed6d67f7680645'/>
<id>5e7a154aaaa8891afa007e111aed6d67f7680645</id>
<content type='text'>
The kernel initialises the minimum RTT of a socket to ~0U (see
tcp_init_sock() and tcp_create_openreq_child()), and tcpi_min_rtt keeps
that value until the first RTT sample.

For a passively opened socket, the handshake gives no sample if the
SYN-ACK was retransmitted (Karn's algorithm, see tcp_synack_rtt_meas()),
and the only fallback is the timestamp echo, which isn't there if the
peer didn't negotiate TCP timestamps. Windows clients don't, by default.

tcp_rtt_dst_check() casts tcpi_min_rtt to int, so ~0U becomes -1, the
peer passes the threshold check, and it's added to the low RTT table,
which it never leaves: from then on, every connection with that peer
advertises an unclamped window to the guest and stalls on
retransmissions.

Skip the check while the minimum RTT hasn't been measured yet.

Reproduced on Linux 6.18.57 by dropping SYN-ACKs at a client with
net.ipv4.tcp_timestamps set to 0, for two seconds: tcpi_min_rtt of the
accepted socket is 0xffffffff, with tcpi_total_retrans 3, and pasta
would have added the client to the table.

Link: https://archives.passt.top/passt-dev/CAJPNJUuUYSkW776P0hKmweHnKOqXtsXqwm4HXP-+jorXrSfFFg@mail.gmail.com/
Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Signed-off-by: Pietro De Domenico &lt;lynxes.exe@gmail.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The kernel initialises the minimum RTT of a socket to ~0U (see
tcp_init_sock() and tcp_create_openreq_child()), and tcpi_min_rtt keeps
that value until the first RTT sample.

For a passively opened socket, the handshake gives no sample if the
SYN-ACK was retransmitted (Karn's algorithm, see tcp_synack_rtt_meas()),
and the only fallback is the timestamp echo, which isn't there if the
peer didn't negotiate TCP timestamps. Windows clients don't, by default.

tcp_rtt_dst_check() casts tcpi_min_rtt to int, so ~0U becomes -1, the
peer passes the threshold check, and it's added to the low RTT table,
which it never leaves: from then on, every connection with that peer
advertises an unclamped window to the guest and stalls on
retransmissions.

Skip the check while the minimum RTT hasn't been measured yet.

Reproduced on Linux 6.18.57 by dropping SYN-ACKs at a client with
net.ipv4.tcp_timestamps set to 0, for two seconds: tcpi_min_rtt of the
accepted socket is 0xffffffff, with tcpi_total_retrans 3, and pasta
would have added the client to the table.

Link: https://archives.passt.top/passt-dev/CAJPNJUuUYSkW776P0hKmweHnKOqXtsXqwm4HXP-+jorXrSfFFg@mail.gmail.com/
Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Signed-off-by: Pietro De Domenico &lt;lynxes.exe@gmail.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>migrate, tcp: Account for bytes acknowledged before migration</title>
<updated>2026-12-04T21:54:33+00:00</updated>
<author>
<name>Laurent Vivier</name>
<email>lvivier@redhat.com</email>
</author>
<published>2026-12-04T12:28:02+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=1d3afa7c3a4532055bd841fcf669b89345557c87'/>
<id>1d3afa7c3a4532055bd841fcf669b89345557c87</id>
<content type='text'>
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 &lt;lvivier@redhat.com&gt;
Reviewed-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Tested-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
[sbrivio: Reworded comment in tcp_flow_migrate_target_ext()]
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;lvivier@redhat.com&gt;
Reviewed-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Tested-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
[sbrivio: Reworded comment in tcp_flow_migrate_target_ext()]
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>treewide: no L2 buffer in splice-only mode</title>
<updated>2026-12-04T21:54:18+00:00</updated>
<author>
<name>Stuart McLaren</name>
<email>stuart.mclaren@hpe.com</email>
</author>
<published>2026-12-03T17:56:24+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=66e115b7f2188dd8d49d5738959fecc540ce9727'/>
<id>66e115b7f2188dd8d49d5738959fecc540ce9727</id>
<content type='text'>
Save memory by not initializing L2 memory buffers when
running in --splice-only mode.

This reduces pasta memory use when running splice only.
For example, on one measured system, VmRSS went from
~12 MB to ~3 MB.

Signed-off-by: Stuart McLaren &lt;stuart.mclaren@hpe.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Save memory by not initializing L2 memory buffers when
running in --splice-only mode.

This reduces pasta memory use when running splice only.
For example, on one measured system, VmRSS went from
~12 MB to ~3 MB.

Signed-off-by: Stuart McLaren &lt;stuart.mclaren@hpe.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Retransmit the same SYN or SYN-ACK on handshake timeout</title>
<updated>2026-12-02T22:00:56+00:00</updated>
<author>
<name>Jon Maloy</name>
<email>jmaloy@redhat.com</email>
</author>
<published>2026-12-02T20:21:03+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=f8f340650247e97b0633a33cdb08e20f2880b36b'/>
<id>f8f340650247e97b0633a33cdb08e20f2880b36b</id>
<content type='text'>
Commit 0e8df13c96be ("tcp: Resend SYN for inbound connections") lets
tcp_timer_handler() retry the handshake for connections that are
taking too long to establish, by sending a new, bare SYN at each retry.

However, this approach has two issues:

- For connections initiated by the guest (TAP_SYN_RCVD), we send a
  SYN-ACK, not a SYN, so the retry carries the wrong flags, and lacks
  the ACK

- As tcp_prepare_flags() advances seq_to_tap for every SYN we send,
  every retry uses a different sequence number, and, once the
  handshake completes, we start sending data from the ISN plus the
  number of retries, instead of ISN + 1

If the guest acknowledges our original SYN-ACK (or SYN) after one or
more retries, for example because the ACK was held in a queue, we send
data with sequence numbers shifted by the number of retries, and, once
the retransmission timer rewinds to the acknowledged sequence, the
same data again, so that the guest assembles a corrupted stream.

Retransmit what we originally sent instead: a SYN-ACK if the guest
initiated the connection, a SYN otherwise, and reset seq_to_tap to the
initial sequence number first, which is still stored in
seq_ack_from_tap at this point.

If the guest initiated the connection, i.e. the TAP_SYN_RCVD flag is
set, we set the ACK flag in each retry, otherwise not. In both cases,
we rewind the sequence number to ISN before retransmitting.

Reported-by: Fumin &lt;awawfumin@gmail.com&gt;
Link: https://bugs.passt.top/show_bug.cgi?id=229
Fixes: 0e8df13c96be ("tcp: Resend SYN for inbound connections")
Signed-off-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 0e8df13c96be ("tcp: Resend SYN for inbound connections") lets
tcp_timer_handler() retry the handshake for connections that are
taking too long to establish, by sending a new, bare SYN at each retry.

However, this approach has two issues:

- For connections initiated by the guest (TAP_SYN_RCVD), we send a
  SYN-ACK, not a SYN, so the retry carries the wrong flags, and lacks
  the ACK

- As tcp_prepare_flags() advances seq_to_tap for every SYN we send,
  every retry uses a different sequence number, and, once the
  handshake completes, we start sending data from the ISN plus the
  number of retries, instead of ISN + 1

If the guest acknowledges our original SYN-ACK (or SYN) after one or
more retries, for example because the ACK was held in a queue, we send
data with sequence numbers shifted by the number of retries, and, once
the retransmission timer rewinds to the acknowledged sequence, the
same data again, so that the guest assembles a corrupted stream.

Retransmit what we originally sent instead: a SYN-ACK if the guest
initiated the connection, a SYN otherwise, and reset seq_to_tap to the
initial sequence number first, which is still stored in
seq_ack_from_tap at this point.

If the guest initiated the connection, i.e. the TAP_SYN_RCVD flag is
set, we set the ACK flag in each retry, otherwise not. In both cases,
we rewind the sequence number to ISN before retransmitting.

Reported-by: Fumin &lt;awawfumin@gmail.com&gt;
Link: https://bugs.passt.top/show_bug.cgi?id=229
Fixes: 0e8df13c96be ("tcp: Resend SYN for inbound connections")
Signed-off-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>icmp, tcp, udp: Change Layer-4 protocol handlers to return unsigned</title>
<updated>2026-12-02T21:59:29+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-12-01T01:23:45+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=8ce30019e739080a5a8292d567b8e48631f2f6fa'/>
<id>8ce30019e739080a5a8292d567b8e48631f2f6fa</id>
<content type='text'>
...to avoid embarrassing mistakes like the one fixed by the previous
commit: they are always supposed to return a count of consumed
packets, and handle protocol errors themselves.

Note that, strictly speaking, those should all return size_t instead
of unsigned int, but changing tcp_tap_handler() to return size_t
triggers something that looks like a false positive in Coverity Scan
which I still need to investigate.  Just fix the signedness for the
moment being.

Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
...to avoid embarrassing mistakes like the one fixed by the previous
commit: they are always supposed to return a count of consumed
packets, and handle protocol errors themselves.

Note that, strictly speaking, those should all return size_t instead
of unsigned int, but changing tcp_tap_handler() to return size_t
triggers something that looks like a false positive in Coverity Scan
which I still need to investigate.  Just fix the signedness for the
moment being.

Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Fix return value of tcp_tap_handler() on SO_PEEK_OFF failure</title>
<updated>2026-12-02T21:59:29+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-12-01T01:04:29+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=6569a6f6c94e656a04f77132f853666550b744c7'/>
<id>6569a6f6c94e656a04f77132f853666550b744c7</id>
<content type='text'>
This can't actually happen with the current kernel implementation of
SO_PEEK_OFF, but still it's rather fragile and obviously wrong:
tcp_tap_handler() should never return negative values, but that's
what the error path for tcp_rewind_seq() actually does.

For some reason, Coverity Scan spotted this only after 6637c202f261
("tap: Explicitly drop outbound IPv6 fragments, warn about them") in
combination with other recent commits.

Instead of -1, return a value corresponding to one consumed packet.

While at it, fix the comment to tcp_data_from_tap() indicating that,
there, -1 is a legitimate return value instead.

Fixes: bde1847960cf ("tcp: Fast re-transmit if half-closed, make TAP_FIN_RCVD path consistent")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This can't actually happen with the current kernel implementation of
SO_PEEK_OFF, but still it's rather fragile and obviously wrong:
tcp_tap_handler() should never return negative values, but that's
what the error path for tcp_rewind_seq() actually does.

For some reason, Coverity Scan spotted this only after 6637c202f261
("tap: Explicitly drop outbound IPv6 fragments, warn about them") in
combination with other recent commits.

Instead of -1, return a value corresponding to one consumed packet.

While at it, fix the comment to tcp_data_from_tap() indicating that,
there, -1 is a legitimate return value instead.

Fixes: bde1847960cf ("tcp: Fast re-transmit if half-closed, make TAP_FIN_RCVD path consistent")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Handle data and FIN in TAP_SYN_RCVD like in established connections</title>
<updated>2026-12-01T08:23:34+00:00</updated>
<author>
<name>Jon Maloy</name>
<email>jmaloy@redhat.com</email>
</author>
<published>2026-11-27T20:01:24+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=14b5f2b4fb561efee7e2bad55c4014c8ca76d7db'/>
<id>14b5f2b4fb561efee7e2bad55c4014c8ca76d7db</id>
<content type='text'>
In tcp_tap_handler(), the TAP_SYN_RCVD branch handles the segment
completing the handshake from the guest, but it also handles a FIN in
the same segment on its own, without checking that its sequence is the
expected one, or that the segment carries no data: on a FIN, we
increase seq_from_tap, shut down the socket for writing, send an ACK,
and return.

If the FIN is out of order, for example because it overtook the data
preceding it, we acknowledge data we never received, the server gets
an EOF without any data, and once the data arrives, we reset the
connection. If the FIN comes together with data, the data is lost. A
FIN without ACK is also accepted, as we only check for the ACK flag
afterwards. In both cases, we don't set TAP_FIN_RCVD either.

Further, if the segment is the last one in a batch, we return right
after processing the handshake, without looking at any data it might
carry: the data is neither forwarded nor acknowledged, and the guest
needs to retransmit it.

Check for the ACK flag before considering the connection established,
and only return early for a pure ACK: otherwise, let
tcp_data_from_tap() handle data and FIN, which already checks that the
FIN is in sequence, and sets TAP_FIN_RCVD, so that we shut down the
socket once all the data was forwarded.

With the reproducer attached to the bug report, which opens 100
connections through pasta with reordering on the tap interface, 34
connections end up with an empty EOF without this change, and none
with it.

Link: https://bugs.passt.top/show_bug.cgi?id=226
Reported-by: Zhenrong (Daniel) Gu &lt;zrgu@stu.xjtu.edu.cn&gt;
Reported-by: Xing Feng &lt;xingfeng@stu.xjtu.edu.cn&gt;
Reported-by: Peng Zhang &lt;p-zhang@xjtu.edu.cn&gt;
Signed-off-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In tcp_tap_handler(), the TAP_SYN_RCVD branch handles the segment
completing the handshake from the guest, but it also handles a FIN in
the same segment on its own, without checking that its sequence is the
expected one, or that the segment carries no data: on a FIN, we
increase seq_from_tap, shut down the socket for writing, send an ACK,
and return.

If the FIN is out of order, for example because it overtook the data
preceding it, we acknowledge data we never received, the server gets
an EOF without any data, and once the data arrives, we reset the
connection. If the FIN comes together with data, the data is lost. A
FIN without ACK is also accepted, as we only check for the ACK flag
afterwards. In both cases, we don't set TAP_FIN_RCVD either.

Further, if the segment is the last one in a batch, we return right
after processing the handshake, without looking at any data it might
carry: the data is neither forwarded nor acknowledged, and the guest
needs to retransmit it.

Check for the ACK flag before considering the connection established,
and only return early for a pure ACK: otherwise, let
tcp_data_from_tap() handle data and FIN, which already checks that the
FIN is in sequence, and sets TAP_FIN_RCVD, so that we shut down the
socket once all the data was forwarded.

With the reproducer attached to the bug report, which opens 100
connections through pasta with reordering on the tap interface, 34
connections end up with an empty EOF without this change, and none
with it.

Link: https://bugs.passt.top/show_bug.cgi?id=226
Reported-by: Zhenrong (Daniel) Gu &lt;zrgu@stu.xjtu.edu.cn&gt;
Reported-by: Xing Feng &lt;xingfeng@stu.xjtu.edu.cn&gt;
Reported-by: Peng Zhang &lt;p-zhang@xjtu.edu.cn&gt;
Signed-off-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Limit fast retransmit to one per loss event</title>
<updated>2026-11-30T21:20:29+00:00</updated>
<author>
<name>Anshu Kumari</name>
<email>anskuma@redhat.com</email>
</author>
<published>2026-11-30T06:44:14+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=2ac075a62864822f109b766fd474eeb9274d7431'/>
<id>2ac075a62864822f109b766fd474eeb9274d7431</id>
<content type='text'>
Every duplicate ACK unconditionally triggered a fast retransmit,
even when the ACK sequence hadn't advanced.

Guard fast retransmit on !conn-&gt;retries, and increment retries
after the first retransmit. This is a quick fix to stop the
amplification storm. Full compliance with RFC 5681 Section 3.2
(three duplicate ACKs) is left to a later patch.

As a fast retransmit is now accounted in conn-&gt;retries, the next
retransmission timeout is doubled (tcp_timer_ctl() uses conn-&gt;retries
as backoff exponent).

In TAP_FIN_RECVD path, tcp_tap_window_update() returns true for any
non-zero window because of which tcp_data_from_sock() gets called
for every ACKs(even for unchanged duplicate ACK). If the send window
is full calling tcp_data_from_sock() re-armed the retransmission
timer via conn_flag(),so periodic duplicate ACKs could delay
retransmission indefinitely and prevent a half-closed connection
from recovering. Therefore, only call tcp_data_from_sock() when
the ACK or window actually changed.

Link: https://bugs.passt.top/show_bug.cgi?id=224
Reported-by: Ada Urbaniec &lt;ada.urbaniec@gmail.com&gt;
Signed-off-by: Anshu Kumari &lt;anskuma@redhat.com&gt;
Reviewed-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Every duplicate ACK unconditionally triggered a fast retransmit,
even when the ACK sequence hadn't advanced.

Guard fast retransmit on !conn-&gt;retries, and increment retries
after the first retransmit. This is a quick fix to stop the
amplification storm. Full compliance with RFC 5681 Section 3.2
(three duplicate ACKs) is left to a later patch.

As a fast retransmit is now accounted in conn-&gt;retries, the next
retransmission timeout is doubled (tcp_timer_ctl() uses conn-&gt;retries
as backoff exponent).

In TAP_FIN_RECVD path, tcp_tap_window_update() returns true for any
non-zero window because of which tcp_data_from_sock() gets called
for every ACKs(even for unchanged duplicate ACK). If the send window
is full calling tcp_data_from_sock() re-armed the retransmission
timer via conn_flag(),so periodic duplicate ACKs could delay
retransmission indefinitely and prevent a half-closed connection
from recovering. Therefore, only call tcp_data_from_sock() when
the ACK or window actually changed.

Link: https://bugs.passt.top/show_bug.cgi?id=224
Reported-by: Ada Urbaniec &lt;ada.urbaniec@gmail.com&gt;
Signed-off-by: Anshu Kumari &lt;anskuma@redhat.com&gt;
Reviewed-by: Jon Maloy &lt;jmaloy@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>packet: Fix pool traversal for multi-iovec packets</title>
<updated>2026-11-27T02:53:53+00:00</updated>
<author>
<name>luffyluo</name>
<email>luffyluo@tencent.com</email>
</author>
<published>2026-11-26T16:56:10+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=15980a90f9a60e6ae9a3865bb85d20a3d8379deb'/>
<id>15980a90f9a60e6ae9a3865bb85d20a3d8379deb</id>
<content type='text'>
With vhost-user a guest frame can span several descriptors.  The pool
stores such a packet as a marker slot (iov_base == NULL, iov_len = N)
followed by N data slots, and packet_get() uses the marker to return
all N iovecs at once.

The traversal loops in tap4_handler(), tap6_handler(),
tcp_data_from_tap() and udp_tap_handler() don't know about markers and
advance one slot at a time: after handling the packet from its marker
they land on its first data slot, where iov_base != NULL, so
packet_get() hands back that slot alone, as if it were a whole
single-iovec packet.  Parsing that fragment as a complete frame is
what breaks: in tcp_data_from_tap() a fragment shorter than a TCP
header makes IOV_PEEK_HEADER() fail ("TCP header not contiguous"), and
a longer one gives a th-&gt;doff read from payload bytes, so
off = th-&gt;doff * 4 exceeds the fragment length.  In udp_tap_handler()
the fragments go out as extra datagrams.

Fix it with packet_next(), returning the index of the packet following
the one at a given index, and use it to advance those loops, so they
skip the data slots of the packet they just handled.  For single-iovec
packets it returns idx + 1, so tap and pasta, which always build
single-iovec tails with IOV_TAIL_FROM_BUF(), are unaffected.

Fixes: ca38be0141d1 ("packet: Add support for multi-vector packets")
Signed-off-by: luffyluo &lt;luffyluo@tencent.com&gt;
[lvivier: Fix multi-iovec return values and TCP reordering scan restart]
Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
[sbrivio: Minor style fixes]
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With vhost-user a guest frame can span several descriptors.  The pool
stores such a packet as a marker slot (iov_base == NULL, iov_len = N)
followed by N data slots, and packet_get() uses the marker to return
all N iovecs at once.

The traversal loops in tap4_handler(), tap6_handler(),
tcp_data_from_tap() and udp_tap_handler() don't know about markers and
advance one slot at a time: after handling the packet from its marker
they land on its first data slot, where iov_base != NULL, so
packet_get() hands back that slot alone, as if it were a whole
single-iovec packet.  Parsing that fragment as a complete frame is
what breaks: in tcp_data_from_tap() a fragment shorter than a TCP
header makes IOV_PEEK_HEADER() fail ("TCP header not contiguous"), and
a longer one gives a th-&gt;doff read from payload bytes, so
off = th-&gt;doff * 4 exceeds the fragment length.  In udp_tap_handler()
the fragments go out as extra datagrams.

Fix it with packet_next(), returning the index of the packet following
the one at a given index, and use it to advance those loops, so they
skip the data slots of the packet they just handled.  For single-iovec
packets it returns idx + 1, so tap and pasta, which always build
single-iovec tails with IOV_TAIL_FROM_BUF(), are unaffected.

Fixes: ca38be0141d1 ("packet: Add support for multi-vector packets")
Signed-off-by: luffyluo &lt;luffyluo@tencent.com&gt;
[lvivier: Fix multi-iovec return values and TCP reordering scan restart]
Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
[sbrivio: Minor style fixes]
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Keep window from tap below MAX_WINDOW</title>
<updated>2026-11-24T10:39:56+00:00</updated>
<author>
<name>Jason Chu</name>
<email>jaschu@janestreet.com</email>
</author>
<published>2026-11-23T21:16:00+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=0b9abe75043cfed0d92b14e4f34e42ade9ee4221'/>
<id>0b9abe75043cfed0d92b14e4f34e42ade9ee4221</id>
<content type='text'>
In tcp_internal.h, SEQ_GE(a, b) checks
(uint32_t)(a) - (uint32_t)(b) &lt; MAX_WINDOW, so a sequence number
exactly MAX_WINDOW (16 MiB) ahead is treated as out of range.

tcp_tap_window_update() clamps the advertised window from tap to
MAX_WINDOW inclusive, and pasta sends up to that full window. If the
peer negotiates a window scale above MAX_WS (9 to 14) and advertises
at least 16 MiB, pasta can put exactly MAX_WINDOW bytes in flight.
When the peer acknowledges all of them in one ACK, tcp_data_from_tap()
fails SEQ_GE(ack_seq, conn-&gt;seq_ack_from_tap) and ignores the ACK.
pasta then rewinds on each ACK timeout and retransmits the same 16 MiB,
which the peer drops as duplicate data while repeating the same ACK,
so the connection stalls.

We hit this on Linux with a raised net.ipv4.tcp_rmem maximum (and it
also reproduces via SO_RCVBUF) when the receiver pauses while more
than 16 MiB arrives. In that case the kernel only sends a delayed ACK,
and pasta delivers all 16 MiB before the delayed ACK timer fires.
With a 6 MiB tcp_rmem maximum, the default on older kernels, the peer
uses a window scale of 7 and the window never reaches 16 MiB. Current
kernels default to up to 32 MiB, which we haven't tested.

Clamp the window in tcp_tap_window_update() to MAX_WINDOW - 1 instead.
For window scales 9 to 14, the right shift rounds the stored window
down by one scale unit, keeping every valid ACK within SEQ_GE() range.
Window scales up to MAX_WS cannot represent MAX_WINDOW anyway.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Jason Chu &lt;jaschu@janestreet.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In tcp_internal.h, SEQ_GE(a, b) checks
(uint32_t)(a) - (uint32_t)(b) &lt; MAX_WINDOW, so a sequence number
exactly MAX_WINDOW (16 MiB) ahead is treated as out of range.

tcp_tap_window_update() clamps the advertised window from tap to
MAX_WINDOW inclusive, and pasta sends up to that full window. If the
peer negotiates a window scale above MAX_WS (9 to 14) and advertises
at least 16 MiB, pasta can put exactly MAX_WINDOW bytes in flight.
When the peer acknowledges all of them in one ACK, tcp_data_from_tap()
fails SEQ_GE(ack_seq, conn-&gt;seq_ack_from_tap) and ignores the ACK.
pasta then rewinds on each ACK timeout and retransmits the same 16 MiB,
which the peer drops as duplicate data while repeating the same ACK,
so the connection stalls.

We hit this on Linux with a raised net.ipv4.tcp_rmem maximum (and it
also reproduces via SO_RCVBUF) when the receiver pauses while more
than 16 MiB arrives. In that case the kernel only sends a delayed ACK,
and pasta delivers all 16 MiB before the delayed ACK timer fires.
With a 6 MiB tcp_rmem maximum, the default on older kernels, the peer
uses a window scale of 7 and the window never reaches 16 MiB. Current
kernels default to up to 32 MiB, which we haven't tested.

Clamp the window in tcp_tap_window_update() to MAX_WINDOW - 1 instead.
For window scales 9 to 14, the right shift rounds the stored window
down by one scale unit, keeping every valid ACK within SEQ_GE() range.
Window scales up to MAX_WS cannot represent MAX_WINDOW anyway.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Jason Chu &lt;jaschu@janestreet.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
