mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-19 17:02:15 +00:00
7514b931b3
xnba.pm writes ${next-server} in place of !myipfn! and lets iPXE fill it from
the DHCP offer. next-server is a DHCPv4 field, so an IPv6 node resolves it to
the empty string and every URL in the script loses its host. The fallback does
not help either: my_ip_facing resolves with inet_aton, so it reports an
IPv6-only node unresolvable.
The script now carries the facing address of the management node when the node
has an IPv6 address, bracketed because the script puts it in a URL. The lookup
names the family, the way grub2.pm does. An IPv4 node keeps ${next-server}, so
nothing changes for it.
ipxe.pm runs this code with SCRIPTS and METHOD set to its own, so the change
reaches netboot=ipxe as well as netboot=xnba.
xnba.pm also calls xCAT::NetworkUtils eight times without loading it, and works
only because another module does. The use is now explicit.
Captured by xCAT-test/unit/ipxe_script_server.t. Ignoring the family fails five
of its seven assertions and leaves the two IPv4 ones passing.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
39 lines
1.8 KiB
Perl
39 lines
1.8 KiB
Perl
#!/usr/bin/env perl
|
|
#
|
|
# The server an iPXE boot script names for a node.
|
|
#
|
|
# xnba.pm writes ${next-server} into the script and lets iPXE fill it from the DHCP offer.
|
|
# next-server is a DHCPv4 field, so an IPv6 node resolves it to nothing and every URL in the
|
|
# script loses its host. ipxe.pm runs the same code, so this reaches netboot=ipxe as well.
|
|
use strict;
|
|
use warnings;
|
|
|
|
use FindBin;
|
|
use Test::More tests => 7;
|
|
|
|
use lib "$FindBin::Bin/../../perl-xCAT";
|
|
use xCAT::NetworkUtils;
|
|
|
|
is( xCAT::NetworkUtils::ipxe_script_server(4, '192.0.2.1'), '${next-server}',
|
|
'an IPv4 node keeps the iPXE variable, which iPXE fills from its own offer' );
|
|
is( xCAT::NetworkUtils::ipxe_script_server(undef, '192.0.2.1'), '${next-server}',
|
|
'a node of unknown family keeps the variable, so nothing changes for it' );
|
|
|
|
# The script puts the server in a URL, so an IPv6 literal needs its brackets.
|
|
is( xCAT::NetworkUtils::ipxe_script_server(6, '2001:db8::1'), '[2001:db8::1]',
|
|
'an IPv6 node carries the address, bracketed' );
|
|
is( xCAT::NetworkUtils::ipxe_script_server(6, 'mn.cluster.example'), 'mn.cluster.example',
|
|
'a name is carried as it is, because a name needs no brackets' );
|
|
|
|
# Without a facing address there is nothing to name. ${next-server} would be worse than
|
|
# nothing: it resolves to the empty string and the URL loses its host silently.
|
|
is( xCAT::NetworkUtils::ipxe_script_server(6, undef), undef,
|
|
'an IPv6 node with no facing address yields nothing' );
|
|
is( xCAT::NetworkUtils::ipxe_script_server(6, ''), undef,
|
|
'and an empty facing address yields nothing' );
|
|
|
|
# The whole point is that the two families differ here.
|
|
isnt( xCAT::NetworkUtils::ipxe_script_server(6, '2001:db8::1'),
|
|
xCAT::NetworkUtils::ipxe_script_server(4, '192.0.2.1'),
|
|
'the two families are not given the same text' );
|