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 }