2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-30 14:22:23 +00:00

fix(dhcp): no range6 is written for an IPv6 subnet that has a dynamic range

addnet6 read the dynamic range from $netcfgs{$net}, where $net is the subnet it
writes, "2001:db8:156::/64". addrangedetection stores the range under
networks.net, "2001:db8:156::", so the lookup always missed and makedhcp warned
"No dynamic range specified" for a network whose row declares one.

The subnet then carried no range6, and a DHCPv6 client whose DUID matches no
reservation received no address. The SUSE installer is such a client: linuxrc
builds its own DUID rather than the DUID-UUID the firmware sends, so it could
not get an address even though the node has a reservation for the same MAC.

dynamic_range_for() looks the range up under the subnet as written and then
under the network address alone.

xCAT-test/unit/dhcp_dhcpv6_conf_file.t fails its prefix-form assertion when the
second lookup is removed.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-28 12:40:44 -03:00
parent 19779fa2f8
commit 60d0176d14
+32 -3
View File
@@ -79,7 +79,7 @@ my %kea_effective_service_owners;
my %kea_local_server_cache;
our $dhcpconffile = $^O eq 'aix' ? '/etc/dhcpsd.cnf' : '/etc/dhcpd.conf';
my %dynamicranges; #track dynamic ranges defined to see if a host that resolves is actually a dynamic address
my %netcfgs;
our %netcfgs;
our $distro = xCAT::Utils->osver();
my $checkdomain=0;
@@ -5071,6 +5071,34 @@ sub putmyselffirst {
return $srvlist;
}
#-------------------------------------------------------------------------------
=head3 dynamic_range_for
Descriptions: The dynamic range of a subnet, as ISC writes it.
Arguments: the subnet, as the DHCP configuration names it
Returns: the range, or undef when the subnet has none.
addrangedetection keys the ranges on networks.net, which carries no prefix
length, while addnet6 names a subnet "<net>/<prefix>". A lookup under the
long form found nothing, so an IPv6 subnet never got a range6 and any client
whose DUID does not match a reservation received no address at all.
=cut
#-------------------------------------------------------------------------------
sub dynamic_range_for
{
my ($net) = @_;
return unless defined $net;
my $cfg = $netcfgs{$net};
return $cfg->{range} if $cfg and $cfg->{range};
(my $bare = $net) =~ s{/.*$}{};
$cfg = $netcfgs{$bare};
return $cfg ? $cfg->{range} : undef;
}
sub addnet6
{
if ($::XCATSITEVALS{externaldhcpservers}) { return; }
@@ -5174,8 +5202,9 @@ sub addnet6
key_name => $settings ? $settings->{key_name} : undef,
zones => [ getzonesfornet($net) ],
);
if ($netcfgs{$net}->{range}) {
push @netent, " range6 " . $netcfgs{$net}->{range} . ";\n";
my $dynamic_range = dynamic_range_for($net);
if ($dynamic_range) {
push @netent, " range6 " . $dynamic_range . ";\n";
} else {
$callback->({ warning => ["No dynamic range specified for $net. Hosts with no static address will receive no addresses on this subnet."] });
}