From aba7b8028897d8be934a6cb024598d9f4825006b Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 5 Nov 2026 09:45:49 -0300 Subject: [PATCH] fix(xcat-core): an IPv6 node gets a boot script whose URLs carry no host xnba.pm started its script server at ${next-server} and replaced it only when the IPv6 lookup answered. An IPv6 node for which this server has no facing IPv6 address therefore kept the DHCPv4 variable, an IPv6 client resolved it to the empty string, every URL in the script lost its host, and nodeset reported success. ipxe.pm runs the same code with SCRIPTS set to xcat/ipxe, so netboot=ipxe took the same path. NetworkUtils gains ipxe_script_server_for_node, which makes the decision and returns either the server or a reason. No value serves such a node, so xnba.pm now stops with that reason instead of writing a script that cannot work. netboot_ipxe_method.t and secureboot_ipxe_node_shim.t replace the whole NetworkUtils module through %INC, so the new sub is stubbed there as well; both carry IPv4 nodes, for which the real sub answers the iPXE variable. Restoring the old behaviour in the new sub -- keep ${next-server} when the lookup does not answer -- fails eight of the sixteen assertions in ipxe_script_server_for_node.t and leaves the IPv4, unknown-family and IPv6-with-an-address outcomes passing. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- perl-xCAT/xCAT/NetworkUtils.pm | 37 ++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/xnba.pm | 15 +++------ xCAT-test/unit/netboot_ipxe_method.t | 3 ++ xCAT-test/unit/secureboot_ipxe_node_shim.t | 3 ++ 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index c73c1527db..c0335905d1 100644 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -4006,6 +4006,43 @@ sub ipxe_script_server { #------------------------------------------------------------------------------- +=head3 ipxe_script_server_for_node + + Descriptions: The server that the iPXE boot script of one node names, or nothing and the + reason there is none. + + xnba.pm kept ${next-server} whenever the IPv6 lookup did not answer. An IPv6 + client resolves that DHCPv4 variable to the empty string, so every URL in the + script loses its host and nodeset still reports success. There is no value + that works for such a node, so the caller is given a reason instead. + + Arguments: $node + Returns: ($server, undef), or (undef, $reason) + +=cut + +#------------------------------------------------------------------------------- +sub ipxe_script_server_for_node { + my ($class, $node) = @_; + + my $family = $class->node_address_family($node) || 4; + return ('${next-server}', undef) unless $family == 6; + + # my_ip_facing resolves with inet_aton and reports an IPv6-only node unresolvable, so the + # lookup has to name the family. + my @facing = $class->my_ip_facing_family($node, 6); + my $facing = ( @facing && !$facing[0] ) ? $facing[1] : undef; + my $server = ipxe_script_server(6, $facing); + return ($server, undef) if defined $server; + + return (undef, + "$node provisions over IPv6 and no IPv6 address of this server faces it, so every URL" + . " in its boot script would carry no host. Give the provisioning interface an address" + . " in the IPv6 network of $node."); +} + +#------------------------------------------------------------------------------- + =head3 radvd_config Descriptions: The radvd configuration for the IPv6 networks xCAT serves. diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index c3c0ec88b7..d9668cfa1e 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -232,16 +232,11 @@ sub setstate { my $elilokcmdline = $kern->{kcmdline}; #track it separate, since vars differ my $pxelinuxkcmdline = $kern->{kcmdline}; #track it separate, since vars differ # next-server is a DHCPv4 field. An IPv6 node resolves it to nothing, so every URL in - # the script loses its host. Such a node carries the facing address instead, bracketed. - # my_ip_facing resolves with inet_aton and reports an IPv6-only node unresolvable, so the - # lookup has to name the family. - my $script_server = '${next-server}'; - if ((xCAT::NetworkUtils->node_address_family($node) || 4) == 6) { - my @facing = xCAT::NetworkUtils->my_ip_facing_family($node, 6); - my $resolved = $facing[0] ? undef - : xCAT::NetworkUtils::ipxe_script_server(6, $facing[1]); - $script_server = $resolved if defined $resolved; - } + # the script loses its host. There is no value that serves such a node when no IPv6 + # address faces it, which is why this stops instead of keeping the variable. + my ($script_server, $script_server_error) = + xCAT::NetworkUtils->ipxe_script_server_for_node($node); + return (1, $script_server_error) if defined $script_server_error; if ($kern->{kcmdline} =~ /!myipfn!/) { my $ipfn = $script_server; diff --git a/xCAT-test/unit/netboot_ipxe_method.t b/xCAT-test/unit/netboot_ipxe_method.t index f375e79e96..1577176004 100644 --- a/xCAT-test/unit/netboot_ipxe_method.t +++ b/xCAT-test/unit/netboot_ipxe_method.t @@ -35,6 +35,9 @@ BEGIN { # can reach. These nodes are IPv4, which keeps ${next-server} in the script. sub node_address_family { return 4 } sub my_ip_facing_family { return (0, '192.0.2.1') } + # This file replaces the whole module through %INC, so the decision xnba.pm asks for has to + # be here too. These nodes are IPv4, and the real sub answers the iPXE variable for IPv4. + sub ipxe_script_server_for_node { return ('${next-server}', undef) } package xCAT::TableUtils; sub getTftpDir { return $tftp } diff --git a/xCAT-test/unit/secureboot_ipxe_node_shim.t b/xCAT-test/unit/secureboot_ipxe_node_shim.t index 3a6f5fc88b..0ec5cb7e1b 100644 --- a/xCAT-test/unit/secureboot_ipxe_node_shim.t +++ b/xCAT-test/unit/secureboot_ipxe_node_shim.t @@ -37,6 +37,9 @@ BEGIN { # can reach. These nodes are IPv4, which keeps ${next-server} in the script. sub node_address_family { return 4 } sub my_ip_facing_family { return (0, '192.0.2.1') } + # This file replaces the whole module through %INC, so the decision xnba.pm asks for has to + # be here too. These nodes are IPv4, and the real sub answers the iPXE variable for IPv4. + sub ipxe_script_server_for_node { return ('${next-server}', undef) } package xCAT::TableUtils; sub getTftpDir { return $tftp }