From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 2/2] dhcp: Add --dhcp-boot option to set boot filename in DHCP replies
Date: Tue, 7 Apr 2026 13:46:01 +1000 [thread overview]
Message-ID: <adR9-XJYkx8RO6eD@zatzit> (raw)
In-Reply-To: <20260403080204.2364581-3-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4195 bytes --]
On Fri, Apr 03, 2026 at 10:02:04AM +0200, Laurent Vivier wrote:
> Add a --dhcp-boot option that populates the 'file' field in DHCP reply
> messages with the given filename.
>
> Using --dhcp-boot together with --no-dhcp is rejected at startup.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> conf.c | 10 ++++++++++
> dhcp.c | 5 ++++-
> passt.1 | 6 ++++++
> passt.h | 1 +
> 4 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/conf.c b/conf.c
> index ae37bf96dac4..2cf1bc7420d3 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -984,6 +984,7 @@ static void usage(const char *name, FILE *f, int status)
> " --no-udp Disable UDP protocol handler\n"
> " --no-icmp Disable ICMP/ICMPv6 protocol handler\n"
> " --no-dhcp Disable DHCP server\n"
> + " --dhcp-boot FILE DHCP boot filename option\n"
> " --no-ndp Disable NDP responses\n"
> " --no-dhcpv6 Disable DHCPv6 server\n"
> " --no-ra Disable router advertisements\n"
> @@ -1537,6 +1538,7 @@ void conf(struct ctx *c, int argc, char **argv)
> {"migrate-exit", no_argument, NULL, 29 },
> {"migrate-no-linger", no_argument, NULL, 30 },
> {"stats", required_argument, NULL, 31 },
> + {"dhcp-boot", required_argument, NULL, 32 },
> { 0 },
> };
> const char *optstring = "+dqfel:hs:F:I:p:P:m:a:n:M:g:i:o:D:S:H:461t:u:T:U:";
> @@ -1775,6 +1777,11 @@ 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 32:
> + if (snprintf_check(c->dhcp_boot, sizeof(c->dhcp_boot),
> + "%s", optarg))
> + die("Invalid DHCP bootfile name: %s", optarg);
> + break;
> case 'd':
> c->debug = 1;
> c->quiet = 0;
> @@ -2206,6 +2213,9 @@ void conf(struct ctx *c, int argc, char **argv)
> c->no_dhcpv6 = 1;
> }
>
> + if (c->no_dhcp && c->dhcp_boot[0])
> + die("--dhcp-boot cannot be used with --no-dhcp");
> +
> get_dns(c);
>
> if (!*c->pasta_ifn) {
> diff --git a/dhcp.c b/dhcp.c
> index 1ff8cba9f93d..7fdb6e051dec 100644
> --- a/dhcp.c
> +++ b/dhcp.c
> @@ -344,6 +344,9 @@ int dhcp(const struct ctx *c, struct iov_tail *data)
> m->op != BOOTREQUEST)
> return -1;
>
> + static_assert(sizeof(reply.file) == sizeof(c->dhcp_boot),
> + "dhcp_boot must have the same size as reply.file");
> +
> reply.op = BOOTREPLY;
> reply.htype = m->htype;
> reply.hlen = m->hlen;
> @@ -357,7 +360,7 @@ int dhcp(const struct ctx *c, struct iov_tail *data)
> reply.giaddr = m->giaddr;
> memcpy(&reply.chaddr, m->chaddr, sizeof(reply.chaddr));
> memset(&reply.sname, 0, sizeof(reply.sname));
> - memset(&reply.file, 0, sizeof(reply.file));
> + memcpy(&reply.file, c->dhcp_boot, sizeof(reply.file));
> reply.magic = m->magic;
>
> for (i = 0; i < ARRAY_SIZE(opts); i++)
> diff --git a/passt.1 b/passt.1
> index 13e8df9de9f3..a6ac2884bf3f 100644
> --- a/passt.1
> +++ b/passt.1
> @@ -342,6 +342,12 @@ Disable the DHCP server. DHCP client requests coming from guest or target
> namespace will be silently dropped. Implied if there is no gateway on the
> selected IPv4 default route.
>
> +.TP
> +.BR \-\-dhcp-boot " " \fIfile
> +Set the boot filename in DHCP replies to \fIfile\fR. This populates the
> +\fIfile\fR field in BOOTP/DHCP reply messages, which can be used for
> +network booting (PXE). Cannot be used with \fB--no-dhcp\fR.
> +
> .TP
> .BR \-\-no-ndp
> Disable Neighbor Discovery. NDP messages coming from guest or target
> diff --git a/passt.h b/passt.h
> index 62b8dcdf0a41..4044a4c07ea3 100644
> --- a/passt.h
> +++ b/passt.h
> @@ -255,6 +255,7 @@ struct ctx {
>
> char hostname[PASST_MAXDNAME];
> char fqdn[PASST_MAXDNAME];
> + char dhcp_boot[128];
>
> int ifi6;
> struct ip6_ctx ip6;
> --
> 2.53.0
>
--
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 --]
prev parent reply other threads:[~2026-04-07 3:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 8:02 [PATCH 0/2] vhost-user, dhcp: Fix iPXE network boot over vhost-user Laurent Vivier
2026-04-03 8:02 ` [PATCH 1/2] vhost_user: Offer VIRTIO_NET_F_GUEST_CSUM Laurent Vivier
2026-04-07 3:44 ` David Gibson
2026-04-03 8:02 ` [PATCH 2/2] dhcp: Add --dhcp-boot option to set boot filename in DHCP replies Laurent Vivier
2026-04-07 3:46 ` David Gibson [this message]
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=adR9-XJYkx8RO6eD@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/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).