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=XfwatWla; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8BD185A0271 for ; Tue, 27 Jan 2026 09:46:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1769503572; bh=HB97CdoJEHQ+ArvCeJsD5Dx/Nal6g57Oxey3ZVRvJUs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XfwatWlaXwZqsBmXaDuGnwl/v5Sj/7ofzKGWIjbSbA2Sk02o5B4cp68qRByPI+SxM 7/LG4IKOX6cACrjEV9FHcmKKby+t7BHbRcz0OYNlPK0RgS/PMSi1zfEtCI6sAJWl5+ Tq3xbB+09xWXNZ3+o3hhQPFXhT7alkIL6ha3Ml3UNAdZ/GV7mgAGr/U61AQie3G89z iE9y0/g5Lf9Dx5iOyuulYexqKS6nWNWv/Kd2qioM98NWxZp1KKao9QL/HsnN8UnTfP gZplBIIxdlPqvRCsQNorOwZiu33/bo2HbgJaU7BunOg8UKo0XN6by6MEkhZver0emv gqk/4kotG3Phg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4f0fBr2mnWz4wCP; Tue, 27 Jan 2026 19:46:12 +1100 (AEDT) Date: Tue, 27 Jan 2026 19:42:21 +1100 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v2 1/9] conf: Support CIDR notation for -a/--address option Message-ID: References: <20260118221612.2115386-1-jmaloy@redhat.com> <20260118221612.2115386-2-jmaloy@redhat.com> <8ac549ba-c893-4e68-ac1c-72974781fa4e@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AmpT4BwnlvLCO126" Content-Disposition: inline In-Reply-To: <8ac549ba-c893-4e68-ac1c-72974781fa4e@redhat.com> Message-ID-Hash: 3FMJ7FYRMP6QBFR67HYV5TDXDMR7JC25 X-Message-ID-Hash: 3FMJ7FYRMP6QBFR67HYV5TDXDMR7JC25 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: --AmpT4BwnlvLCO126 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 21, 2026 at 07:06:10PM -0500, Jon Maloy wrote: > On 2026-01-19 00:02, David Gibson wrote: > > On Sun, Jan 18, 2026 at 05:16:04PM -0500, Jon Maloy wrote: [snip] > > > +/** > > > + * conf_addr_prefix_len() - Parse address with optional prefix length > > > + * @arg: Address string, optionally with /prefix_len suffix (modifie= d) > > > + * @addr: Output for parsed address > > > + * @prefix_len: Output for prefix length (0 if not specified) > > > + * > > > + * Return: AF_INET for IPv4, AF_INET6 for IPv6, -1 on error > > > + */ > > > +static int conf_addr_prefix_len(char *arg, union inany_addr *addr, > > > + int *prefix_len) > > > +{ > > > + char *slash; > > > + > > > + *prefix_len =3D 0; > > > + > > > + /* Check for /prefix_len suffix */ > > > + slash =3D strchr(arg, '/'); > > > + if (slash) { > > > + unsigned long len; > > > + char *end; > > > + > > > + *slash =3D '\0'; > > > + errno =3D 0; > > > + len =3D strtoul(slash + 1, &end, 10); > > > + if (errno || *end) > > > + return -1; > > > + > > > + *prefix_len =3D len; > > > + } > > > + > > > + if (!inany_prefix_pton(arg, addr, prefix_len)) > > > + return -1; > >=20 > > Oh, sorry, I wasn't clear. My idea was that inany_prefix_pton() would > > handle the parsing (strchr(), strtoul() etc.) of the prefix length > > internally, rather than doing that here then adjusting it in there. >=20 > Ok. So I basically eliminate conf_addr_perfix_len() and replace it with > a inany_prefix_pton() which does all the job. Makes sense. Yes. > Regarding the prefix length adjustment: if I give some address in one of = the > following two formats: > 192.168.1.1/24 > or > ::ffff:192.168.1.1/120 >=20 > they will both be stored in the array in exactly the same > format, as ::ffff:192.168.1.1. Yes. > It makes little sense to use two different prefix lengths just > because the user happened to use some specific format, and would > only create problems for anybody trying to access that entry later. > I think this one *should* be adjusted. Absolutely, but they should all be adjusted to the IPv6 form, not the IPv4 form. --=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 --AmpT4BwnlvLCO126 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAml4emIACgkQzQJF27ox 2GfXqQ//Q2nmGOCsvHPrJ3KHepVhU7j/t0r5YQofggGXGVq9Kck61b1DE5UQ9HJA xWi9S6ncg/25t28+1VKKV3ASuW2o+4e+WOEpz666RnGSbgYEPF6BigQAj0DqUxjp 97Rwhvgt84fpYz7Nm/2gY5N1ELz4VVBVJ89hN+Bwzr81YI811RWNw+jiJYxjXJYs fGZn8R+1WjZo5/Or4jtIKhsaMFnNRNTPgFz5GF9UAQtdf0g9+bJ007nLgyXsAsJZ LfTJSpMf1eoUsiqkc8pbUXt1tOoc9vvJ+M1GSPcKSsuYDCwM86fcKRAQGbEPLqb6 EOq4kzU/forZpOhT+mBVcCXQmAUFFN5YfaB6ih7d7rtHP6IIrRECixsSyZVqaJMC OmlurEaFL6ZMzNCtszwWZ+7M3wGHc+vuj9tv7RCw61pmbyGc2Vox8pKUcdwT3hK3 8O/npov1C8CAumLUquZuHgDkb4M9f4uQpPsZrzygOOkfF2d/oQ4vOacY5iaQUdtG +cNSdp1AAQbjvV5L49SMF9zUsqMFS76MLgC7jF64iUvjnOk61FuXtj8BKhj2ztEC tdZ4IkXxMXZCRGyf2GUNQMM5RGv6HctW5ON1btvonirskxzIIqto2fVrxJK4ivfH RdZAIjVZ5S4OfDIaMnJAevTTb5VM14KIHU+F5vVWVVFD+1VxXo8= =nmoS -----END PGP SIGNATURE----- --AmpT4BwnlvLCO126--