aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-01-06 17:10:46 +1100
committerStefano Brivio <sbrivio@redhat.com>2026-01-11 01:31:43 +0100
commit35f63d29932c74c38a3cbaea4256890f8a88b428 (patch)
tree9539e66d4b5244e83e06f8c5b1aeefa1e2c1cbd4
parentfacc73634a04e1ddbd7057d534df62e0c40eb274 (diff)
downloadpasst-35f63d29932c74c38a3cbaea4256890f8a88b428.tar
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.tar.gz
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.tar.bz2
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.tar.lz
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.tar.xz
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.tar.zst
passt-35f63d29932c74c38a3cbaea4256890f8a88b428.zip
fwd: Minor cleanup to fwd_nat_from_splice()
The order we do things in this function is slightly odd, and we have a redundant assignment to tgt->oport. Remove that, and re-order for clarity. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--fwd.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/fwd.c b/fwd.c
index 9b701ad..961c533 100644
--- a/fwd.c
+++ b/fwd.c
@@ -660,13 +660,15 @@ uint8_t fwd_nat_from_splice(const struct ctx *c, uint8_t proto,
return PIF_NONE;
}
+ /* Preserve the src & dest (loopback) addresses */
+ tgt->oaddr = ini->eaddr;
tgt->eaddr = ini->oaddr;
- /* Preserve the specific loopback address used, but let the kernel pick
- * a source port on the target side
- */
- tgt->oaddr = ini->eaddr;
+ /* Let the kernel pick a host side source port */
tgt->oport = 0;
+ if (proto == IPPROTO_UDP)
+ /* But for UDP preserve the source port */
+ tgt->oport = ini->eport;
tgt->eport = ini->oport;
if (proto == IPPROTO_TCP)
@@ -674,12 +676,6 @@ uint8_t fwd_nat_from_splice(const struct ctx *c, uint8_t proto,
else if (proto == IPPROTO_UDP)
tgt->eport += c->udp.fwd_out.delta[tgt->eport];
- /* Let the kernel pick a host side source port */
- tgt->oport = 0;
- if (proto == IPPROTO_UDP)
- /* But for UDP preserve the source port */
- tgt->oport = ini->eport;
-
return PIF_HOST;
}