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=GcNCwf4o; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 6C2DB5A0625 for ; Tue, 07 Apr 2026 05:16:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1775531792; bh=DXBK+1MRpHwRHgN2MM4BjIOvcOvHawGiDwHPrz3YSBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GcNCwf4omhrjihaaom12B1sxc+eomqVu7TgQRgMU7wEqw/PL0DMZQ3Fywnc786qA1 cR3WU+Y8KCSjcf36sH8sQsg4dV7Cprx8pfJShgINH1SQ39HbYRPoxWiU00ceGAn1jN TjJ1ZHyQLBP9neQmXO1YegtjIzykxcvtPt1EeWy5QX5smLPT7r5uujLO6B3NFIWT0k dvajmKUiwKgD7fLYFq8hvdalWqRCJoZgcHF2enI/EYBeuxyzNg2dZ2sL+0rHjS2Mdr p1yKcXTM0f5duP4JfwnH33qNEOmQJff75+daYa6mY9aHx+H7Y+VIAjth3y5vIR1I2M d4QgxDJSq7FRA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fqWZ86RMFz4wLK; Tue, 07 Apr 2026 13:16:32 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 15/18] conf: Move "all" handling to port specifier Date: Tue, 7 Apr 2026 13:16:27 +1000 Message-ID: <20260407031630.2457081-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407031630.2457081-1-david@gibson.dropbear.id.au> References: <20260407031630.2457081-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LE5AHELSYUVS4WD6HYD2CEX5V65EYMSA X-Message-ID-Hash: LE5AHELSYUVS4WD6HYD2CEX5V65EYMSA 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: Currently -[tTuU] all is handled separately in conf_ports() before calling conf_ports_spec(). Earlier changes mean we can now move this handling to conf_ports_spec(). This makes the code slightly simpler, but more importantly it allows some useful combinations we couldn't previously do, such as -t 127.0.0.1/all or -u %eth2/all Signed-off-by: David Gibson --- conf.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/conf.c b/conf.c index 51612047..fcc75d25 100644 --- a/conf.c +++ b/conf.c @@ -251,6 +251,11 @@ static void conf_ports_spec(const struct ctx *c, const char *p, *ep; unsigned i; + if (!strcmp(spec, "all")) { + /* Treat "all" as equivalent to "": all non-ephemeral ports */ + spec = ""; + } + /* Mark all exclusions first, they might be given after base ranges */ for_each_chunk(p, ep, spec, ",") { struct port_range xrange; @@ -372,19 +377,6 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, return; } - if (!strcmp(optarg, "all")) { - uint8_t exclude[PORT_BITMAP_SIZE] = { 0 }; - - /* Exclude ephemeral ports */ - fwd_port_map_ephemeral(exclude); - - conf_ports_range_except(c, optname, optarg, fwd, - proto, NULL, NULL, - 1, NUM_PORTS - 1, exclude, - 1, FWD_WEAK); - return; - } - strncpy(buf, optarg, sizeof(buf) - 1); if ((spec = strchr(buf, '/'))) { -- 2.53.0