From 60d0176d14c746d4ff7b92f69f64fd362334de5e Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:40:44 -0300 Subject: [PATCH] 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> --- xCAT-server/lib/xcat/plugins/dhcp.pm | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 9bb8380ec3..aa2a7b8c78 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -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 "/". 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."] }); }