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=202512 header.b=PboZFPhG; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8C1F75A065C for ; Mon, 15 Dec 2025 11:08:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1765793302; bh=8zz8KBlkn3SS/NUTn8LI2HIfFS9L8eb0VMOBawdTa3w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PboZFPhGWNO5hAgom2Y4h/35Gsm5MqXwNQGQP2S7x9asi0HgGOzZKNu7H9Qwz7gG0 5zcpPkNieCf8+aDV1RjH/s3S061jVPyar4tFHs0JIozXCDntFLy+kzfzFSMltJoPX1 Zyc1kuHwzFYIX+LK8/jq398y9dRgU2UqbO4rxJBe8OKnTE335VpGKCvtfTdOJUNzej Bb8wVgbyW+vXTgr5w/mzcAJm04Ob+vfFtyaR7mGvtg2Z7Dd2eYSEw1faOH7BlTFFIg ln62SBRsOtkFXW8pRZKk/n+1TOBrlZfeGw/FtmvYZIYMS8QoFkRBfriY7Ib9qkIvNT AhLjqEcUUcFUA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dVG3V2Gnkz4wDn; Mon, 15 Dec 2025 21:08:22 +1100 (AEDT) Date: Mon, 15 Dec 2025 20:54:59 +1100 From: David Gibson To: Jon Maloy Subject: Re: [RFC 04/12] conf: Apply -n/--netmask to most recently added address Message-ID: References: <20251215015441.887736-1-jmaloy@redhat.com> <20251215015441.887736-5-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yMmwE/gapfOI93q7" Content-Disposition: inline In-Reply-To: <20251215015441.887736-5-jmaloy@redhat.com> Message-ID-Hash: 2HJTT2W4O7RQ4HVDK32OUJLRJTVB4RQD X-Message-ID-Hash: 2HJTT2W4O7RQ4HVDK32OUJLRJTVB4RQD 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: sbrivio@redhat.com, dgibson@redhat.com, passt-dev@passt.top 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: --yMmwE/gapfOI93q7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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]. >=20 > This allows per-address prefix configuration, such as: >=20 > -a 10.0.0.1 -n 24 -a 10.0.0.2 -n 16 >=20 > 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. >=20 > Signed-off-by: Jon Maloy > --- > conf.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) >=20 > 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 =3D 0; > char *runas =3D 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 =3D conf_ip4_prefix(optarg); > - if (c->ip4.addrs[0].prefix_len < 0) > + prefix =3D conf_ip4_prefix(optarg); > + > + if (prefix < 0) > die("Invalid netmask: %s", optarg); > =20 > + /* Apply to most recent address, or addrs[0] if none yet */ > + idx =3D c->ip4.addr_count ? c->ip4.addr_count - 1 : 0; > + c->ip4.addrs[idx].prefix_len =3D prefix; > break; > case 'M': > parse_mac(c->our_tap_mac, optarg); > --=20 > 2.51.1 >=20 --=20 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 --yMmwE/gapfOI93q7 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmk/2vIACgkQzQJF27ox 2GcgbBAAkErsnCnncnM4xkcENW2X75WYXEUNhOkRx7Or6UwQD+yCMG2NRW++sDgY lcZNW+0X3XZ+6sNoA33pm7Eu5wbvUgDF7dhEw6lKLd/Sf1Vc2EwJwznQmqEBKQ58 2zxrqgtv6F65CQ+fwz/jqllYcREzs6XOg8yk8YNwpKxryzwZj5uw2luus2fw9Hz7 nS7wMvpZtmEHaDtsiI3D4C85OTFiTSbvwX/MUswo6m0taRkK/2pQ9h3sm6CQ81/D 2F5vZ66L+Tvvrjzfc2J8PqRau6VLXJMsmKL+kRdWdsDlpj4WOYX9717nkcwDfek5 ocaXFQK3KKGD7bASaVfjYN5Eue32mHM8DVdEp1/yj8UlPC/3HYi61uiogHh2vwJR j7G0a9JI3O0WEObCrQ9q2iSZ7EV7rAX8yLCQpREYNPBxQnGyNlDThHEQA4SIud3s Hk6vRWU4oPPafgthFGqsMU55SoG8GvMmXm3zag1gtyU0GOHhM3Jy0UlCz+zLNGzG g8h6JmQuthRudGeL7BoLHZJvsHEvT1gckcpLOqt2f/fJ+Q2SgZysiFyiMnVeTkvZ nQylTLGHfOGeQXRu/RRREDNkEYqldfCSmwteCAxIzkgcL91qHZQv3J7wemGdLKN0 ID1kmi3+k4TswIR57AeKfHWrhmIo5BwtNU+kfvqFePPIUwu8EOo= =rrOs -----END PGP SIGNATURE----- --yMmwE/gapfOI93q7--