From 82d39637a693426552b58419c2cf24f72d1e3332 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Sun, 8 Nov 2026 11:02:56 -0300 Subject: [PATCH 1/2] test(xcat-core): an unknown DHCPv6 client needs the second boot stage named kea_client_classes6 names the shim for an unknown client, which answers the firmware. The shim starts iPXE, and iPXE solicits again with the iPXE user class. A client xCAT has never seen matches no per-node class, so its only match is the architecture class, and it is handed the shim a second time. It never fetches a kernel and never sends a findme, so sequential discovery over IPv6 cannot start. The new assertions ask for an iPXE second-stage class carrying the per-network script that mknb writes, and for it to be offered before the architecture class, because Kea takes the first class that defines an option. All four fail on this commit. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/dhcp6_boot_client_classes.t | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/xCAT-test/unit/dhcp6_boot_client_classes.t b/xCAT-test/unit/dhcp6_boot_client_classes.t index f8b70d58b1..742fda3f19 100644 --- a/xCAT-test/unit/dhcp6_boot_client_classes.t +++ b/xCAT-test/unit/dhcp6_boot_client_classes.t @@ -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' ); From a8d482cdb149d1809c150d4c30c3d5c97b28fd39 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Sun, 8 Nov 2026 11:02:56 -0300 Subject: [PATCH 2/2] fix(xcat-core): an unknown DHCPv6 client is handed the shim twice kea_client_classes6 built one class per client architecture, each naming the signed iPXE shim. That answers the firmware. The shim starts iPXE, which solicits again carrying the iPXE user class, and a client xCAT has never seen matches no per-node class: its only match is the same architecture class, so it is given the shim again and never fetches a kernel. The Genesis image never runs, no findme reaches xcatd, and sequential discovery over IPv6 cannot start. The DHCPv4 side has carried this second stage for years in kea_xnba_network_classes, keyed on option 93. kea_client_classes6 now also builds an iPXE second-stage class for the network, naming the per-network script mknb writes under xcat/ipxe/nets, which carries destiny=discover and no node name. The class is offered before the architecture class, because Kea takes the first class that defines an option. kea_boot_client_classes6 passes the network and its prefix length, which name that script. Measured on xcat88-mn: /tftpboot/xcat/ipxe/nets holds 2001:db8:188::_64.uefi and no DHCPv6 class named it. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- perl-xCAT/xCAT/DHCP/BootPolicy.pm | 26 ++++++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/dhcp.pm | 7 ++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/DHCP/BootPolicy.pm b/perl-xCAT/xCAT/DHCP/BootPolicy.pm index a8e2891f2f..9465d40acc 100644 --- a/perl-xCAT/xCAT/DHCP/BootPolicy.pm +++ b/perl-xCAT/xCAT/DHCP/BootPolicy.pm @@ -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. diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index d40a267827..467f3aa20a 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -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.