<feed xmlns='http://www.w3.org/2005/Atom'>
<title>passt/flow.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>udp: Don't share a preserved source port with other sockets</title>
<updated>2026-12-02T21:58:01+00:00</updated>
<author>
<name>Gerwim Feiken</name>
<email>info@gerwim.nl</email>
</author>
<published>2026-12-01T23:52:01+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=3f594423487c44db8d78748922cfb614b4b77518'/>
<id>3f594423487c44db8d78748922cfb614b4b77518</id>
<content type='text'>
For a UDP flow initiated from the guest, passt keeps the guest's
source port on the host side (fwd_nat_from_tap()) and binds the flow
socket with SO_REUSEADDR (sock_l4_()). Several passt instances in one
network namespace -- one per VM, as a VM manager spawning passt from
one daemon does -- can then each bind the same port towards the same
destination, typically the resolver behind --dns-forward. Their
sockets share one identical 4-tuple, and the kernel delivers each
reply to only one of them: the other guest's queries go unanswered
until the flow expires, and the guest owning the receiving socket gets
answers to queries it never sent.

Bind the host side socket of a flow initiated from the tap interface
without SO_REUSEADDR, so that the bind fails if any other socket holds
the port, and fall back to a port chosen by the kernel in that case.
udp_flow_new() reads the actual port back with getsockname(), as it
already does for the address. Listening sockets, and flows initiated
from them, keep SO_REUSEADDR.

Link: https://bugs.passt.top/show_bug.cgi?id=223
Signed-off-by: Gerwim Feiken &lt;info@gerwim.nl&gt;
[jmaloy: Don't pass 'exclusive' through the PIF_SPLICE path in
 flowside_sock_l4(): flows initiated from the tap interface never
 target it, assert that instead]
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>
For a UDP flow initiated from the guest, passt keeps the guest's
source port on the host side (fwd_nat_from_tap()) and binds the flow
socket with SO_REUSEADDR (sock_l4_()). Several passt instances in one
network namespace -- one per VM, as a VM manager spawning passt from
one daemon does -- can then each bind the same port towards the same
destination, typically the resolver behind --dns-forward. Their
sockets share one identical 4-tuple, and the kernel delivers each
reply to only one of them: the other guest's queries go unanswered
until the flow expires, and the guest owning the receiving socket gets
answers to queries it never sent.

Bind the host side socket of a flow initiated from the tap interface
without SO_REUSEADDR, so that the bind fails if any other socket holds
the port, and fall back to a port chosen by the kernel in that case.
udp_flow_new() reads the actual port back with getsockname(), as it
already does for the address. Listening sockets, and flows initiated
from them, keep SO_REUSEADDR.

Link: https://bugs.passt.top/show_bug.cgi?id=223
Signed-off-by: Gerwim Feiken &lt;info@gerwim.nl&gt;
[jmaloy: Don't pass 'exclusive' through the PIF_SPLICE path in
 flowside_sock_l4(): flows initiated from the tap interface never
 target it, assert that instead]
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>cppcheck: Fix scope of the variable 'type_or_state'</title>
<updated>2026-11-22T21:02:50+00:00</updated>
<author>
<name>Laurent Vivier</name>
<email>lvivier@redhat.com</email>
</author>
<published>2026-11-19T12:49:16+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=5fa9ecd998d8c66882dead33c44b53be4316924b'/>
<id>5fa9ecd998d8c66882dead33c44b53be4316924b</id>
<content type='text'>
Fix following cppcheck 2.22.0 error:

flow.c:289:14: style: The scope of the variable 'type_or_state' can be reduced. [variableScope]

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Fixes: bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow logging functions")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix following cppcheck 2.22.0 error:

flow.c:289:14: style: The scope of the variable 'type_or_state' can be reduced. [variableScope]

Signed-off-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Fixes: bfbd2deae0c3 ("flow: Handle NULL (unknown) flows in flow logging functions")
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>flow: Handle NULL (unknown) flows in flow logging functions</title>
<updated>2026-11-16T23:14:11+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-11-15T16:35:52+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=bfbd2deae0c39cbfd85cea8fab4271943d546032'/>
<id>bfbd2deae0c39cbfd85cea8fab4271943d546032</id>
<content type='text'>
Starting from commit edeb2a26c663 ("udp: Improve messages for errors
getting errors"), we might call flow logging functions with a NULL
flow, for example via udp_sock_fwd() -&gt; udp_sock_errs().

As reported by Doug, that will make us dereference a NULL flow in
flow_dbg().  This happens occasionally with a specific pattern in
outbound UDP traffic, where we contact a large number of endpoints
that might be occasionally unreachable.

We want to print socket errors even if we couldn't find an associated
flow.  For simplicity, instead of adding conditionals in all the
possible callers, just handle NULL flows in flow logging functions,
and tell the user that we couldn't find a flow for the error.

Reported-by: Doug Baggett &lt;doug.baggett@gmail.com&gt;
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2529245
Fixes: edeb2a26c663 ("udp: Improve messages for errors getting errors")
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>
Starting from commit edeb2a26c663 ("udp: Improve messages for errors
getting errors"), we might call flow logging functions with a NULL
flow, for example via udp_sock_fwd() -&gt; udp_sock_errs().

As reported by Doug, that will make us dereference a NULL flow in
flow_dbg().  This happens occasionally with a specific pattern in
outbound UDP traffic, where we contact a large number of endpoints
that might be occasionally unreachable.

We want to print socket errors even if we couldn't find an associated
flow.  For simplicity, instead of adding conditionals in all the
possible callers, just handle NULL flows in flow logging functions,
and tell the user that we couldn't find a flow for the error.

Reported-by: Doug Baggett &lt;doug.baggett@gmail.com&gt;
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2529245
Fixes: edeb2a26c663 ("udp: Improve messages for errors getting errors")
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>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, udp: Fix errno handling in udp_flow_sock()</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:24+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=60cd39a5a8ce4ea0f1b6ca33d1c99aa6a780e713'/>
<id>60cd39a5a8ce4ea0f1b6ca33d1c99aa6a780e713</id>
<content type='text'>
flowside_connect() behaves much like connect(2) itself, returning -1 on
error with errno set to the error code.  One of the callers, in
udp_flow_sock(), uses the errno code with flow_dbg_perror() *after* it's
called epoll_del() and close() either of which could clobber errno.

Fix that by moving the debug message earlier: there's no reason it has to
wait until the epoll_del() and close().

While we're at it, adjust the comment on flowside_connect() to clarify
that it sets errno (rather than, say, returning an error code).

Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
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>
flowside_connect() behaves much like connect(2) itself, returning -1 on
error with errno set to the error code.  One of the callers, in
udp_flow_sock(), uses the errno code with flow_dbg_perror() *after* it's
called epoll_del() and close() either of which could clobber errno.

Fix that by moving the debug message earlier: there's no reason it has to
wait until the epoll_del() and close().

While we're at it, adjust the comment on flowside_connect() to clarify
that it sets errno (rather than, say, returning an error code).

Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
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: Indent flow details 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:22+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=2fbeb3b1ea2998a1e1a1854aea9fdffcc62a4d15'/>
<id>2fbeb3b1ea2998a1e1a1854aea9fdffcc62a4d15</id>
<content type='text'>
flow_log__() has the option to append an extra log message with address
details of the flow, to give more context to errors or warnings.  Add an
indent to this part of the message, to emphasise that it's additional
information related to a nearby message, rather than a message in its own
right.

Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
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_log__() has the option to append an extra log message with address
details of the flow, to give more context to errors or warnings.  Add an
indent to this part of the message, to emphasise that it's additional
information related to a nearby message, rather than a message in its own
right.

Suggested-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
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>flow: Correct misleading signature of flowside_sock_l4()</title>
<updated>2026-06-16T21:49:53+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-06-16T01:09:33+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=6d1f38cad752b818ea5be523896f1ceab4c12db0'/>
<id>6d1f38cad752b818ea5be523896f1ceab4c12db0</id>
<content type='text'>
flowside_sock_l4() takes a @tgt parameter with the side to create a socket
for.  The name is misleading, however, although ICMP only uses it for the
target side of the flow, UDP can use it for either or both sides.  TCP
doesn't use it at all.  Rename it to @side.

While we're there remove the stale comment for the @data paremeter which
was removed in 05972c7c4daf.

Fixes: 05972c7c4daf ("util: Move epoll registration out of sock_l4_sa()")
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>
flowside_sock_l4() takes a @tgt parameter with the side to create a socket
for.  The name is misleading, however, although ICMP only uses it for the
target side of the flow, UDP can use it for either or both sides.  TCP
doesn't use it at all.  Rename it to @side.

While we're there remove the stale comment for the @data paremeter which
was removed in 05972c7c4daf.

Fixes: 05972c7c4daf ("util: Move epoll registration out of sock_l4_sa()")
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>clang-tidy: Squash inconsistent brace warnings in foreach macros</title>
<updated>2026-05-11T22:04:03+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-05-11T10:03:18+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=a82a2173d4ea41fe4e97d9451f8ed1626b00d612'/>
<id>a82a2173d4ea41fe4e97d9451f8ed1626b00d612</id>
<content type='text'>
clang-tidy, at least as of 22.1.4 complains about if/else statements with
inconsistent braces.  We generally do want consistend bracing per our
coding style.  However, some of our foreach macros generate inconsistent
bracing in a way that can't really be avoided.  Add suppressions to stop
clang-tidy complaining about these.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Reviewed-by: Laurent Vivier &lt;lvivier@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>
clang-tidy, at least as of 22.1.4 complains about if/else statements with
inconsistent braces.  We generally do want consistend bracing per our
coding style.  However, some of our foreach macros generate inconsistent
bracing in a way that can't really be avoided.  Add suppressions to stop
clang-tidy complaining about these.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Reviewed-by: Laurent Vivier &lt;lvivier@redhat.com&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
