2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-22 18:32:13 +00:00

fix(ipv6): an NFS root loses the last group of its IPv6 server

substitute_facing_address brackets the facing address only where a port
follows the placeholder. An NFS root carries the server between two colons,
as in "root=nfs:!myipfn!:/install/netboot", so an IPv6 server came out as
"root=nfs:2001:db8::1:/install/netboot". dracut reads the server up to the
last colon, so it took "2001:db8:" and the statelite node could not mount its
root.

The substitution now also brackets a placeholder that an NFS path follows. A
placeholder with nothing after it still takes the bare address, because
xcatd=!myipfn! names a host with no port and the postscripts read that value
as it stands.

networkutils_ipv6_helpers.t covers both forms in one command line. Removing
the new substitution fails the two IPv6 checks and leaves the IPv4 and
bare-placeholder checks passing.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-30 13:17:23 -03:00
parent c0f8fd42b0
commit 7f46d8dab3
2 changed files with 29 additions and 4 deletions
+10 -4
View File
@@ -4186,10 +4186,11 @@ sub send_tcp_msg {
Returns:
the command line, with the placeholder replaced.
A placeholder that a port follows is bracketed when the address is IPv6,
because "http://2001:db8::1:80/" cannot be split into a host and a port.
Every other placeholder takes the bare address: xcatd=!myipfn! names a host
with no port, and the postscripts read that value as it stands.
A placeholder that a port or an NFS path follows is bracketed when the
address is IPv6, because neither "http://2001:db8::1:80/" nor
"root=nfs:2001:db8::1:/install" can be split at the right colon. Every other
placeholder takes the bare address: xcatd=!myipfn! names a host with no port,
and the postscripts read that value as it stands.
=cut
@@ -4199,7 +4200,12 @@ sub substitute_facing_address {
return $cmdline unless defined($cmdline) && defined($address) && length($address);
if (index($address, ':') >= 0) {
# A port follows the placeholder, as in "http://!myipfn!:80/". Without the brackets
# the port cannot be told from the last group of the address.
$cmdline =~ s/!myipfn!(?=:\d)/[$address]/g;
# An NFS path follows it, as in "root=nfs:!myipfn!:/install". dracut reads the
# server up to the last colon, so an unbracketed address loses its last group.
$cmdline =~ s{!myipfn!(?=:/)}{[$address]}g;
}
$cmdline =~ s/!myipfn!/$address/g;
return $cmdline;
@@ -718,4 +718,23 @@ SKIP: {
'a value that is neither a host nor the placeholder is still refused' );
}
# An NFS root carries the server between two colons: "root=nfs:<server>:/install". dracut
# reads the server up to the last colon, so an unbracketed IPv6 address lost its last group
# and a statelite node could not mount its root.
is( xCAT::NetworkUtils::substitute_facing_address('root=nfs:!myipfn!:/install/netboot', '2001:db8::1'),
'root=nfs:[2001:db8::1]:/install/netboot',
'an NFS server is bracketed before its path' );
is( xCAT::NetworkUtils::substitute_facing_address('root=nfs:!myipfn!:/install/netboot', '192.0.2.1'),
'root=nfs:192.0.2.1:/install/netboot',
'an IPv4 NFS server is left alone' );
is( xCAT::NetworkUtils::substitute_facing_address('imgurl=http://!myipfn!:80/x root=nfs:!myipfn!:/y', '2001:db8::1'),
'imgurl=http://[2001:db8::1]:80/x root=nfs:[2001:db8::1]:/y',
'a port and an NFS path are both bracketed in one command line' );
is( xCAT::NetworkUtils::substitute_facing_address('xcatd=!myipfn!', '2001:db8::1'),
'xcatd=2001:db8::1',
'a placeholder with nothing after it still takes the bare address' );
is( xCAT::NetworkUtils::substitute_facing_address('path=!myipfn!/install', '2001:db8::1'),
'path=2001:db8::1/install',
'a slash that no colon precedes does not bracket' );
done_testing();