public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: Anshu Kumari <anskuma@redhat.com>,
	passt-dev@passt.top, jmaloy@redhat.com, lvivier@redhat.com
Subject: Re: [PATCH v3 3/6] dhcp: Add option type table and value parser
Date: Mon, 15 Jun 2026 12:09:42 +1000	[thread overview]
Message-ID: <ai9e5jzhoajDDbTS@zatzit> (raw)
In-Reply-To: <20260612010436.6b25300f@elisabeth>

[-- Attachment #1: Type: text/plain, Size: 2578 bytes --]

On Fri, Jun 12, 2026 at 01:04:37AM +0200, Stefano Brivio wrote:
> On Tue, 2 Jun 2026 12:23:47 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Mon, Jun 01, 2026 at 01:07:53PM +0530, Anshu Kumari wrote:
> >
> > > [...]
> > >
> > > +/**
> > > + * dhcp_opt_types - Maps option code to RFC 2132 value type, indexed by code
> > > + */
> > > +static const enum dhcp_opt_type dhcp_opt_types[256] = {
> > > +	[1]   = DHCP_OPT_IPV4,		/* Subnet Mask */
> > > +	[2]   = DHCP_OPT_INT32,		/* Time Offset */
> > > +	[3]   = DHCP_OPT_IPV4_LIST,	/* Router */  
> > 
> > I'm still a bit unsure if we want to allow user modification of the
> > options, like this one, which we already manage ourselves.
> 
> I think we don't lose any functionality if we allow users to overwrite
> them, and we might gain some: for example one might want to directly
> set a specific default route in the target network namespace, in pasta,
> but change it as a DHCP client runs.
> 
> Not that I see any point in doing that, but it's harmless, so why not.
> Maybe even just for testing, go figure.

Fair point, I concur.

> > > [...]
> > >
> > > @@ -61,7 +227,15 @@ int dhcp_add_option(struct ctx *c, uint8_t code, const char *val_str)
> > >  		c->custom_opts_count++;
> > >  	}
> > >  
> > > +	ret = dhcp_opt_parse(code, val_str,
> > > +			     c->custom_opts[idx].val,
> > > +			     sizeof(c->custom_opts[0].val));  
> > 
> > Now that this parsing and adding code is all in dhcp.c, could we parse
> > the options directly into the existing opts[] global, rather than
> > requiring both the string and parsed forms in c->custom_opts?
> 
> I see one downside with that: the day we add the possibility for
> pesto(1) to set and read out options, we would need to add an
> implementation to decode them back, which could be rather complicated
> if you think of stuff such as "compressed" (yes, that madness) domain
> names.

Sorry, let me clarify.  I'm not suggesting we remove the string
version of the value, for exactly that reason (along with making
debugging messages easier).

However, at the moment I think we end up with *two* copies of the
parsed binary value: one in c->custom_opts[].val, and another in the
opts[].s global within dhcp.c.  I'm hoping we can remove one of them;
the one in custom_opts seeming like the easier one.

-- 
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 --]

  reply	other threads:[~2026-06-15  2:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  7:37 [PATCH v3 0/6] Add --dhcp-boot and --dhcp-opt options Anshu Kumari
2026-06-01  7:37 ` [PATCH v3 1/6] conf: Add --dhcp-opt command-line option Anshu Kumari
2026-06-02  2:00   ` David Gibson
2026-06-11 23:04   ` Stefano Brivio
2026-06-13  2:50     ` David Gibson
2026-06-15  6:42       ` Stefano Brivio
2026-06-01  7:37 ` [PATCH v3 2/6] conf: Add --dhcp-boot " Anshu Kumari
2026-06-02  2:02   ` David Gibson
2026-06-11 23:05   ` Stefano Brivio
2026-06-01  7:37 ` [PATCH v3 3/6] dhcp: Add option type table and value parser Anshu Kumari
2026-06-02  2:23   ` David Gibson
2026-06-11 23:04     ` Stefano Brivio
2026-06-15  2:09       ` David Gibson [this message]
2026-06-11 23:04   ` Stefano Brivio
2026-06-15  2:10     ` David Gibson
2026-06-01  7:37 ` [PATCH v3 4/6] dhcp: Refactor fill_one() to operate on a generic buffer Anshu Kumari
2026-06-02  2:25   ` David Gibson
2026-06-01  7:37 ` [PATCH v3 5/6] dhcp: Add option overload Anshu Kumari
2026-06-02  2:50   ` David Gibson
2026-06-11 23:04   ` Stefano Brivio
2026-06-01  7:37 ` [PATCH v3 6/6] doc: Add --dhcp-boot and --dhcp-opt to man page Anshu Kumari
2026-06-02  2:54   ` David Gibson
2026-06-11 23:05   ` Stefano Brivio

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=ai9e5jzhoajDDbTS@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).