[PATCH 0/3] pasta: Implement runtime auto-forwarding for UDP
In "auto" mode port forwarding, we scan for listening TCP ports at start up, and then every second thereafter. For UDP, however, we scan only at start up. That's documented, but surprising, and there's no real reason for it to be that way. Implement periodic scanning for UDP auto forwarding too. Link: https://bugs.passt.top/show_bug.cgi?id=45 *** BLURB HERE *** David Gibson (3): tcp: Use common helper for rebinding inbound and outbound ports tcp: Simplify away tcp_port_rebind() udp,pasta: Periodically scan for ports to automatically forward passt.1 | 3 +- tcp.c | 109 +++++++++++++++++++++++--------------------------------- udp.c | 74 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 66 deletions(-) -- 2.41.0
tcp_port_rebind() has two cases with almost but not quite identical code.
Simplify things a bit by factoring this out into a single parameterised
helper, tcp_port_do_rebind().
Signed-off-by: David Gibson
tcp_port_rebind() is desgined to be called from NS_CALL() and has two
disjoint cases: one where it enters the namespace (outbound forwards) and
one where it doesn't (inbound forwards).
We only actually need the NS_CALL() framing for the outbound case, for
inbound we can just call tcp_port_do_rebind() directly. So simplify
tcp_port_rebind() to tcp_port_rebind_outbound(), allowing us to eliminate
an awkward parameters structure.
With that done we can safely rename tcp_port_do_rebind() to
tcp_port_rebind() for brevity.
Signed-off-by: David Gibson
pasta supports automatic port forwarding, where we look for listening
sockets in /proc/net (in both namespace and outside) and establish port
forwarding to match.
For TCP we do this scan both at initial startup, then periodically
thereafter. For UDP however, we currently only scan at start. So unlike
TCP we won't update forwarding to handle services that start after pasta
has begun.
There's no particular reason for that, other than that we didn't implement
it. So, remove that difference, by scanning for new UDP forwards
periodically too. The logic is basically identical to that for TCP, but it
needs some changes to handle the mildly different data structures in the
UDP case.
Link: https://bugs.passt.top/show_bug.cgi?id=45
Signed-off-by: David Gibson
On Wed, 15 Nov 2023 16:25:31 +1100
David Gibson
In "auto" mode port forwarding, we scan for listening TCP ports at start up, and then every second thereafter. For UDP, however, we scan only at start up.
That's documented, but surprising, and there's no real reason for it to be that way. Implement periodic scanning for UDP auto forwarding too.
Link: https://bugs.passt.top/show_bug.cgi?id=45
*** BLURB HERE ***
David Gibson (3): tcp: Use common helper for rebinding inbound and outbound ports tcp: Simplify away tcp_port_rebind() udp,pasta: Periodically scan for ports to automatically forward
Applied. -- Stefano
participants (2)
-
David Gibson
-
Stefano Brivio