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=BDhdGO2w; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id CB4365A0274 for ; Wed, 11 Mar 2026 13:03:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1773230596; bh=WzRhsxh6aUNSaK6/12YfpT7Wr0buSP53h8ZaUa8JHwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDhdGO2w58fYkvZtslWTsnEnJ0BrMb5giAnUt+LjUar2rxUNmDpqeFF9DuvCRGUnb kBEhx95sXddnlmGve7NKvw0RCMeYb8RPHVCMwX6ogkG2DMQQCbZCD+0/ZWlV89MNQu FHcALREqgalAOaEFnkuZkwHXVxL0TYOf862QZNxtDMpMizrYnjkvPpbiIBwzhykan4 rAgZZekDAA/lZJP5BaFEdDCiQHc5v0OHo6b3Z2ZMnO+XTRyve0oYiWS4OOnvqZKqXQ 4C9mjbYVRQ7RE8gf0DX//ArpdyAeG/O/cgjJO1lXh/ElZupPA+fFFC0plVL2XAdsX2 FmtvH9rCY4hHQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fW8XN2RfHz4wRD; Wed, 11 Mar 2026 23:03:16 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 9/9] conf: Parse all forwarding options at the same time Date: Wed, 11 Mar 2026 23:03:14 +1100 Message-ID: <20260311120314.933546-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260311120314.933546-1-david@gibson.dropbear.id.au> References: <20260311120314.933546-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LEZOD76WP2F5H2THCNB2KBMA2D2DBZ2Y X-Message-ID-Hash: LEZOD76WP2F5H2THCNB2KBMA2D2DBZ2Y 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: We don't handle the -t and -u options in the main option parsing loop, because they rely on some IP parameters already being finalised (specifically, conf_ports() uses use ifi4 and ifi6 to determine if IP versions are enabled). So, we parse them in a second pass through the command line. The -T and -U options are parsed in a third pass through the command line, because they relied on setup of the guest namespace. However, since we reworked their handling to use the forward table structure, that's no longer the case. So, move their handling into the same loop as the -t and -u options. Signed-off-by: David Gibson --- conf.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/conf.c b/conf.c index ffbd403d..dafac463 100644 --- a/conf.c +++ b/conf.c @@ -2152,7 +2152,7 @@ void conf(struct ctx *c, int argc, char **argv) if (c->ifi4 && IN4_IS_ADDR_UNSPECIFIED(&c->ip4.guest_gw)) c->no_dhcp = 1; - /* Inbound port options can be parsed now, after IPv4/IPv6 settings */ + /* Forwarding options can be parsed now, after IPv4/IPv6 settings */ fwd_probe_ephemeral(); optind = 0; do { @@ -2162,6 +2162,10 @@ void conf(struct ctx *c, int argc, char **argv) conf_ports(c, name, optarg, &c->fwd_in, &tcp_in_mode); else if (name == 'u') conf_ports(c, name, optarg, &c->fwd_in, &udp_in_mode); + else if (name == 'T') + conf_ports(c, name, optarg, &c->fwd_out, &tcp_out_mode); + else if (name == 'U') + conf_ports(c, name, optarg, &c->fwd_out, &udp_out_mode); } while (name != -1); if (c->mode == MODE_PASTA) @@ -2191,17 +2195,6 @@ void conf(struct ctx *c, int argc, char **argv) if (c->mode == MODE_PASTA) nl_sock_init(c, true); - /* ...and outbound port options now that namespaces are set up. */ - optind = 0; - do { - name = getopt_long(argc, argv, optstring, options, NULL); - - if (name == 'T') - conf_ports(c, name, optarg, &c->fwd_out, &tcp_out_mode); - else if (name == 'U') - conf_ports(c, name, optarg, &c->fwd_out, &udp_out_mode); - } while (name != -1); - if (!c->ifi4) c->no_dhcp = 1; -- 2.53.0