<feed xmlns='http://www.w3.org/2005/Atom'>
<title>passt/udp.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>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>udp: Flush socket errors even after an intervening recvmmsg() clears the code</title>
<updated>2026-12-03T01:22:24+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-12-03T01:22:24+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=111029829f8761cd0ccd7c5f8648ad0e9527841b'/>
<id>111029829f8761cd0ccd7c5f8648ad0e9527841b</id>
<content type='text'>
Gonzalo reports that if a socket error occurs (for example, due to an
ICMP message) between udp_sock_errs() and a subsequent recvmmsg()
call, coming from udp_sock_recv(), the recvmmsg() call will clear the
socket error code, but not the queue.

At this point, once we're done handling the socket events, EPOLLERR is
still set, so udp_listen_sock_handler(), and, in turn, udp_sock_fwd(),
will be called again, but the recvmsg() call in udp_peek_addr() won't
report any actual error (rather EAGAIN).

As a result, we won't call udp_sock_errs() and leave the error in the
queue.  This leads to a event processing loop, until a further error
is reported.

This is a consequence of 04984578b00f ("udp: Deal with errors as we go
in udp_sock_fwd()"): earlier, udp_sock_errs() would be called on any
EPOLLERR event.  But now that we clear errors as we iterate through
udp_peek_addr() calls, we don't necessarily do that anymore.

This part is still desirable, so, instead of going back to an initial
out-of-order call to udp_sock_errs() on EPOLLERR, keep the processing
order as it is, but make sure that we'll call udp_sock_errs() at least
once per event handling cycle, whenever EPOLLERR was set on the
socket.

This way, if the error code vanished because of an intervening
recvmmsg() call, we will still be able to clear queued errors.

Link: https://bugs.passt.top/show_bug.cgi?id=228
Reported-by: Gonzalo Rivas Valenzuela &lt;grv@jessica.cl&gt;
Fixes: 04984578b00f ("udp: Deal with errors as we go in udp_sock_fwd()"
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Gonzalo reports that if a socket error occurs (for example, due to an
ICMP message) between udp_sock_errs() and a subsequent recvmmsg()
call, coming from udp_sock_recv(), the recvmmsg() call will clear the
socket error code, but not the queue.

At this point, once we're done handling the socket events, EPOLLERR is
still set, so udp_listen_sock_handler(), and, in turn, udp_sock_fwd(),
will be called again, but the recvmsg() call in udp_peek_addr() won't
report any actual error (rather EAGAIN).

As a result, we won't call udp_sock_errs() and leave the error in the
queue.  This leads to a event processing loop, until a further error
is reported.

This is a consequence of 04984578b00f ("udp: Deal with errors as we go
in udp_sock_fwd()"): earlier, udp_sock_errs() would be called on any
EPOLLERR event.  But now that we clear errors as we iterate through
udp_peek_addr() calls, we don't necessarily do that anymore.

This part is still desirable, so, instead of going back to an initial
out-of-order call to udp_sock_errs() on EPOLLERR, keep the processing
order as it is, but make sure that we'll call udp_sock_errs() at least
once per event handling cycle, whenever EPOLLERR was set on the
socket.

This way, if the error code vanished because of an intervening
recvmmsg() call, we will still be able to clear queued errors.

Link: https://bugs.passt.top/show_bug.cgi?id=228
Reported-by: Gonzalo Rivas Valenzuela &lt;grv@jessica.cl&gt;
Fixes: 04984578b00f ("udp: Deal with errors as we go in udp_sock_fwd()"
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>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>udp: Improve messages for errors getting errors</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:26+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=edeb2a26c663085b3eae0a7eac6eb011a21ae7c3'/>
<id>edeb2a26c663085b3eae0a7eac6eb011a21ae7c3</id>
<content type='text'>
If udp_sock_recverr() gets an error retrieving the error queue, or
udp_sock_errs() gets an error reading the SO_ERROR sockopt, we log a
message with err_perror(),

That severity is reasonable - this is something going unexpectedly wrong
host side, not merely a connection getting shut down because we hit a
network error.  However, the messages can be made more useful by linking
them to the specific flow, and safer by ratelimiting them.

Remove the places where we included the numerical value of the socket fd:
that's rarely useful, especially now that we have the context about the
flow the fd belonged to.

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>
If udp_sock_recverr() gets an error retrieving the error queue, or
udp_sock_errs() gets an error reading the SO_ERROR sockopt, we log a
message with err_perror(),

That severity is reasonable - this is something going unexpectedly wrong
host side, not merely a connection getting shut down because we hit a
network error.  However, the messages can be made more useful by linking
them to the specific flow, and safer by ratelimiting them.

Remove the places where we included the numerical value of the socket fd:
that's rarely useful, especially now that we have the context about the
flow the fd belonged to.

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>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>flow: Include flow details with higher priority log 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:23+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=780ba8a55feb99feb11c3277b2cb7d3222ec7872'/>
<id>780ba8a55feb99feb11c3277b2cb7d3222ec7872</id>
<content type='text'>
Currently flow_log() and related functions / macros have a 'details'
parameter which indicates whether to add extra messages with details of the
flow's addresses.  This is still a bit awkward to invoke, and only used in
a few places.  Change the logic, to automatically include the details if
and only if the log priority is greater than LOG_DEBUG.

Rationale:

If at debug log level, there are already a bunch of debug messages tracking
the flow life cycle, which include those details (we make sure to retain
those).  It's usually pretty easy to cross reference a specific flow debug
message with the flow's history including the details.

If at higher log level, and we generate a flow-connected error or warning
we don't have those life cycle messages.  So, just giving the flow index
doesn't really tell you anything about which flow tripped the error.
Adding the address details make the error message significantly more
useful.

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>
Currently flow_log() and related functions / macros have a 'details'
parameter which indicates whether to add extra messages with details of the
flow's addresses.  This is still a bit awkward to invoke, and only used in
a few places.  Change the logic, to automatically include the details if
and only if the log priority is greater than LOG_DEBUG.

Rationale:

If at debug log level, there are already a bunch of debug messages tracking
the flow life cycle, which include those details (we make sure to retain
those).  It's usually pretty easy to cross reference a specific flow debug
message with the flow's history including the details.

If at higher log level, and we generate a flow-connected error or warning
we don't have those life cycle messages.  So, just giving the flow index
doesn't really tell you anything about which flow tripped the error.
Adding the address details make the error message significantly more
useful.

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>flow: Regularise flow specific logging helpers</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:21+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=d66a3f18138f94a3a7f8674d75551e7a844a1308'/>
<id>d66a3f18138f94a3a7f8674d75551e7a844a1308</id>
<content type='text'>
flow.h has a collection of logging helpers that automatically include
information about a specific flow.  Which variants are present are a bit
ad-hoc, based on what we happened to want use (e.g. there are no
LOG_WARNING level versions, at present).  There's also a rather awkward
and only occasionally used flow_log_details_() helper to print additional
log messages with more details of the flow (basically its addresses).
It's particularly awkward to try to combine that with ratelimiting.

Re-organise this to be based around a flow_log__() internal helper, which
has bool parameters to include strerror() / perror information and/or
the extra details.  Add wrapper macros for all combinations of perror,
ratelimiting and DEBUG/WARNING/ERR priorities.

Be a little more consistent about parameter order between the various
functions / macros / wrappers while we're at it.

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>
flow.h has a collection of logging helpers that automatically include
information about a specific flow.  Which variants are present are a bit
ad-hoc, based on what we happened to want use (e.g. there are no
LOG_WARNING level versions, at present).  There's also a rather awkward
and only occasionally used flow_log_details_() helper to print additional
log messages with more details of the flow (basically its addresses).
It's particularly awkward to try to combine that with ratelimiting.

Re-organise this to be based around a flow_log__() internal helper, which
has bool parameters to include strerror() / perror information and/or
the extra details.  Add wrapper macros for all combinations of perror,
ratelimiting and DEBUG/WARNING/ERR priorities.

Be a little more consistent about parameter order between the various
functions / macros / wrappers while we're at it.

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>fwd, pif: Remove duplicated logic between tcp_listen() and udp_listen()</title>
<updated>2026-06-16T21:49:57+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-06-16T01:09:35+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=50e3dcc44074dea26ed8486f65aa02d1dc2291ec'/>
<id>50e3dcc44074dea26ed8486f65aa02d1dc2291ec</id>
<content type='text'>
tcp_listen() and udp_listen() have only some simple logic around a call to
pif_listen(), and it's basically identical in each case.  If we move the
common logic into pif_listen() we can then remove {tcp,udp}_listen()
entirely, with their caller in fwd_sync_one() calling pif_listen()
directly.

We also move the logic converting from a protocol id to an epoll type from
fwd_sync_one() into pif_listen().  It's a bit arbitrary, but seems slightly
nicer that way.

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>
tcp_listen() and udp_listen() have only some simple logic around a call to
pif_listen(), and it's basically identical in each case.  If we move the
common logic into pif_listen() we can then remove {tcp,udp}_listen()
entirely, with their caller in fwd_sync_one() calling pif_listen()
directly.

We also move the logic converting from a protocol id to an epoll type from
fwd_sync_one() into pif_listen().  It's a bit arbitrary, but seems slightly
nicer that way.

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>udp: Pass iov_tail to udp_update_hdr4()/udp_update_hdr6()</title>
<updated>2026-05-26T10:17:07+00:00</updated>
<author>
<name>Laurent Vivier</name>
<email>lvivier@redhat.com</email>
</author>
<published>2026-05-20T09:55:26+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=dec66c02b5e43e0ef809afa47e1008e143a01250'/>
<id>dec66c02b5e43e0ef809afa47e1008e143a01250</id>
<content type='text'>
Change udp_update_hdr4() and udp_update_hdr6() to take an iov_tail
pointing at the UDP frame instead of a contiguous udp_payload_t buffer
and explicit data length.  This lets vhost-user pass scatter-gather
virtqueue buffers directly without an intermediate copy.

The UDP header is built into a local struct udphdr and written back with
IOV_PUSH_HEADER().  On the tap side, udp_tap_prepare() wraps the
existing udp_payload_t in a two-element iov to match the new interface.

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Reviewed-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>
Change udp_update_hdr4() and udp_update_hdr6() to take an iov_tail
pointing at the UDP frame instead of a contiguous udp_payload_t buffer
and explicit data length.  This lets vhost-user pass scatter-gather
virtqueue buffers directly without an intermediate copy.

The UDP header is built into a local struct udphdr and written back with
IOV_PUSH_HEADER().  On the tap side, udp_tap_prepare() wraps the
existing udp_payload_t in a two-element iov to match the new interface.

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Reviewed-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>
