On Sun, Dec 14, 2025 at 08:54:33PM -0500, Jon Maloy wrote: > We allow for multiple -n/--netmask options, and update the handling so > that each given prefix length is applied to the most recently added > address instead of always to addrs[0]. > > This allows per-address prefix configuration, such as: > > -a 10.0.0.1 -n 24 -a 10.0.0.2 -n 16 > > If no address has been added yet, -n still applies to addrs[0] for > backwards compatibility. Huh. I'd forgotten until looking at this series that we had the -n option. We probably do need this change, but in general I think we'd be better off deprecating -n, in favour of allowing a prefix len as part of the -a option, e.g. -a 10.0.0.1/24 -a 10.0.0.2/16 That could be a smaller change preliminary to this series. > > Signed-off-by: Jon Maloy > --- > conf.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/conf.c b/conf.c > index e9f217b..0a4a28a 100644 > --- a/conf.c > +++ b/conf.c > @@ -1528,6 +1528,7 @@ void conf(struct ctx *c, int argc, char **argv) > size_t logsize = 0; > char *runas = NULL; > long fd_tap_opt; > + int prefix, idx; > int name, ret; > uid_t uid; > gid_t gid; > @@ -1872,10 +1873,14 @@ void conf(struct ctx *c, int argc, char **argv) > die("Invalid address: %s", optarg); > break; > case 'n': > - c->ip4.addrs[0].prefix_len = conf_ip4_prefix(optarg); > - if (c->ip4.addrs[0].prefix_len < 0) > + prefix = conf_ip4_prefix(optarg); > + > + if (prefix < 0) > die("Invalid netmask: %s", optarg); > > + /* Apply to most recent address, or addrs[0] if none yet */ > + idx = c->ip4.addr_count ? c->ip4.addr_count - 1 : 0; > + c->ip4.addrs[idx].prefix_len = prefix; > break; > case 'M': > parse_mac(c->our_tap_mac, optarg); > -- > 2.51.1 > -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson