mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-22 18:32:13 +00:00
Merge remote-tracking branch 'origin/fix/dhcp6-reserved-address-reclaim-hold' into releases/2.20.0-rc9
This commit is contained in:
@@ -101,6 +101,32 @@ sub kea_client_classes6 {
|
||||
|
||||
my @classes;
|
||||
|
||||
# The second stage, before the first. The architecture class below answers the firmware and
|
||||
# hands it the shim. The shim starts iPXE, which solicits again with the iPXE user class, and
|
||||
# a client xCAT has never seen matches no per-node class: its only other match is that
|
||||
# architecture class, so it is handed the shim a second time and never fetches a kernel. mknb
|
||||
# writes a per-network script carrying destiny=discover and no node name, and nothing else
|
||||
# names it over DHCPv6. Kea takes the first class that defines an option, so this one is
|
||||
# offered first.
|
||||
if ( $opts{ipxe_uefi}
|
||||
&& defined( $opts{net} )
|
||||
&& length( $opts{net} )
|
||||
&& defined( $opts{prefix} )
|
||||
&& length( $opts{prefix} ) )
|
||||
{
|
||||
my $scripts = $class->x86_loader( method => 'ipxe' )->{scripts};
|
||||
my $network_id = $opts{net} . '_' . $opts{prefix};
|
||||
my $safe = $network_id;
|
||||
$safe =~ s/[^A-Za-z0-9_.-]/_/g;
|
||||
push @classes, {
|
||||
name => "xcat-ipxe6-net-$safe$sfx",
|
||||
test => dhcp6_ipxe_user_class_test()
|
||||
. " and (option[61].hex == 0x0007 or option[61].hex == 0x0009)",
|
||||
'option-data' =>
|
||||
[ kea_bootfile_url6_option("http://$host/tftpboot/$scripts/nets/$network_id.uefi") ],
|
||||
};
|
||||
}
|
||||
|
||||
# A UEFI client is the only x86 client that solicits over DHCPv6, so the BIOS loader has no
|
||||
# DHCPv6 class. Both architecture ids are in use: firmware reports 0x0007, and 0x0009 appears
|
||||
# on the same machines once the loader chainloads.
|
||||
|
||||
@@ -5454,8 +5454,13 @@ sub kea_boot_client_classes6
|
||||
my $uri_host = xCAT::NetworkUtils->format_uri_host( $facing[1] );
|
||||
return [] unless $uri_host;
|
||||
|
||||
# mknb names the per-network boot script after the network and its prefix length, so the
|
||||
# class that offers it needs both.
|
||||
my ( $netaddr, $prefixlen ) = split( m{/}, ( defined($net) ? $net : '' ), 2 );
|
||||
|
||||
return xCAT::DHCP::BootPolicy->kea_client_classes6(
|
||||
kea_ipxe_loader_flags(), uri_host => $uri_host, suffix => $id );
|
||||
kea_ipxe_loader_flags(), uri_host => $uri_host, suffix => $id,
|
||||
net => $netaddr, prefix => $prefixlen );
|
||||
}
|
||||
|
||||
# Which upstream loader files the local TFTP tree has, as the Kea class builders take them.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# So classes could not reach the config even once something built them.
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 11;
|
||||
use Test::More tests => 15;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use JSON;
|
||||
@@ -89,3 +89,27 @@ is( $rv && $rv->{'option-data'}[0]{data}, "tftp://$host/boot/grub2/grub2.riscv64
|
||||
my $no_loader = classes6( uri_host => $host, ipxe_uefi => 0, tftpdir => '/tftpboot' );
|
||||
is( scalar( grep { $_->{test} =~ /0x0007/ } @$no_loader ), 0,
|
||||
'with no iPXE shim on disk the x86_64 class is left out rather than pointing at nothing' );
|
||||
|
||||
# --- the SECOND stage, which is what a findme needs ---------------------------------------------
|
||||
# The class above answers the firmware and hands it the shim. The shim starts iPXE, which solicits
|
||||
# again carrying the iPXE user class. A client xCAT has never seen matches no per-node class, so
|
||||
# its only match is the architecture class above and it is handed the shim a second time. It never
|
||||
# fetches a kernel and never sends a findme. mknb writes a per-network script that carries
|
||||
# destiny=discover and no node name; nothing named it over DHCPv6.
|
||||
my $withnet = classes6( uri_host => $host, ipxe_uefi => 1, tftpdir => '/tftpboot',
|
||||
net => '2001:db8:188::', prefix => 64 );
|
||||
my ($second) = grep { $_->{test} =~ /iPXE/ } @$withnet;
|
||||
ok( $second, 'an iPXE second-stage class is built for the network' );
|
||||
is( $second && $second->{'option-data'}[0]{data},
|
||||
"http://$host/tftpboot/xcat/ipxe/nets/2001:db8:188::_64.uefi",
|
||||
'and it names the per-network script mknb wrote, the one carrying destiny=discover' );
|
||||
like( $second ? $second->{test} : '', qr/option\[61\]/,
|
||||
'it is scoped to an x86_64 UEFI client, not to every iPXE client' );
|
||||
|
||||
# Ordering is half the fix. Kea takes the first class that defines an option, so the second stage
|
||||
# must be offered before the architecture class that names the shim.
|
||||
my ($ipxe_at) = grep { $withnet->[$_]{test} =~ /iPXE/ } 0 .. $#$withnet;
|
||||
my ($arch_at) =
|
||||
grep { $withnet->[$_]{test} =~ /0x0007/ && $withnet->[$_]{test} !~ /iPXE/ } 0 .. $#$withnet;
|
||||
ok( defined($ipxe_at) && defined($arch_at) && $ipxe_at < $arch_at,
|
||||
'the second stage is matched before the first, or iPXE is handed the shim again' );
|
||||
|
||||
Reference in New Issue
Block a user