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 Reviewed-by: David Gibson > --- > 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