From: David Gibson <david@gibson.dropbear.id.au>
To: Anshu Kumari <anskuma@redhat.com>
Cc: passt-dev@passt.top, sbrivio@redhat.com, jmaloy@redhat.com,
lvivier@redhat.com
Subject: Re: [PATCH v4 3/4] dhcp: Add --dhcp-opt with option table and value parser
Date: Mon, 22 Jun 2026 12:42:01 +1000 [thread overview]
Message-ID: <ajig-ZGX419O2UoJ@zatzit> (raw)
In-Reply-To: <CADJNnV+bXYBarBDuGLLdXzHaz3e-5ggE9MgNtYEHB6Er+TqrKA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2433 bytes --]
On Fri, Jun 19, 2026 at 12:59:10PM +0530, Anshu Kumari wrote:
> On Fri, Jun 19, 2026 at 9:24 AM David Gibson <david@gibson.dropbear.id.au>
> wrote:
>
> > 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=192
> > > Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> > > ---
> > > 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?
> >
>
> 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.
>
> 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.
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-06-22 3:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 13:22 [PATCH v4 0/4] Add --dhcp-boot and --dhcp-opt options Anshu Kumari
2026-06-17 13:22 ` [PATCH v4 1/4] dhcp: Refactor fill_one() to operate on a generic buffer Anshu Kumari
2026-06-19 3:26 ` David Gibson
2026-06-17 13:22 ` [PATCH v4 2/4] dhcp: Add option overload Anshu Kumari
2026-06-19 3:39 ` David Gibson
2026-06-19 7:55 ` Anshu Kumari
2026-06-22 2:43 ` David Gibson
2026-06-17 13:22 ` [PATCH v4 3/4] dhcp: Add --dhcp-opt with option table and value parser Anshu Kumari
2026-06-19 3:52 ` David Gibson
2026-06-19 7:29 ` Anshu Kumari
2026-06-22 2:42 ` David Gibson [this message]
2026-06-17 13:22 ` [PATCH v4 4/4] conf: Add --dhcp-boot command-line option Anshu Kumari
2026-06-19 3:53 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ajig-ZGX419O2UoJ@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=anskuma@redhat.com \
--cc=jmaloy@redhat.com \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).