Page MenuHomeFreeBSD

loader.efi: Apply command-line DHCP overrides earlier
ClosedPublic

Authored by kgalazka on Thu, Sep 24, 8:48 PM.
Tags
None
Referenced Files
F174690288: D59998.id188005.diff
Mon, Oct 5, 5:41 AM
F174669176: D59998.id188005.diff
Mon, Oct 5, 2:12 AM
F174570245: D59998.id188005.diff
Sun, Oct 4, 6:45 AM
Unknown Object (File)
Sun, Oct 4, 2:45 AM
Unknown Object (File)
Sat, Oct 3, 11:31 PM
Unknown Object (File)
Sat, Oct 3, 11:22 PM
Unknown Object (File)
Sat, Oct 3, 4:45 AM
Unknown Object (File)
Sat, Oct 3, 2:05 AM
Subscribers

Details

Summary

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 <krzysztof.galazka@intel.com>

Sponsored by: Intel Corporation
Assisted by: Github Copilot (GPT-5.6 Sol)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77289
Build 74172: arc lint + arc unit

Event Timeline

The only thing that I worry about in moving this parsing earlier is side effects from env variables taking effect before we have the efi partition list, so things like currdev=disk3p4: stop working. Is that the case?

  • Address @imp comment.

I moved parse_args just before maybe_download_initmd.

I'm not sure if this is the correct way to test it,
but loader.efi started from EFI shell in a VM seems
to respects curdev provides as command-line argument.

  • Address @imp comment.

I moved parse_args just before maybe_download_initmd.

I'm not sure if this is the correct way to test it,
but loader.efi started from EFI shell in a VM seems
to respects curdev provides as command-line argument.

That's the right way to test it :) There's half a dozen different ways to get currdev correctly on the command line, and shell it the easiest and best because it is a common workaround to have a startup.nsh launch the boot loader because the firmware doesn't get something right.

This revision is now accepted and ready to land.Fri, Sep 25, 3:07 PM

I had claude look at this, and it likes it, but added there's a possible refinement that makes sense to me.

  1. bootp.c:476-480 (if (tag == TAG_ROOTPATH) { if (getenv("dhcp.root-path")==NULL) val=cp; strlcpy(...) }) is now dead weight. setenv_() (line 458) already promotes DHCP option 17 into dhcp.root-path with overwrite=0 (preserves a pre-set override), and dev_net.c's new exit: block unconditionally re-copies that same env var into rootpath right after. Same value gets written twice from two files. Could collapse the bootp.c branch to a plain strlcpy(rootpath, (const char *)cp, sizeof(rootpath)) and let dev_net.c own the override entirely.

So consider this to be a nice to have addition.

  • Collapse the bootp.c TAG_ROOTPATH branch to a plain strlcpy
This revision now requires review to proceed.Tue, Sep 29, 2:41 PM

I like this.

And I have a bunch of changes in this area I need to carefully review, so I'll add you to the reviews. I think I'll have them later today.

This revision was not accepted when it landed; it landed in state Needs Review.Tue, Sep 29, 7:56 PM
This revision was automatically updated to reflect the committed changes.