From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MVizyp41; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 2717D5A0262 for ; Wed, 20 May 2026 02:38:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779237499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nX1ZcZgnF7egbXhJojmAvgHVupL7VhjnIfc8xhhb1yQ=; b=MVizyp41YGqRyvh5p4FUneo7Sb3dPfTNk3t7FUsfPR5NLUnuAIviyOOFGeJ8fYRKFuOAOL HnGo9+2qbhvGgzI5dD+JcqCgdclWqfW+uLYp7JGYddgmIIUe0+rPCMjeL9A1JvtIptHR8D gxII6bFsVW6XtUBsuGvBPkkgR/4CwLM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-FszYDyWiP6e2ZX6cK6DMcg-1; Tue, 19 May 2026 20:38:17 -0400 X-MC-Unique: FszYDyWiP6e2ZX6cK6DMcg-1 X-Mimecast-MFC-AGG-ID: FszYDyWiP6e2ZX6cK6DMcg_1779237496 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48e79219704so29891795e9.1 for ; Tue, 19 May 2026 17:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779237496; x=1779842296; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nX1ZcZgnF7egbXhJojmAvgHVupL7VhjnIfc8xhhb1yQ=; b=H1tfqaa6iYxzrNX6EM0SNWatpKpUwhymQr/3zAK4snM3GuZQg16H6gWvUcVzN8VW/d mJnKSinSXTAJOlA1c1l8K0+TiNyvikRQayRYbSXx84lt3AQoVqOBIwrsbVWkeRq8lp5i Obyf8i83AqxJavxTXAYHoE9c8/faVOiHwuQqFOQFaEZNK0jX3QNgR2AKnvHDk2v7gBqt HLUF3aAx7xrKjb82ICH/X7MOTkloX51dRrB5C8gAZZ2peH8IsOZD7z6LXSz3yeXQVC6N uBa5c03ifAKJ+okXB6mwxVS9caYqyikpcNFVcpBMnarflC1+YX2ZJRbt456X+UPmJedE YsBA== X-Gm-Message-State: AOJu0Yz25jepGL12XNBMlo5cdLbJ09dPoV43brH3CULn1wI9fcIB8ptx zAxW6SY283Xl7zCpBROKUW5Mx2uHbSZoO5NwnxWpGRF4NJZrnckwQVf7LT1txU3W9EYhGkYk0hp MHq/TiPL9xl2z00b7SjV7sk9f1gMHC/snIZJcPNT72jXLF6pf36aVxg== X-Gm-Gg: Acq92OHlQqsIfOms6ruiP6D8jjTjFXTo3vMOvYt5vr9ozKBOfGhNznNEcOEiVFqJkxi iLKuEIF+0F53GZ0fRbQLJ/PdNnsiNzweVdvZZ698ZZLZpkAGLzrZZ02OQeFCuutu3QycVhQlhLh wkUcGWYzt48mm5EbY0dCgwEUJn9J7n1bYKk7PVHbijX0Kec3eq2TJ4gg6IlIU2133DIHx6LvExI VSQYb8cwiPovsRLyEfZ5ffRrOtcQQfNDNaDxWEFfTxCXaBpDvq2h2+/2qQ80jNIfSmKFaYB7iUc EhG/UQ1kqPQD2F2vJc04nkvNAijHn2enLkgWnPkCWqc3W9ow5x5g/mp8jIqmo9Lkd+0GNaFoj3C cW4oJM157bryf/X+6Phj4F2GgtA7qcaer X-Received: by 2002:a05:600c:4a1a:b0:48a:592c:e655 with SMTP id 5b1f17b1804b1-48fe6325f25mr203448075e9.17.1779237495963; Tue, 19 May 2026 17:38:15 -0700 (PDT) X-Received: by 2002:a05:600c:4a1a:b0:48a:592c:e655 with SMTP id 5b1f17b1804b1-48fe6325f25mr203447915e9.17.1779237495526; Tue, 19 May 2026 17:38:15 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe4c833fcsm358550875e9.2.2026.05.19.17.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 17:38:15 -0700 (PDT) From: Stefano Brivio To: Anshu Kumari Subject: Re: [PATCH 1/6] conf: Add --dhcp-opt command-line option Message-ID: <20260520023813.1bb36a9a@elisabeth> In-Reply-To: <20260518132002.418296-2-anskuma@redhat.com> References: <20260518132002.418296-1-anskuma@redhat.com> <20260518132002.418296-2-anskuma@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Wed, 20 May 2026 02:38:14 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2bG1Ut6GCsMFLx7GI5-I8pSdpSkUml_Mt3tBMBV3Gqg_1779237496 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: AJ5CILQJ55FAKKM4RQ53X5CPU7MC73A2 X-Message-ID-Hash: AJ5CILQJ55FAKKM4RQ53X5CPU7MC73A2 X-MailFrom: sbrivio@redhat.com 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, lvivier@redhat.com, jmaloy@redhat.com, david@gibson.dropbear.id.au 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: On Mon, 18 May 2026 18:49:57 +0530 Anshu Kumari wrote: > Introduce the --dhcp-opt flag that allows setting arbitrary DHCP > options from command-line in the form of [Option CODE,VALUE]. > This patch adds the option storage in struct ctx and CLI parsing; > the type-aware value parser and DHCP reply injection follow > in subsequent patches. > > Link: https://bugs.passt.top/show_bug.cgi?id=192 > Signed-off-by: Anshu Kumari > --- > conf.c | 36 +++++++++++++++++++++++++++++++++++- > passt.h | 10 ++++++++++ > 2 files changed, 45 insertions(+), 1 deletion(-) > > diff --git a/conf.c b/conf.c > index 029b9c7..2624e58 100644 > --- a/conf.c > +++ b/conf.c > @@ -47,6 +47,7 @@ > #include "lineread.h" > #include "isolation.h" > #include "log.h" > +#include "dhcp.h" > #include "vhost_user.h" > #include "epoll_ctl.h" > #include "conf.h" > @@ -616,7 +617,8 @@ static void usage(const char *name, FILE *f, int status) > " -S, --search LIST Space-separated list, search domains\n" > " a single, empty option disables the DNS search list\n" > " -H, --hostname NAME Hostname to configure client with\n" > - " --fqdn NAME FQDN to configure client with\n"); > + " --fqdn NAME FQDN to configure client with\n" > + " --dhcp-opt CODE,VAL Set DHCP option by code\n"); > if (strstr(name, "pasta")) > FPRINTF(f, " default: don't use any search list\n"); > else > @@ -844,6 +846,10 @@ static void conf_print(const struct ctx *c) > info(" router: %s", > inet_ntop(AF_INET, &c->ip4.guest_gw, > buf, sizeof(buf))); > + for (i = 0; i < c->custom_opts_count; i++) > + info(" option %u: %s", > + c->custom_opts[i].code, > + c->custom_opts[i].str); > } > > for (i = 0; i < ARRAY_SIZE(c->ip4.dns); i++) { > @@ -1233,6 +1239,7 @@ void conf(struct ctx *c, int argc, char **argv) > {"migrate-no-linger", no_argument, NULL, 30 }, > {"stats", required_argument, NULL, 31 }, > {"conf-path", required_argument, NULL, 'c' }, > + {"dhcp-opt", required_argument, NULL, 33 }, > { 0 }, > }; > const char *optstring = "+dqfel:hs:c:F:I:p:P:m:a:n:M:g:i:o:D:S:H:461t:u:T:U:"; > @@ -1465,6 +1472,33 @@ void conf(struct ctx *c, int argc, char **argv) > die("Can't display statistics if not running in foreground"); > c->stats = strtol(optarg, NULL, 0); > break; > + case 33: { > + unsigned long code; > + const char *comma; > + char *end; > + > + comma = strchr(optarg, ','); > + if (!comma) > + die("--dhcp-opt requires Option CODE,VALUE format"); > + > + code = strtoul(optarg, &end, 0); > + if (end != comma || code < 1 || code > 254) > + die("DHCP option code must be 1-254: %s", > + optarg); > + > + if (c->custom_opts_count >= MAX_CUSTOM_DHCP_OPTS) > + die("Too many --dhcp-opt entries (max %d)", > + MAX_CUSTOM_DHCP_OPTS); > + > + c->custom_opts[c->custom_opts_count].code = code; > + if (snprintf_check(c->custom_opts[c->custom_opts_count].str, > + sizeof(c->custom_opts[0].str), > + "%s", comma + 1)) > + die("DHCP option value too long: %s", > + comma + 1); > + c->custom_opts_count++; > + break; > + } > case 'd': > c->debug = 1; > c->quiet = 0; > diff --git a/passt.h b/passt.h > index 1726965..acb57dd 100644 > --- a/passt.h > +++ b/passt.h > @@ -263,6 +263,16 @@ struct ctx { > char hostname[PASST_MAXDNAME]; > char fqdn[PASST_MAXDNAME]; > > +#define MAX_CUSTOM_DHCP_OPTS 32 > + > + struct { > + uint8_t code; > + uint8_t len; > + uint8_t val[255]; > + char str[256]; > + } custom_opts[MAX_CUSTOM_DHCP_OPTS]; > + int custom_opts_count; Assuming you actually need those fields here (but the same reasoning would apply to another struct as well): we document structs and fields (and enums, and functions) using the so-called kerneldoc style: https://docs.kernel.org/doc-guide/kernel-doc.html Just look at the beginning of struct ctx: you'll find those comments. They need to be updated when you add / change / remove fields. > + > int ifi6; > struct ip6_ctx ip6; > -- Stefano