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=202606 header.b=XR3qTAYu; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 40C045A0269 for ; Mon, 22 Jun 2026 05:35:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1782099351; bh=7z0eWg/j0QtDXgOdPE9UwakYsYz2+Ip1mgMN8aU3zgc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XR3qTAYuFHjvycMsbc3/elZEoYMlUJOhrhF6Tg13IHT2yJGtsCtBAM1D3aet1Zo74 VQoj/clxLUnPgJzI011qsLHigtnY3psoMOdCAgI285ySX1wZCh+8BXTHnv3emgxpP0 JbiwhNRYX61xmhNcdZOEyr7vlM06vfKDt1YJPtLWAFfD2wfsyaPiEBVMrOdITFL8Ih eXI0OrDye4FEr7JnaEH2+miXBX+xZcnQfDHHQpXMU79sM1er7JzfzgqU/o27OggT6N v+8NZJ7UhGq0g1S/4llCmhkLwXbw5bIO/ooxjqD8V1XDlxzAXlmDdnLYM6keYenN77 hJAj+eryVpYjA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gkDPM5cZFz4wG8; Mon, 22 Jun 2026 13:35:51 +1000 (AEST) Date: Mon, 22 Jun 2026 12:42:01 +1000 From: David Gibson To: Anshu Kumari Subject: Re: [PATCH v4 3/4] dhcp: Add --dhcp-opt with option table and value parser Message-ID: References: <20260617132243.1499556-1-anskuma@redhat.com> <20260617132243.1499556-4-anskuma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BGSrgae0rV320n/u" Content-Disposition: inline In-Reply-To: Message-ID-Hash: JNFNK3RL45JLCATK35C66HEH6MB4VNMW X-Message-ID-Hash: JNFNK3RL45JLCATK35C66HEH6MB4VNMW 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: passt-dev@passt.top, sbrivio@redhat.com, jmaloy@redhat.com, lvivier@redhat.com 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: --BGSrgae0rV320n/u Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 19, 2026 at 12:59:10PM +0530, Anshu Kumari wrote: > On Fri, Jun 19, 2026 at 9:24=E2=80=AFAM David Gibson > wrote: >=20 > > On Wed, Jun 17, 2026 at 06:52:37PM +0530, Anshu Kumari wrote: > > > Introduce the --dhcp-opt flag that allows setting arbitrary DHCP > > > options from command-line in the form [--dhcp-opt CODE,VALUE]. > > > > > > Add a type lookup table mapping option codes to RFC 2132 value types > > > (IPv4, IPv4 list, integer, string) and dhcp_opt_parse() to convert > > > CLI strings to binary wire format. Parsed options are stored in > > > struct ctx and injected into DHCP replies. If the same option code > > > is given more than once, the last value wins. > > > > > > Link: https://bugs.passt.top/show_bug.cgi?id=3D192 > > > Signed-off-by: Anshu Kumari > > > --- > > > v4: > > > - Renamed custom_opts to dhcp_opts, 256 entries indexed by option > > > code, removed MAX_CUSTOM_DHCP_OPTS and count field. > > > - Changed str buffer from 256 to 255 bytes. > > > - Moved function to conf.c as static conf_dhcp_option(), renamed > > > from dhcp_add_option(). > > > - Made dhcp_opt_parse() non-static, declared in dhcp.h > > > - Dropped val/len from ctx struct; conf_dhcp_option() validates > > > with temp buffer, dhcp() parses str directly into opts[] at > > > reply time. > > > > Hmm. So each option is parsed twice. What prevents you from parsing > > directly into the opts[] array at conf() time? > > >=20 > The first parse acts as a validation step to check that the user has > entered the correct value format for the option. Without it, if the > user passes something like *--dhcp-opt 3,notanip*, the error would > surface only when the first DHCP client connects, not at startup. >=20 > I think it's better to fail during startup if correct value format > is not entered in command-line rather than failing at later stage > during reply time. Right, I understand that. What I'm suggesting is that you keep the binary value from the initial parse (that also error checks) - like you did in the earlier versions - but that it be kept in the opts[] array instead of in a new data structure. --=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 --BGSrgae0rV320n/u Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmo4oPgACgkQzQJF27ox 2GfrQhAAgiKL1+tm64tnR258on4L9r+kWkUOJeRX4uI/C2N5Q3YXliKFYLW2Ka9N hidh6dezqeG1WqqZq2SvsWXQ67/lin2Bbx4HrCgPfbookCjxrEUv8tvOwvlm+1Um 7fBoL9n+kpFoMCpS9ZXQfT6mn6fwAEEUKiNapd7dzo20wwJj+Ko5FDDeu+82gQ2f MPIJTrZghQr5RbDFlnGElChZgrK5XmGt5rVx3Q/J9DaEDbZoIgesQ6vIoDanqwGC MyHzN828bbaiVRlVGrpewDjWpndnndUwqwTg1TYd+scgkdhIqhPwr4Tli3fimMNL 1wccpdimpzxDp7GF0a5d0LC2brqbd5PCOiqq59iz2Sai2TgoyfYOOMsEPu/WjCHD By87liT1iTJYvOmxTF2PiC7I+x1HExOcJCd00m1mvF8Q6klYYS56Zd+XrDbYMiYD TygGGGjzS5r4J5z+MSRgfxDqLLyTTfEIe8X529UjtjHoBewfus9++pTuXor4Yhjp E5eF2Y7yj7g8Pw+53qxDfLxupLUqEdtolqJPTc+It4xO4wXFlxVN0k3Pgh0ldBW8 ++gLe1FZHPznimX1M8ZUjtrb/VuWC6gtt6HZa/vpgn81AMbhhA2RtGbjGyvfxK6+ LX+HT8koeWK8YiNRgANQAGTbjpZ6mtpb4sWokLrYaQfyTyEW9oU= =elkc -----END PGP SIGNATURE----- --BGSrgae0rV320n/u--