<feed xmlns='http://www.w3.org/2005/Atom'>
<title>passt/tcp_conn.h, 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>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>tcp: Avoid division by zero with small MSS values</title>
<updated>2026-11-10T22:35:59+00:00</updated>
<author>
<name>Anshu Kumari</name>
<email>anskuma@redhat.com</email>
</author>
<published>2026-10-26T11:18:20+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=943f29f82ada14b7d540ee1634060bd6be0d62b7'/>
<id>943f29f82ada14b7d540ee1634060bd6be0d62b7</id>
<content type='text'>
Fuzz testing with AFL++ persistent mode found that
tcp_buf_data_from_sock() terminates the process with SIGFPE
(signal 8) from division by zero at:

  fill_bufs = DIV_ROUND_UP(wnd_scaled - already_sent, mss);

when MSS is small enough (less than four) to round down to 0
during the bit-shift in MSS_SET(). The termination itself is
clean (not memory corruption or data leakage), but we can
handle this condition more gracefully.

We considered resetting connections with a zero or very low
MSS, but concluded this is not RFC-compliant: RFC 9293,
section 3.1 (MUST-7), states: "TCP implementations MUST be
prepared to handle an illegal option length (e.g., zero); a
suggested procedure is to reset the connection and log the
error cause." However, this applies only to option *lengths*,
not *values* — no standard RFC defines a minimum MSS value.
Section 3.5.2 further states: "A reset must not be sent if
it is not clear that this is the case." Very low MSS values
also have legitimate uses in microcontroller applications
with limited buffers, and a zero MSS could represent a
unidirectional connection.

Rounding a low MSS upward is also not an option: emitting
segments larger than the peer advertised violates the
effective send MSS requirement in RFC 9293, section 3.7.1.

Instead, preserve the actual MSS:

  - Adjust MSS_SET() to clamp non-zero values below 4 to 1,
    avoiding the round-to-zero in bit-field storage.
  - Adjust MSS_GET() to return 1 when tap_mss is 1, so we
    never inflate the MSS beyond what the peer advertised.
  - When MSS is zero, don't send data:
    tcp_buf_data_from_sock() returns early. The peer will
    eventually determine the connection is unusable and
    reset it.

Signed-off-by: Anshu Kumari &lt;anskuma@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>
Fuzz testing with AFL++ persistent mode found that
tcp_buf_data_from_sock() terminates the process with SIGFPE
(signal 8) from division by zero at:

  fill_bufs = DIV_ROUND_UP(wnd_scaled - already_sent, mss);

when MSS is small enough (less than four) to round down to 0
during the bit-shift in MSS_SET(). The termination itself is
clean (not memory corruption or data leakage), but we can
handle this condition more gracefully.

We considered resetting connections with a zero or very low
MSS, but concluded this is not RFC-compliant: RFC 9293,
section 3.1 (MUST-7), states: "TCP implementations MUST be
prepared to handle an illegal option length (e.g., zero); a
suggested procedure is to reset the connection and log the
error cause." However, this applies only to option *lengths*,
not *values* — no standard RFC defines a minimum MSS value.
Section 3.5.2 further states: "A reset must not be sent if
it is not clear that this is the case." Very low MSS values
also have legitimate uses in microcontroller applications
with limited buffers, and a zero MSS could represent a
unidirectional connection.

Rounding a low MSS upward is also not an option: emitting
segments larger than the peer advertised violates the
effective send MSS requirement in RFC 9293, section 3.7.1.

Instead, preserve the actual MSS:

  - Adjust MSS_SET() to clamp non-zero values below 4 to 1,
    avoiding the round-to-zero in bit-field storage.
  - Adjust MSS_GET() to return 1 when tap_mss is 1, so we
    never inflate the MSS beyond what the peer advertised.
  - When MSS is zero, don't send data:
    tcp_buf_data_from_sock() returns early. The peer will
    eventually determine the connection is unusable and
    reset it.

Signed-off-by: Anshu Kumari &lt;anskuma@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>flow, treewide: Promote priority of selected flow-linked messages</title>
<updated>2026-06-22T07:13:46+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-06-19T15:26:25+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=74863b01d304beda59d7a7bc9cfa887683fedd95'/>
<id>74863b01d304beda59d7a7bc9cfa887683fedd95</id>
<content type='text'>
Most of out flow specific log messages are debug level for fear of flooding
the logs, even when they report real error conditions that might be off
significance.

Now that we have the mechanisms for log message rate limiting, we can do
better.  Promote many flow related messages to warning or error level, with
rate limiting.  While we're there add ratelimiting to a handful of existing
warning or error level messages.

They general heuristic is to promote messages that report a failure which
is not something that should be triggered by the guest doing something
weird.  This mostly means failures from socket operations we expect to be
legitimate.

Adding the ratelimiting means plumbing the 'now' timestamp through much
more of the code, hence the large churn.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Most of out flow specific log messages are debug level for fear of flooding
the logs, even when they report real error conditions that might be off
significance.

Now that we have the mechanisms for log message rate limiting, we can do
better.  Promote many flow related messages to warning or error level, with
rate limiting.  While we're there add ratelimiting to a handful of existing
warning or error level messages.

They general heuristic is to promote messages that report a failure which
is not something that should be triggered by the guest doing something
weird.  This mostly means failures from socket operations we expect to be
legitimate.

Adding the ratelimiting means plumbing the 'now' timestamp through much
more of the code, hence the large churn.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp, tcp_splice: Make helper for setting SO_LINGER socket option</title>
<updated>2026-05-27T08:17:18+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-05-13T07:18:20+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=98e3c015b3791ff55381e5ee687f541721d1695e'/>
<id>98e3c015b3791ff55381e5ee687f541721d1695e</id>
<content type='text'>
Both spliced and non-spliced TCP in some cases set the SO_LINGER socket
option in order to to force a TCP RST on a socket side connection.  In each
case we open code the setsockopt() logic.  We're shortly going to add
another place that needs this, so move the setsockopt() and error handling
logic into a shared helper.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Both spliced and non-spliced TCP in some cases set the SO_LINGER socket
option in order to to force a TCP RST on a socket side connection.  In each
case we open code the setsockopt() logic.  We're shortly going to add
another place that needs this, so move the setsockopt() and error handling
logic into a shared helper.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp_splice: Simplify tracking of read/written bytes</title>
<updated>2026-05-26T10:21:49+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-05-21T06:37:45+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=da0096964cb79752ef152f7d760b3f27997fc59d'/>
<id>da0096964cb79752ef152f7d760b3f27997fc59d</id>
<content type='text'>
For each each direction of each spliced connection, we keep track of how
many bytes we've read from one socket and written to the other.  However,
we never actually care about the absolute values of these, only the
difference between them, which represents how much data is currently "in
flight" in the splicing pipe.

Simplify the handling by having a single variable tracking the number of
bytes in the pipe.

As a bonus, the new scheme makes it clearer that we don't need to worry
about overflows: pending can never become larger than the maximum pipe
bufffer size, well within 32-bits.

I _think_ the old scheme was safe in the case of overflow - again under
the assumption that read/written can never be further apart than the pipe
buffer size.  However, it's much harder to reason about this case.  It's
certainly plausible that an overflow could occur - sending 4GiB through
a local socket is entirely achievable.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For each each direction of each spliced connection, we keep track of how
many bytes we've read from one socket and written to the other.  However,
we never actually care about the absolute values of these, only the
difference between them, which represents how much data is currently "in
flight" in the splicing pipe.

Simplify the handling by having a single variable tracking the number of
bytes in the pipe.

As a bonus, the new scheme makes it clearer that we don't need to worry
about overflows: pending can never become larger than the maximum pipe
bufffer size, well within 32-bits.

I _think_ the old scheme was safe in the case of overflow - again under
the assumption that read/written can never be further apart than the pipe
buffer size.  However, it's much harder to reason about this case.  It's
certainly plausible that an overflow could occur - sending 4GiB through
a local socket is entirely achievable.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Use SO_MEMINFO for accurate send buffer overhead accounting</title>
<updated>2026-05-07T06:03:14+00:00</updated>
<author>
<name>Jon Maloy</name>
<email>jmaloy@redhat.com</email>
</author>
<published>2026-04-25T19:58:18+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=a458719f01838f0d5867e817d84a497637999ee1'/>
<id>a458719f01838f0d5867e817d84a497637999ee1</id>
<content type='text'>
The TCP window advertised to the guest/container must balance two
competing needs: large enough to trigger kernel socket buffer
auto-tuning, but not so large that sendmsg() partially fails, causing
retransmissions.

The current approach uses the difference (SNDBUF_GET() - SIOCOUTQ), but
SNDBUF_GET() returns a scaled value that only roughly accounts for
per-skb overhead. The clamped_scale approximation doesn't accurately
track the actual per-segment overhead, which can lead to both excessive
retransmissions and reduced throughput.

We now introduce the use of SO_MEMINFO to obtain SK_MEMINFO_SNDBUF and
SK_MEMINFO_WMEM_QUEUED from the kernel. The latter is presented in the
kernel's own accounting units, i.e. including the sk_buff overhead,
and matches exactly what the kernel's own sk_stream_memory_free()
function is using.

When data is queued and the overhead ratio is observable, we calculate
the per-segment overhead as (wmem_queued - sendq) / num_segments, then
determine how many additional segments should fit in the remaining
buffer space, considering the calculated per-mss overhead. This approach
treats segments as discrete quantities, and produces a more accurate
estimate of available buffer space than a linear scaling factor does.

When the ratio cannot be observed, e.g. because the queue is empty or
we are in a transient state, we fall back to the existing clamped_scale
calculation (scaling between 100% and 75% of buffer capacity).

When SO_MEMINFO succeeds, we also use SK_MEMINFO_SNDBUF directly to
set SNDBUF, avoiding a separate SO_SNDBUF getsockopt() call.

If SO_MEMINFO is unavailable, we fall back to the pre-existing
SNDBUF_GET() - SIOCOUTQ calculation.

Link: https://bugs.passt.top/show_bug.cgi?id=138
Link: https://github.com/containers/podman/issues/28219
Analysed-by: Yumei Huang &lt;yuhuang@redhat.com&gt;
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>
The TCP window advertised to the guest/container must balance two
competing needs: large enough to trigger kernel socket buffer
auto-tuning, but not so large that sendmsg() partially fails, causing
retransmissions.

The current approach uses the difference (SNDBUF_GET() - SIOCOUTQ), but
SNDBUF_GET() returns a scaled value that only roughly accounts for
per-skb overhead. The clamped_scale approximation doesn't accurately
track the actual per-segment overhead, which can lead to both excessive
retransmissions and reduced throughput.

We now introduce the use of SO_MEMINFO to obtain SK_MEMINFO_SNDBUF and
SK_MEMINFO_WMEM_QUEUED from the kernel. The latter is presented in the
kernel's own accounting units, i.e. including the sk_buff overhead,
and matches exactly what the kernel's own sk_stream_memory_free()
function is using.

When data is queued and the overhead ratio is observable, we calculate
the per-segment overhead as (wmem_queued - sendq) / num_segments, then
determine how many additional segments should fit in the remaining
buffer space, considering the calculated per-mss overhead. This approach
treats segments as discrete quantities, and produces a more accurate
estimate of available buffer space than a linear scaling factor does.

When the ratio cannot be observed, e.g. because the queue is empty or
we are in a transient state, we fall back to the existing clamped_scale
calculation (scaling between 100% and 75% of buffer capacity).

When SO_MEMINFO succeeds, we also use SK_MEMINFO_SNDBUF directly to
set SNDBUF, avoiding a separate SO_SNDBUF getsockopt() call.

If SO_MEMINFO is unavailable, we fall back to the pre-existing
SNDBUF_GET() - SIOCOUTQ calculation.

Link: https://bugs.passt.top/show_bug.cgi?id=138
Link: https://github.com/containers/podman/issues/28219
Analysed-by: Yumei Huang &lt;yuhuang@redhat.com&gt;
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>tcp: Avoid comparison of expressions with different signedness in RTT_SET()</title>
<updated>2026-03-10T14:25:05+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-03-06T07:02:35+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=994bb76578645d181d315e4001d5fc0dfc92fcf6'/>
<id>994bb76578645d181d315e4001d5fc0dfc92fcf6</id>
<content type='text'>
With gcc 14.2, building against musl 1.2.5 (slightly outdated Alpine
on x86_64):

tcp.c: In function 'tcp_update_seqack_wnd':
util.h:40:39: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   40 | #define MIN(x, y)               (((x) &lt; (y)) ? (x) : (y))
      |                                       ^
tcp_conn.h:63:26: note: in expansion of macro 'MIN'
   63 |         (conn-&gt;rtt_exp = MIN(RTT_EXP_MAX, ilog2(MAX(1, rtt / RTT_STORE_MIN))))
      |                          ^~~
tcp.c:1234:17: note: in expansion of macro 'RTT_SET'
 1234 |                 RTT_SET(conn, tinfo-&gt;tcpi_rtt);
      |                 ^~~~~~~
util.h:40:54: warning: operand of '?:' changes signedness from 'int' to 'unsigned int' due to unsignedness of other operand [-Wsign-compare]
   40 | #define MIN(x, y)               (((x) &lt; (y)) ? (x) : (y))
      |                                                      ^~~
tcp_conn.h:63:26: note: in expansion of macro 'MIN'
   63 |         (conn-&gt;rtt_exp = MIN(RTT_EXP_MAX, ilog2(MAX(1, rtt / RTT_STORE_MIN))))
      |                          ^~~
tcp.c:1234:17: note: in expansion of macro 'RTT_SET'
 1234 |                 RTT_SET(conn, tinfo-&gt;tcpi_rtt);
      |                 ^~~~~~~

for some reason, that's not reported by gcc with glibc.

Cast the result of ilog2() to unsigned before using it, and introduce
0 as lower bound, to make it obvious that we expect the argument to be
always valid, the way we're using it.

Suggested-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Fixes: 000601ba86da ("tcp: Adaptive interval based on RTT for socket-side acknowledgement checks")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
Reviewed-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With gcc 14.2, building against musl 1.2.5 (slightly outdated Alpine
on x86_64):

tcp.c: In function 'tcp_update_seqack_wnd':
util.h:40:39: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   40 | #define MIN(x, y)               (((x) &lt; (y)) ? (x) : (y))
      |                                       ^
tcp_conn.h:63:26: note: in expansion of macro 'MIN'
   63 |         (conn-&gt;rtt_exp = MIN(RTT_EXP_MAX, ilog2(MAX(1, rtt / RTT_STORE_MIN))))
      |                          ^~~
tcp.c:1234:17: note: in expansion of macro 'RTT_SET'
 1234 |                 RTT_SET(conn, tinfo-&gt;tcpi_rtt);
      |                 ^~~~~~~
util.h:40:54: warning: operand of '?:' changes signedness from 'int' to 'unsigned int' due to unsignedness of other operand [-Wsign-compare]
   40 | #define MIN(x, y)               (((x) &lt; (y)) ? (x) : (y))
      |                                                      ^~~
tcp_conn.h:63:26: note: in expansion of macro 'MIN'
   63 |         (conn-&gt;rtt_exp = MIN(RTT_EXP_MAX, ilog2(MAX(1, rtt / RTT_STORE_MIN))))
      |                          ^~~
tcp.c:1234:17: note: in expansion of macro 'RTT_SET'
 1234 |                 RTT_SET(conn, tinfo-&gt;tcpi_rtt);
      |                 ^~~~~~~

for some reason, that's not reported by gcc with glibc.

Cast the result of ilog2() to unsigned before using it, and introduce
0 as lower bound, to make it obvious that we expect the argument to be
always valid, the way we're using it.

Suggested-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Fixes: 000601ba86da ("tcp: Adaptive interval based on RTT for socket-side acknowledgement checks")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
Reviewed-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add missing includes to headers</title>
<updated>2026-03-04T16:39:57+00:00</updated>
<author>
<name>Peter Foley</name>
<email>pefoley@google.com</email>
</author>
<published>2026-02-23T18:11:19+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=adbf5c135f19db5b6751393b7f5cbf516031bde8'/>
<id>adbf5c135f19db5b6751393b7f5cbf516031bde8</id>
<content type='text'>
Support build systems like bazel that check that headers are
self-contained.

Also update includes so that clang-include-cleaner succeeds.

Tested with:
clang-include-cleaner-19 --extra-arg=-D_GNU_SOURCE --extra-arg=-DPAGE_SIZE=4096 --extra-arg=-DVERSION=\"git\" --extra-arg=-DHAS_GETRANDOM *.h *.c

Signed-off-by: Peter Foley &lt;pefoley@google.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>
Support build systems like bazel that check that headers are
self-contained.

Also update includes so that clang-include-cleaner succeeds.

Tested with:
clang-include-cleaner-19 --extra-arg=-D_GNU_SOURCE --extra-arg=-DPAGE_SIZE=4096 --extra-arg=-DVERSION=\"git\" --extra-arg=-DHAS_GETRANDOM *.h *.c

Signed-off-by: Peter Foley &lt;pefoley@google.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Send TCP keepalive segments after a period of tap-side inactivity</title>
<updated>2026-02-24T23:17:45+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-02-04T11:41:37+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=d2f7c21cfb949f2b1587b9475917efdd6ac549fd'/>
<id>d2f7c21cfb949f2b1587b9475917efdd6ac549fd</id>
<content type='text'>
There are several circumstances in which a live, but idle TCP connection
can be forgotten by a guest, with no "on the wire" indication that this has
happened.  The most obvious is if the guest abruptly reboots.  A more
subtle case can happen with a half-closed connection, specifically one
in FIN_WAIT_2 state on the guest.  A connection can, legitimately, remain
in this state indefinitely.  If however, a socket in this state is closed
by userspace, Linux at least will remove the kernel socket after 60s
(or as configured in the net.ipv4.tcp_fin_timeout sysctl).

Because there's no on the wire indication in these cases, passt will
pointlessly retain the connection in its flow table, at least until it is
removed by the inactivity timeout after several hours.

To avoid keeping connections around for so long in this state, add
functionality to periodically send TCP keepalive segments to the guest if
we've seen no activity on the tap interface.  If the guest is no longer
aware of the connection, it should respond with an RST which will let
passt remove the stale entry.

To do this we use a method similar to the inactivity timeout - a 1-bit
page replacement / clock algorithm, but with a shorter interval, and only
checking for tap side activity.  Currently we use a 300s interval, meaning
we'll send a keepalive after 5-10 minutes of (tap side) inactivity.

Link: https://bugs.passt.top/show_bug.cgi?id=179
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are several circumstances in which a live, but idle TCP connection
can be forgotten by a guest, with no "on the wire" indication that this has
happened.  The most obvious is if the guest abruptly reboots.  A more
subtle case can happen with a half-closed connection, specifically one
in FIN_WAIT_2 state on the guest.  A connection can, legitimately, remain
in this state indefinitely.  If however, a socket in this state is closed
by userspace, Linux at least will remove the kernel socket after 60s
(or as configured in the net.ipv4.tcp_fin_timeout sysctl).

Because there's no on the wire indication in these cases, passt will
pointlessly retain the connection in its flow table, at least until it is
removed by the inactivity timeout after several hours.

To avoid keeping connections around for so long in this state, add
functionality to periodically send TCP keepalive segments to the guest if
we've seen no activity on the tap interface.  If the guest is no longer
aware of the connection, it should respond with an RST which will let
passt remove the stale entry.

To do this we use a method similar to the inactivity timeout - a 1-bit
page replacement / clock algorithm, but with a shorter interval, and only
checking for tap side activity.  Currently we use a 300s interval, meaning
we'll send a keepalive after 5-10 minutes of (tap side) inactivity.

Link: https://bugs.passt.top/show_bug.cgi?id=179
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: Re-introduce inactivity timeouts based on a clock algorithm</title>
<updated>2026-02-24T23:17:38+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-02-04T11:41:35+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=1820103fbbf13df98257a3f5c3ba625de624b0b3'/>
<id>1820103fbbf13df98257a3f5c3ba625de624b0b3</id>
<content type='text'>
We previously had a mechanism to remove TCP connections which were
inactive for 2 hours.  That was broken for a long time, due to poor
interactions with the timerfd handling, so we removed it.

Adding this long scale timer onto the timerfd handling, which mostly
handles much shorter timeouts is tricky to reason about.  However, for the
inactivity timeouts, we don't require precision.  Instead, we can use
a 1-bit page replacement / "clock" algorithm.  Every INACTIVITY_INTERVAL
(2 hours), a global timer marks every TCP connection as tentatively
inactive.  That flag is cleared if we get any events, either tap side or
socket side.

If the inactive flag is still set when the next INACTIVITY_INTERVAL expires
then the connection has been inactive for an extended period and we reset
and close it.  In practice this means that connections will be removed
after 2-4 hours of inactivity.

This is not a true fix for bug 179, but it does mitigate the damage, by
limiting the time that inactive connections will remain around,

Link: https://bugs.passt.top/show_bug.cgi?id=179
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We previously had a mechanism to remove TCP connections which were
inactive for 2 hours.  That was broken for a long time, due to poor
interactions with the timerfd handling, so we removed it.

Adding this long scale timer onto the timerfd handling, which mostly
handles much shorter timeouts is tricky to reason about.  However, for the
inactivity timeouts, we don't require precision.  Instead, we can use
a 1-bit page replacement / "clock" algorithm.  Every INACTIVITY_INTERVAL
(2 hours), a global timer marks every TCP connection as tentatively
inactive.  That flag is cleared if we get any events, either tap side or
socket side.

If the inactive flag is still set when the next INACTIVITY_INTERVAL expires
then the connection has been inactive for an extended period and we reset
and close it.  In practice this means that connections will be removed
after 2-4 hours of inactivity.

This is not a true fix for bug 179, but it does mitigate the damage, by
limiting the time that inactive connections will remain around,

Link: https://bugs.passt.top/show_bug.cgi?id=179
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
