aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-03-27 15:34:21 +1100
committerStefano Brivio <sbrivio@redhat.com>2026-03-28 14:35:50 +0100
commit35c56c5b5e00389b2bf51a7d1c3f3c5387bba264 (patch)
tree848990b028e689adc52f80cb2210c988ea812c5e
parent559d4dcbd3593f6a7fc1cefd12666f56a1901652 (diff)
downloadpasst-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar.gz
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar.bz2
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar.lz
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar.xz
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.tar.zst
passt-35c56c5b5e00389b2bf51a7d1c3f3c5387bba264.zip
fwd: Allow FWD_DUAL_STACK_ANY flag to be passed directly to fwd_rule_add()
fwd_rule_add() takes a flags parameter, but it only allows the FWD_WEAK and FWD_SCAN flags to be specified there. It doesn't allow the FWD_DUAL_STACK_ANY flag to be set, instead expecting a [*] address to be indicated by passing NULL as @addr. However, for upcoming dynamic rule updates, it's more convenient to be able to explicitly pass FWD_DUAL_STACK_ANY along with an address of ::. Allow that mode of calling. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--fwd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fwd.c b/fwd.c
index 96957d9..03652b2 100644
--- a/fwd.c
+++ b/fwd.c
@@ -362,12 +362,15 @@ void fwd_rule_add(struct fwd_table *fwd, uint8_t proto, uint8_t flags,
in_port_t first, in_port_t last, in_port_t to)
{
/* Flags which can be set from the caller */
- const uint8_t allowed_flags = FWD_WEAK | FWD_SCAN;
+ const uint8_t allowed_flags = FWD_WEAK | FWD_SCAN | FWD_DUAL_STACK_ANY;
unsigned num = (unsigned)last - first + 1;
struct fwd_rule *new;
unsigned i, port;
assert(!(flags & ~allowed_flags));
+ /* Passing a non-wildcard address with DUAL_STACK_ANY is a bug */
+ assert(!(flags & FWD_DUAL_STACK_ANY) || !addr ||
+ inany_equals(addr, &inany_any6));
if (fwd->count >= ARRAY_SIZE(fwd->rules))
die("Too many port forwarding ranges");