diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-03-11 23:03:14 +1100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-03-11 22:11:30 +0100 |
| commit | 1b32bfe181c7a22d22fbc9ba90b94c8234e15adc (patch) | |
| tree | cc5e734fa07aaa090db9a19f5ec2f9923219b528 | |
| parent | ea239bf954bf016d7c8724fce7c7ae846e661124 (diff) | |
| download | passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar.gz passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar.bz2 passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar.lz passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar.xz passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.tar.zst passt-1b32bfe181c7a22d22fbc9ba90b94c8234e15adc.zip | |
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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | conf.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -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; |
