From c59021e408dad3da3aa5bb0cb98f2147d21e30e7 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 28 Oct 2026 09:46:30 -0300 Subject: [PATCH] fix(dhcp): no DHCPv6 configuration is written on openSUSE ISC serves DHCPv4 and DHCPv6 from two files in the same directory. dhcp.pm set the v6 file inside the branch that switches the v4 file to /etc/dhcp/dhcpd.conf. openSUSE already has /etc/dhcpd.conf, so the branch never ran, $dhcp6conffile stayed undef, and makedhcp wrote no IPv6 configuration. dhcpd6 then exited with "No subnet6 declaration for eth1" and no node could get an IPv6 lease. dhcp6_conf_file_for() now returns the v6 file that belongs beside a given v4 file, and the module derives it after every branch that chooses the v4 file. xCAT-test/unit/dhcp_dhcpv6_conf_file.t fails on the openSUSE and /etc/dhcp3 layouts when the derivation is restricted to /etc/dhcp again. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-server/lib/xcat/plugins/dhcp.pm | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 984e5991cb..9bb8380ec3 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -84,10 +84,9 @@ our $distro = xCAT::Utils->osver(); my $checkdomain=0; # dhcp 4.x will use /etc/dhcp/dhcpd.conf as the config file -my $dhcp6conffile; +our $dhcp6conffile; if ($^O ne 'aix' and not -e $dhcpconffile and -d "/etc/dhcp") { - $dhcpconffile = '/etc/dhcp/dhcpd.conf'; - $dhcp6conffile = '/etc/dhcp/dhcpd6.conf'; + $dhcpconffile = '/etc/dhcp/dhcpd.conf'; } my $usingipv6; @@ -105,6 +104,33 @@ if ($distro =~ /ubuntu.*/) { } } +#------------------------------------------------------- + +=head3 dhcp6_conf_file_for + + Descriptions: The DHCPv6 configuration file that belongs beside a DHCPv4 one. + ISC serves the two families from two files in the same directory, + and the directory differs per distro: openSUSE keeps + /etc/dhcpd.conf, dhcp 4.x uses /etc/dhcp/dhcpd.conf. + Arguments: the DHCPv4 configuration file + Returns: the DHCPv6 configuration file, or undef where there is no ISC v6 file +=cut + +#------------------------------------------------------- +sub dhcp6_conf_file_for +{ + my ($conffile) = @_; + return undef unless defined $conffile; + return undef unless $conffile =~ /dhcpd\.conf$/; + $conffile =~ s/dhcpd\.conf$/dhcpd6.conf/; + return $conffile; +} + +# Derived from the v4 file, which every branch above may have changed. Deriving it inside one +# of those branches left it undef on openSUSE, where /etc/dhcpd.conf already exists, so +# makedhcp wrote no IPv6 configuration at all and dhcpd6 had no subnet6 to serve. +$dhcp6conffile = dhcp6_conf_file_for($dhcpconffile); + sub check_uefi_support { my $ntent = shift; my %blacklist = (