From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=cX6znvBK; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id C6A145A0626 for ; Fri, 27 Mar 2026 05:34:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1774586072; bh=dUlbi3iJXUgmTmWTkNqrl2rNvubR9tF0V5khYl/Y9R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cX6znvBKawd4KfF77r9Kz/ZzYJThhT7H8QQNBhnoRUfo/8sca5CINly2xqRUszGKJ cCyTxHzbTahLiGUpEfujTrctVs7YWpcK5XdQ7FBYNRQNBT+M/8ni1izKSFo/14R0jo inG8KqKm+nmVm90CqmmgX2PPB9u9sf0o2QjJwT9+ywYAQyi0qcM9NSscJwNVyFbPs9 1Hp/1LcoHoA4QJ3povmbd45aim3euD0+TWEn215pcz3S3Ii7J4UTsbb6dIXoWD3ulz QTlXustx34VSVB37uZ5fZZLNZ9ypCh8R3ZBSMskKyxXpU26tUCit1lJ8N0/7xi1wnX 2Rd8N52W1iAiw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fhnqD5Vr8z4wT5; Fri, 27 Mar 2026 15:34:32 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 09/18] fwd: Allow FWD_DUAL_STACK_ANY flag to be passed directly to fwd_rule_add() Date: Fri, 27 Mar 2026 15:34:21 +1100 Message-ID: <20260327043430.1785787-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260327043430.1785787-1-david@gibson.dropbear.id.au> References: <20260327043430.1785787-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: AZ7VQIVCM5VJPU6HPFPZ5PFJQE5G7JKY X-Message-ID-Hash: AZ7VQIVCM5VJPU6HPFPZ5PFJQE5G7JKY X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- fwd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fwd.c b/fwd.c index 96957d9f..03652b23 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"); -- 2.53.0