Skip to content

Commit

Permalink
Merge pull request #7 from OpenCHAMI/synackd/tftp-fixes
Browse files Browse the repository at this point in the history
Correct iPXE architecture-bootloader mapping, set root-path for iPXE bootloader
  • Loading branch information
synackd authored Nov 25, 2024
2 parents 6cf014b + a9760e5 commit 43f555d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions coresmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) {
resp.Options.Update(dhcpv4.OptHostName(fmt.Sprintf("nid%03d", ifaceInfo.CompNID)))
}

// Set root path to this server's IP
resp.Options.Update(dhcpv4.OptRootPath(resp.ServerIPAddr.String()))

// STEP 2: Send boot config
if cinfo := req.Options.Get(dhcpv4.OptionUserClassInformation); string(cinfo) != "iPXE" {
// BOOT STAGE 1: Send iPXE bootloader over TFTP
Expand Down
16 changes: 14 additions & 2 deletions internal/ipxe/ipxe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ func ServeIPXEBootloader(l *logrus.Entry, req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHC
l.Debugf("client architecture of %s is %v (%q)", req.ClientHWAddr, carchBytes, string(carchBytes))
carch = iana.Arch(binary.BigEndian.Uint16(carchBytes))
switch carch {
case iana.EFI_IA32:
case iana.INTEL_X86PC:
// iPXE legacy 32-bit x86 bootloader
resp.Options.Update(dhcpv4.OptBootFileName("undionly.kpxe"))
return resp, true
case iana.EFI_IA32:
// iPXE EFI 32-bit bootloader
resp.Options.Update(dhcpv4.OptBootFileName("ipxe-i386.efi"))
return resp, true
case iana.EFI_X86_64:
// iPXE 64-bit x86 bootloader
resp.Options.Update(dhcpv4.OptBootFileName("ipxe.efi"))
resp.Options.Update(dhcpv4.OptBootFileName("ipxe-x86_64.efi"))
return resp, true
case iana.EFI_ARM32:
// iPXE EFI 32-bit ARM bootloader
resp.Options.Update(dhcpv4.OptBootFileName("ipxe-arm32.efi"))
return resp, true
case iana.EFI_ARM64:
// iPXE EFI 64-bit ARM bootloader
resp.Options.Update(dhcpv4.OptBootFileName("ipxe-arm64.efi"))
return resp, true
default:
l.Errorf("no iPXE bootloader available for unknown architecture: %d (%s)", carch, carch.String())
Expand Down

0 comments on commit 43f555d

Please sign in to comment.