mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-19 17:02:15 +00:00
fix(xcat-core): an IPv6 server is unreadable in the netboot kernel command line
root=nfs:, XCAT=, xcatd= and imgurl=http:// all separate the server from what follows with a colon, so an IPv6 address in any of them cannot be told from the path or the port. Eight sites built those values by interpolation, and a diskless, statelite or cloned node of any family took a command line its initrd could not parse. build_statelite_nfsroot_parameter brackets the server, which covers the NFS root of all three netboot plugins at once. debian.pm and sles.pm now build the XCAT endpoint and the image URL through xcatd_cmdline_address and format_host_port, as anaconda.pm already did for the install path, and the mksysclone endpoint of anaconda.pm and sles.pm goes the same way. destiny.pm had a third xcatd= site. The earlier change covered the two genesis branches and left the legacy nbk branch interpolating the address. nfs_root_options.t asserts the bracketed form, the IPv4 form and the mount options after a bracketed address. Removing the brackets fails 2 of its 80 assertions and leaves the IPv4 and the name cases passing. zvm.pm carries the same pattern and is left alone: z/VM has no IPv6 netboot path to test it on. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -2613,8 +2613,14 @@ sub build_statelite_nfsroot_parameter {
|
||||
my ($additional_mount_options, $error) = _parse_statelite_nfsroot_options($additional_options);
|
||||
return (undef, $error) if $error;
|
||||
|
||||
# root=nfs: separates the server, the directory and the options with colons, so an IPv6
|
||||
# server has to be bracketed or the directory cannot be told from the address. dracut and
|
||||
# mount.nfs both read the bracketed form. All three netboot plugins build it here.
|
||||
my $authority = xCAT::NetworkUtils->format_uri_host($server);
|
||||
return (undef, "Unable to render the NFS root server $server") unless defined($authority);
|
||||
|
||||
my @mount_options = ('ro', @{$additional_mount_options});
|
||||
return ('root=nfs:' . $server . ':' . $rootdir . ':' . join(',', @mount_options), undef);
|
||||
return ('root=nfs:' . $authority . ':' . $rootdir . ':' . join(',', @mount_options), undef);
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -2243,7 +2243,8 @@ sub mksysclone
|
||||
$kcmdline .= "n8r";
|
||||
}
|
||||
}
|
||||
$kcmdline .= " XCAT=$xcatmaster:$xcatdport xcatd=$xcatmaster:$xcatdport SCRIPTNAME=$imagename";
|
||||
my $xcat_endpoint = xCAT::NetworkUtils::xcatd_cmdline_address($xcatmaster, $xcatdport);
|
||||
$kcmdline .= " XCAT=$xcat_endpoint xcatd=$xcat_endpoint SCRIPTNAME=$imagename";
|
||||
|
||||
my $k;
|
||||
my $i;
|
||||
|
||||
@@ -1830,7 +1830,8 @@ sub mknetboot
|
||||
$kcmdline = "NFSROOT=$nfssrv:$nfsdir STATEMNT=";
|
||||
}
|
||||
} else {
|
||||
$kcmdline = "imgurl=http://$imgsrv:$httpport/$rootimgdir/rootimg-statelite.gz STATEMNT=";
|
||||
$kcmdline = "imgurl=http://" . xCAT::NetworkUtils->format_host_port($imgsrv, $httpport)
|
||||
. "/$rootimgdir/rootimg-statelite.gz STATEMNT=";
|
||||
$kcmdline = $checksum_arg . $kcmdline;
|
||||
}
|
||||
|
||||
@@ -1859,7 +1860,7 @@ sub mknetboot
|
||||
}
|
||||
$kcmdline .= $statemnt . " ";
|
||||
$kcmdline .=
|
||||
"XCAT=$xcatmaster:$xcatdport ";
|
||||
"XCAT=" . xCAT::NetworkUtils::xcatd_cmdline_address($xcatmaster, $xcatdport) . " ";
|
||||
$kcmdline .=
|
||||
"NODE=$node ";
|
||||
|
||||
@@ -1887,10 +1888,10 @@ sub mknetboot
|
||||
else
|
||||
{
|
||||
$kcmdline =
|
||||
"imgurl=http://$imgsrv:$httpport/$rootimgdir/$compressedrootimg ";
|
||||
"imgurl=http://" . xCAT::NetworkUtils->format_host_port($imgsrv, $httpport) . "/$rootimgdir/$compressedrootimg ";
|
||||
$kcmdline .= $checksum_arg;
|
||||
$kcmdline .= $uftp_args;
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
$kcmdline .= "XCAT=" . xCAT::NetworkUtils::xcatd_cmdline_address($xcatmaster, $xcatdport) . " ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -701,7 +701,8 @@ sub setdestiny {
|
||||
if (-r "$tftpdir/xcat/nbk.$arch") {
|
||||
$bphash->{$_}->[0]->{kernel} = "xcat/nbk.$arch";
|
||||
$bphash->{$_}->[0]->{initrd} = "xcat/nkfs.$arch.gz";
|
||||
$bphash->{$_}->[0]->{kcmdline} = $kcmdline . "xcatd=$master:$xcatdport";
|
||||
$bphash->{$_}->[0]->{kcmdline} = $kcmdline . "xcatd="
|
||||
. xCAT::NetworkUtils::xcatd_cmdline_address($master, $xcatdport);
|
||||
$callback->({ warning => ["No genesis.kernel.$arch file found. Defaulting to legacy nbk.$arch"]});
|
||||
} else { # can not find genesis.kernel or nbk file
|
||||
$callback->({ error => ["Could not find genesis.kernel.$arch or legacy nbk.$arch files"], errorcode => [1] });
|
||||
|
||||
@@ -579,7 +579,7 @@ sub mknetboot
|
||||
$kcmdline .= $checksum_arg;
|
||||
$kcmdline .= $uftp_args;
|
||||
}
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
$kcmdline .= "XCAT=" . xCAT::NetworkUtils::xcatd_cmdline_address($xcatmaster, $xcatdport) . " ";
|
||||
$kcmdline .= " XCATHTTPPORT=$httpport ";
|
||||
|
||||
#if site.nodestatus="n", append "nonodestatus" to kcmdline
|
||||
@@ -1537,7 +1537,8 @@ sub mksysclone
|
||||
}
|
||||
}
|
||||
}
|
||||
$kcmdline .= " XCAT=$xcatmaster:$xcatdport xcatd=$xcatmaster:$xcatdport SCRIPTNAME=$imagename";
|
||||
my $xcat_endpoint = xCAT::NetworkUtils::xcatd_cmdline_address($xcatmaster, $xcatdport);
|
||||
$kcmdline .= " XCAT=$xcat_endpoint xcatd=$xcat_endpoint SCRIPTNAME=$imagename";
|
||||
|
||||
$bootparams->{$node}->[0]->{kernel} = "xcat/$genesis_kernel";
|
||||
$bootparams->{$node}->[0]->{initrd} = "xcat/$genesis_initrd";
|
||||
|
||||
@@ -159,6 +159,33 @@ for my $owner ([anaconda => 'rhels8'], [debian => 'ubuntu24.04'], [sles => 'sles
|
||||
}
|
||||
}
|
||||
|
||||
# root=nfs: separates the server, the directory and the options with colons, so an IPv6 server
|
||||
# has to be bracketed. All three netboot plugins build the parameter here, so one test covers EL,
|
||||
# Ubuntu and SUSE.
|
||||
{
|
||||
my ($nfsroot, $error) = xCAT::SvrUtils->build_statelite_nfsroot_parameter(
|
||||
'2001:db8::1', '/install/netboot/rhels10.0/x86_64/compute/rootimg', undef);
|
||||
is($error, undef, 'an IPv6 NFS root server is accepted');
|
||||
is($nfsroot, 'root=nfs:[2001:db8::1]:/install/netboot/rhels10.0/x86_64/compute/rootimg:ro',
|
||||
'and is bracketed, so the directory can be told from the address');
|
||||
|
||||
($nfsroot, $error) = xCAT::SvrUtils->build_statelite_nfsroot_parameter(
|
||||
'192.0.2.1', '/install/netboot/rhels10.0/x86_64/compute/rootimg', undef);
|
||||
is($nfsroot, 'root=nfs:192.0.2.1:/install/netboot/rhels10.0/x86_64/compute/rootimg:ro',
|
||||
'an IPv4 server is left as it was');
|
||||
|
||||
($nfsroot, $error) = xCAT::SvrUtils->build_statelite_nfsroot_parameter(
|
||||
'mn.cluster', '/install/netboot/rhels10.0/x86_64/compute/rootimg', undef);
|
||||
is($nfsroot, 'root=nfs:mn.cluster:/install/netboot/rhels10.0/x86_64/compute/rootimg:ro',
|
||||
'and so is a name, which the resolver in the image handles');
|
||||
|
||||
# The options still follow the directory, which is what the colons have to keep apart.
|
||||
($nfsroot, $error) = xCAT::SvrUtils->build_statelite_nfsroot_parameter(
|
||||
'2001:db8::1', '/rootimg', 'nolock,vers=3');
|
||||
is($nfsroot, 'root=nfs:[2001:db8::1]:/rootimg:ro,nolock,vers=3',
|
||||
'the mount options are still readable after a bracketed address');
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
sub set_row {
|
||||
|
||||
Reference in New Issue
Block a user