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=AnB+iqr4; 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 611EF5A061C for ; Thu, 16 Apr 2026 18:21:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776356507; 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=1MDKgYoloaXt7L9crNW1Nnee1ikNrrSdgGvAoviRrtM=; b=AnB+iqr41KKIkJTs6H9jPPHDO2Ih3SrstuEkEeD/s74dweCbW34tdEl0Z3BJJsxn7jErhN Qp+ubsDF9i4Uhf22d0lTfpC8BuAZbyCtDRI/rxcLai4931LXhJODZvB6adynn6hbbQOeHZ dYp6VmnSGhzcV2DW3Q5UIxk6ByX+TxE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-399-mNB4E1-CNXyaM0LRpG9Huw-1; Thu, 16 Apr 2026 12:21:46 -0400 X-MC-Unique: mNB4E1-CNXyaM0LRpG9Huw-1 X-Mimecast-MFC-AGG-ID: mNB4E1-CNXyaM0LRpG9Huw_1776356505 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 23B7E19560A6; Thu, 16 Apr 2026 16:21:45 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet01.pony-001.prod.iad2.dc.redhat.com [10.2.32.101]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 114ED1800446; Thu, 16 Apr 2026 16:21:43 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v2 2/2] dhcp: Add --dhcp-boot option to set boot filename in DHCP replies Date: Thu, 16 Apr 2026 18:21:40 +0200 Message-ID: <20260416162140.3830027-3-lvivier@redhat.com> In-Reply-To: <20260416162140.3830027-1-lvivier@redhat.com> References: <20260416162140.3830027-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eo3gW8wIrUNLUHdf_JFVUWztpImLqgFsqO1Wb1TeGd0_1776356505 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: KUZZH66HMJF3CDI4H765Q4POMQ6MUBDH X-Message-ID-Hash: KUZZH66HMJF3CDI4H765Q4POMQ6MUBDH X-MailFrom: lvivier@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: Laurent Vivier , David Gibson 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: 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