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=WCgAJBOP; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 8A7875A0627 for ; Mon, 23 Mar 2026 09:32:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1774254767; bh=R7DzgxRZIwMw9n9n0khYfJbhK/oLDEkuK7kjdzpwDXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WCgAJBOPeFOkVyIXGebSnSO1EhE4UV6JdQ4rTzsHNLL2NfbsdwqqphfKWueyAgSqb v+AN3yLdTpnVGBmPIKBEWGuFe6R9mq6sr9gC0jZWmWnDPLQHIM5I/ZWmBCZoHHjgtL TAIx19YKH0WSfArYhkQGSEUgLdXbybSllo0oRF3Ywv8PaKxI/yzX1KwN7g97fmyXLe ZcXJXPTbDYytTA9xsHhcEyMi/yj6Cz+lmtcP+PqB3+C2z40ECLyLT+OzmVS04WBgtv H272dFcJd7oIodKHtqry5y0AWMxMdv8BTFrmF+sV9w5K3yCCWAwiX50sQtNy55tBeK XduVMAXZuy17g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ffRHz4t4Kz4wH2; Mon, 23 Mar 2026 19:32:47 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 12/25] conf: Move check for disabled interfaces earlier Date: Mon, 23 Mar 2026 18:37:19 +1100 Message-ID: <20260323073732.3158468-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323073732.3158468-1-david@gibson.dropbear.id.au> References: <20260323073732.3158468-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: TUAHWG5K5T5LOMRAR3RKMBSUHX7FL3NR X-Message-ID-Hash: TUAHWG5K5T5LOMRAR3RKMBSUHX7FL3NR 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: conf_ports_range_except() generates errors if asked to map an address of a family that's not available. This is quite late to perform the check, most callsites pass a NULL address, making the test moot, the one remaining can check the address earlier. Move the check there, simplifying the lower level function. Signed-off-by: David Gibson --- conf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/conf.c b/conf.c index dc9468c2..d4c2a013 100644 --- a/conf.c +++ b/conf.c @@ -160,16 +160,6 @@ static void conf_ports_range_except(const struct ctx *c, char optname, else assert(0); - if (addr) { - if (!c->ifi4 && inany_v4(addr)) { - die("IPv4 is disabled, can't use -%c %s", - optname, optarg); - } else if (!c->ifi6 && !inany_v4(addr)) { - die("IPv6 is disabled, can't use -%c %s", - optname, optarg); - } - } - for (base = first; base <= last; base++) { if (exclude && bitmap_isset(exclude, base)) continue; @@ -335,6 +325,16 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, addr = NULL; } + if (addr) { + if (!c->ifi4 && inany_v4(addr)) { + die("IPv4 is disabled, can't use -%c %s", + optname, optarg); + } else if (!c->ifi6 && !inany_v4(addr)) { + die("IPv6 is disabled, can't use -%c %s", + optname, optarg); + } + } + /* Mark all exclusions first, they might be given after base ranges */ p = spec; do { -- 2.53.0