[PATCH 0/3] Fix regression in auto port forwarding
My recently merged series cleaning up the auto-port-forward scanning contained a series bug: automatic forwards would only appear on alternating seconds. This turned out to be due to a fundamentally broken premise in my thinking. I was thinking that for consistency we wanted the most recent port map information throughout the process. But that's not really true: for the purposes of exclusion what we really need to know is which of the listening sockets we scan are ours. That's given by the *prior* state of the forward maps, not the updated one based on a new scan. The series also had a number of worthwhile changes though. This series fixes it up, by reverting the most misguided of the patches and correcting behaviour of another one while preserving the accompanying code re-orgs. Link: https://bugs.passt.top/show_bug.cgi?id=176 David Gibson (3): Revert "fwd: Update all port maps before applying exclusions" fwd: Exclude ports based on prior mapping state fwd: Don't explicitly exclude reverse-direction TCP ports for UDP fwd.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) -- 2.51.1
With auto port-forwarding modes we scan for listening ports on the host
and/or guest and create forwardings for them. To avoid circular forwarding
we need to exclude our own listening ports. We do this by masking out
the forwarding map for one direction from the other.
Since 1bc7d5485c10, some of our scans take place while the forward maps are
out of sync with what our actual listening ports are though: the map
represents what we intend to forward shortly, rather than what we have
open sockets for right now.
What we have sockets for right now is what matters for the purposes of
excluding from the scan, though, so that was incorrect. So, restore
correct behaviour by saving the map of ports to exclude before we start
updating any of the forwarding maps with new scans. This allows us to
keep all the scans separate from all the rebinds, and therefore several
minor cleanups that permitted.
As a bonus, pre-creating the exclusion bitmaps this way should make this
code easier to adapt as we change the forwarding data structures to allow
more flexible configuration.
Fixes: 1bc7d5485c10 ("fwd: Consolidate scans (not rebinds) in fwd.c")
Link: https://bugs.passt.top/show_bug.cgi?id=176
Signed-off-by: David Gibson
On Wed, 19 Nov 2025 15:26:31 +1100
David Gibson
My recently merged series cleaning up the auto-port-forward scanning contained a series bug: automatic forwards would only appear on alternating seconds.
This turned out to be due to a fundamentally broken premise in my thinking. I was thinking that for consistency we wanted the most recent port map information throughout the process. But that's not really true: for the purposes of exclusion what we really need to know is which of the listening sockets we scan are ours. That's given by the *prior* state of the forward maps, not the updated one based on a new scan.
The series also had a number of worthwhile changes though. This series fixes it up, by reverting the most misguided of the patches and correcting behaviour of another one while preserving the accompanying code re-orgs.
Link: https://bugs.passt.top/show_bug.cgi?id=176
David Gibson (3): Revert "fwd: Update all port maps before applying exclusions" fwd: Exclude ports based on prior mapping state fwd: Don't explicitly exclude reverse-direction TCP ports for UDP
Applied. -- Stefano
participants (2)
-
David Gibson
-
Stefano Brivio