mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
loader.efi: Apply command-line DHCP overrides earlier
Ability to override DHCP options with command-line arguments was affected by intoduction of initmd support. Initmd discovery configures the network before loader arguments were parsed, so a dhcp.root-path override was unavailable during the first network configuration. Move parsing arguments earlier and apply dhcp.root-path even if DHCP response does not contain option 17. This allows providing a dynamic NFS root e.g. by chain loading loader.efi from iPXE. Signed-off-by: Krzysztof Galazka <[email protected]> Reviewed by: imp Assisted by: Github Copilot (GPT-5.6 Sol) Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D59998
This commit is contained in:
1 parent
3893050bc1
commit
c4640126f1
3 files changed
+10
-4
No files matched your search
@@ -248,6 +248,7 @@ static int
|
||||
net_getparams(int sock)
|
||||
{
|
||||
char buf[MAXHOSTNAMELEN];
|
||||
const char *val;
|
||||
n_long rootaddr, smask;
|
||||
|
||||
#ifdef SUPPORT_BOOTP
|
||||
@@ -306,6 +307,8 @@ net_getparams(int sock)
|
||||
return (EIO);
|
||||
}
|
||||
exit:
|
||||
if ((val = getenv("dhcp.root-path")) != NULL)
|
||||
strlcpy(rootpath, val, sizeof(rootpath));
|
||||
if ((rootaddr = net_parse_rootpath()) != htonl(INADDR_NONE))
|
||||
rootip.s_addr = rootaddr;
|
||||
|
||||
|
||||
@@ -1382,6 +1382,12 @@ main(int argc, CHAR16 *argv[])
|
||||
|
||||
devinit();
|
||||
|
||||
/*
|
||||
* Parse command line arguments before any operation that may configure
|
||||
* the network so DHCP overrides are available on the first attempt.
|
||||
*/
|
||||
howto = parse_args(argc, argv);
|
||||
|
||||
/*
|
||||
* If we didn't find a ipxe image, and we're netbooting, try to
|
||||
* download an initmd that the dhcp server tells us about.
|
||||
@@ -1394,7 +1400,6 @@ main(int argc, CHAR16 *argv[])
|
||||
* args (eg -h) or via the UEFI ConOut variable.
|
||||
*/
|
||||
has_kbd = has_keyboard();
|
||||
howto = parse_args(argc, argv);
|
||||
if (!has_kbd && (howto & RB_PROBE))
|
||||
howto |= RB_SERIAL | RB_MULTIPLE;
|
||||
howto &= ~RB_PROBE;
|
||||
|
||||
+1
-3
@@ -474,9 +474,7 @@ vend_rfc1048(u_char *cp, u_int len)
|
||||
bcopy(cp, &rootip.s_addr, sizeof(rootip.s_addr));
|
||||
}
|
||||
if (tag == TAG_ROOTPATH) {
|
||||
if ((val = getenv("dhcp.root-path")) == NULL)
|
||||
val = (const char *)cp;
|
||||
strlcpy(rootpath, val, sizeof(rootpath));
|
||||
strlcpy(rootpath, (const char *)cp, sizeof(rootpath));
|
||||
}
|
||||
if (tag == TAG_HOSTNAME) {
|
||||
if ((val = getenv("dhcp.host-name")) == NULL)
|
||||
|
||||
Reference in new issue
Block a user