mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 01:42:15 +00:00
feat(dhcp): an ipxe node gets no boot file over DHCPv6
dhcp6_bootfile_url_for_node writes RFC 5970 option 59 for grub2 alone, so a node with netboot=ipxe takes its reserved IPv6 address and has nothing to load. Its firmware then releases the address and solicits again. grub2 was the only loader an IPv6 node could use. The iPXE build xCAT ships does speak DHCPv6: snponly.efi, the UEFI loader of ipxe-xcat 2.0.0, carries dhcpv6, ipv6 and four IPv6 strings, against a control of 26 iPXE and dhcp strings in the same binary. The firmware that solicits over DHCPv6 is UEFI, so the UEFI loader is the only one such a client can ask for. An ipxe node now gets tftp://<bracketed server>/<UEFI loader>, and the loader name comes from BootPolicy->x86_loader, which is the one place it is chosen. No URL is written when that file is not on disk, because naming a file the TFTP server does not have costs the client a timeout it cannot diagnose; the Kea client classes already refuse it for the same reason. xnba keeps its exclusion. Its loader reports one ipv6 string against a control of five, where the iPXE loader reports five against 26, so there is no evidence it reads option 59. Captured by xCAT-test/unit/dhcp_dhcpv6_duid.t. Removing ipxe from the gate fails the first assertion; removing the on-disk check fails the second. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -4491,7 +4491,8 @@ sub dhcp6_bootfile_url_for_node
|
||||
return unless $netboot
|
||||
&& ($netboot eq 'grub2'
|
||||
|| $netboot eq 'grub2-http'
|
||||
|| $netboot eq 'grub2-tftp');
|
||||
|| $netboot eq 'grub2-tftp'
|
||||
|| $netboot eq 'ipxe');
|
||||
|
||||
my $server = dhcp6_boot_server_for_node($node, $peer, $nrent);
|
||||
return unless $server;
|
||||
@@ -4499,12 +4500,27 @@ sub dhcp6_bootfile_url_for_node
|
||||
my $uri_host = xCAT::NetworkUtils->format_uri_host($server);
|
||||
return unless $uri_host;
|
||||
|
||||
my $boot_tftpdir = ( ( $nrent && $nrent->{tftpdir} ) || $tftpdir );
|
||||
|
||||
if ($netboot eq 'ipxe') {
|
||||
# The firmware that solicits over DHCPv6 is UEFI, so the UEFI loader is the only one
|
||||
# such a client can ask for. The iPXE build xCAT ships reports dhcpv6 and ipv6, which
|
||||
# the xnba loader does not, so xnba still gets no option 59.
|
||||
my $loader = xCAT::DHCP::BootPolicy->x86_loader( method => 'ipxe' )->{uefi};
|
||||
return unless $loader;
|
||||
|
||||
# Naming a file the TFTP server does not have costs the client a timeout it cannot
|
||||
# diagnose, which is why the Kea client classes check the loader the same way.
|
||||
return if defined $boot_tftpdir && !-e "$boot_tftpdir/$loader";
|
||||
return "tftp://$uri_host/$loader";
|
||||
}
|
||||
|
||||
# grub2_node_loader is the one place the boot file name of a grub2 node is chosen, so
|
||||
# an aarch64 node gets the .efi name its firmware requests over IPv6 as well as IPv4.
|
||||
my $loader = xCAT::DHCP::BootPolicy->grub2_node_loader(
|
||||
node => $node,
|
||||
arch => $ntent && $ntent->{arch},
|
||||
tftpdir => ( ( $nrent && $nrent->{tftpdir} ) || $tftpdir ),
|
||||
tftpdir => $boot_tftpdir,
|
||||
);
|
||||
return "tftp://$uri_host/boot/grub2/$loader";
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ use lib "$FindBin::Bin/../../xCAT-server/lib";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use JSON ();
|
||||
use Test::More;
|
||||
@@ -266,6 +268,39 @@ sub isc_hosts {
|
||||
'ISC: an xnba node gets no bootfile-url' );
|
||||
}
|
||||
|
||||
# ---- An ipxe node gets the UEFI loader over DHCPv6 -------------------------------------------
|
||||
# The firmware that solicits over DHCPv6 is UEFI, and the iPXE build xCAT ships reports dhcpv6
|
||||
# and ipv6 where the xnba loader does not. Without option 59 such a node takes the reserved
|
||||
# address and has nothing to load.
|
||||
{
|
||||
local %DUIDTable::rows = node_rows(%settings);
|
||||
|
||||
my $present = tempdir( CLEANUP => 1 );
|
||||
my $loader = 'xcat/ipxe/x86_64-sb/snponly-shim.efi';
|
||||
make_path( dirname("$present/$loader") );
|
||||
open( my $fh, '>', "$present/$loader" ) or die "cannot write the loader: $!";
|
||||
print {$fh} "loader\n";
|
||||
close($fh);
|
||||
my $absent = tempdir( CLEANUP => 1 );
|
||||
|
||||
$DUIDTable::rows{noderes}{cn02} =
|
||||
{ netboot => 'ipxe', tftpserver => '2001:db8:176::1', tftpdir => $present };
|
||||
$DUIDTable::rows{noderes}{cn03} =
|
||||
{ netboot => 'ipxe', tftpserver => '2001:db8:176::1', tftpdir => $absent };
|
||||
|
||||
my $config = empty_config();
|
||||
my %kea = map { $_->{hostname} => $_ } @{ kea_reservations( $config, 'cn02', 'cn03' ) };
|
||||
|
||||
my ($with) = grep { $_->{name} eq 'bootfile-url' } @{ $kea{cn02}{'option-data'} || [] };
|
||||
is( $with && $with->{data}, "tftp://[2001:db8:176::1]/$loader",
|
||||
'an ipxe node gets the UEFI loader from the bracketed IPv6 server' );
|
||||
|
||||
# Naming a file the TFTP server does not have costs the client a timeout it cannot
|
||||
# diagnose, so no option is better than a wrong one.
|
||||
my ($without) = grep { $_->{name} eq 'bootfile-url' } @{ $kea{cn03}{'option-data'} || [] };
|
||||
is( $without, undef, 'an ipxe node whose loader is not on disk gets no bootfile-url' );
|
||||
}
|
||||
|
||||
# ---- Each backend builds the DUID that mac.duid selects --------------------------------------------
|
||||
{
|
||||
local %DUIDTable::rows = node_rows(%settings);
|
||||
|
||||
Reference in New Issue
Block a user