2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-23 19:02:17 +00:00

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>
This commit is contained in:
Daniel Hilst
2026-11-05 09:45:49 -03:00
parent 7f2fd291aa
commit aba7b80288
4 changed files with 48 additions and 10 deletions
+37
View File
@@ -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.
+5 -10
View File
@@ -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;
+3
View File
@@ -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 }
@@ -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 }