From dc8c5cefedd86d5da4c33bfa5ca90ab4f4264ca0 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Tue, 27 Oct 2026 10:20:52 -0300 Subject: [PATCH] fix(xcat-core): Genesis sends a DUID the reservation does not hold, and makedns aborts on a /62 Both Genesis images built a DUID-UUID from the nil SMBIOS UUID. makedhcp refuses that UUID, because nodeimport writes it to every PowerKVM node, and reserves the hardware address instead, so the client sent an identifier no reservation held and the node took a pool address with no boot file. genesis-duid and doxcat now keep the DUID-LL for it, which is what Kea reads the hardware address out of. getzonesfornet died on an IPv6 prefix that is not a multiple of 4, which took makedns and makedhcp with it for a /62 or a /126 network. A reverse zone is delegated on a nibble, so the prefix is rounded down and the enclosing zone is returned. Both copies of the routine are fixed. The test suite needs socat and jq, and five bats files skipped without them, so the workflow installs both. Template.pm drops the unused _is_el10, credentials.pm drops a repeated import, and two comments that recorded bug history are cut to the fact the code cannot show. Reverting any one fix fails named assertions: 1 of 8 and 1 of 3 bats cases for the two Genesis images, and 4 of 30 in ddns_ipv6.t, which traps the abort so the file still reports. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- .github/workflows/xcat_test.yml | 2 +- perl-xCAT/xCAT/DHCP/Backend/Kea.pm | 5 ++--- .../xcat-genesis-network/files/genesis-duid | 10 +++++++++ xCAT-genesis-scripts/usr/bin/doxcat | 22 ++++++++++++------- xCAT-server/lib/perl/xCAT/Template.pm | 6 ----- xCAT-server/lib/xcat/plugins/credentials.pm | 1 - xCAT-server/lib/xcat/plugins/ddns.pm | 6 ++--- xCAT-server/lib/xcat/plugins/dhcp.pm | 8 +++---- xCAT-server/lib/xcat/plugins/hosts.pm | 6 ++--- xCAT-test/bats/genesis_duid_uuid.bats | 9 ++++++++ xCAT-test/bats/genesis_openembedded_duid.bats | 9 ++++++++ xCAT-test/unit/ddns_ipv6.t | 16 ++++++++++++++ 12 files changed, 70 insertions(+), 30 deletions(-) diff --git a/.github/workflows/xcat_test.yml b/.github/workflows/xcat_test.yml index 63c742b3fb..1716d1b65a 100644 --- a/.github/workflows/xcat_test.yml +++ b/.github/workflows/xcat_test.yml @@ -9,7 +9,7 @@ jobs: - name: Refresh package indexes run: sudo apt-get update - name: Install dependencies - run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests bats bubblewrap cpio xz-utils gzip gawk mawk rpm rsyslog build-essential fakeroot reprepro devscripts debhelper libcapture-tiny-perl libfile-slurper-perl libjson-perl libyaml-pp-perl libparallel-forkmanager-perl libsoap-lite-perl libdbi-perl libdbd-sqlite3-perl libcgi-pm-perl quilt openssh-server dpkg looptools genometools software-properties-common grub-common grub-efi-amd64-bin squashfs-tools pigz python3-yaml + run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests bats bubblewrap cpio xz-utils gzip gawk mawk jq socat rpm rsyslog build-essential fakeroot reprepro devscripts debhelper libcapture-tiny-perl libfile-slurper-perl libjson-perl libyaml-pp-perl libparallel-forkmanager-perl libsoap-lite-perl libdbi-perl libdbd-sqlite3-perl libcgi-pm-perl quilt openssh-server dpkg looptools genometools software-properties-common grub-common grub-efi-amd64-bin squashfs-tools pigz python3-yaml - name: Enable postscript test namespaces run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - name: Install lifecycle test dependencies diff --git a/perl-xCAT/xCAT/DHCP/Backend/Kea.pm b/perl-xCAT/xCAT/DHCP/Backend/Kea.pm index d33d081e36..e9be7e4c6f 100644 --- a/perl-xCAT/xCAT/DHCP/Backend/Kea.pm +++ b/perl-xCAT/xCAT/DHCP/Backend/Kea.pm @@ -807,9 +807,8 @@ sub live_upsert_reservations { ( $identifier_type, $identifier ) = ( 'ip-address', $reservation->{'ip-addresses'}[0] ); } my $key = join('|', - # Copy before lc: map aliases $_ to the hash element, and reading a numeric - # subnet-id in string context attaches a string form to it, so JSON then sends - # "subnet-id":"1" and Kea rejects the update. + # Copy before lc: an aliased $_ makes JSON send the subnet-id as a string, which + # Kea rejects. map { my $v = $_; defined($v) ? lc($v) : '' } $reservation->{'subnet-id'}, $identifier_type, $identifier, ); diff --git a/xCAT-genesis-base/oe/meta-xcat-genesis/recipes-connectivity/xcat-genesis-network/files/genesis-duid b/xCAT-genesis-base/oe/meta-xcat-genesis/recipes-connectivity/xcat-genesis-network/files/genesis-duid index c9341ea032..09e9106ec5 100755 --- a/xCAT-genesis-base/oe/meta-xcat-genesis/recipes-connectivity/xcat-genesis-network/files/genesis-duid +++ b/xCAT-genesis-base/oe/meta-xcat-genesis/recipes-connectivity/xcat-genesis-network/files/genesis-duid @@ -36,6 +36,16 @@ if [ "${#uuid}" -ne 32 ]; then exit 0 fi +# makedhcp refuses the nil UUID, because nodeimport writes it to every PowerKVM node, and +# reserves the hardware address instead. A DUID built from it would match no reservation, so +# keep the DUID-LL that Kea can read the hardware address out of. +case $uuid in + 00000000000000000000000000000000) + log "SMBIOS UUID is the nil UUID, keeping the DUID-LL default" + exit 0 + ;; +esac + # SMBIOS 2.6 and later store the first three UUID fields little-endian, and EDK2 copies # those bytes into its DUID. product_uuid prints the fields in canonical order, so the # first three go back into firmware order here. doxcat and makedhcp do the same swap. diff --git a/xCAT-genesis-scripts/usr/bin/doxcat b/xCAT-genesis-scripts/usr/bin/doxcat index 30ac90e8d9..70b6d4a36d 100755 --- a/xCAT-genesis-scripts/usr/bin/doxcat +++ b/xCAT-genesis-scripts/usr/bin/doxcat @@ -66,14 +66,20 @@ if [ -z "$bootnic" ]; then fi if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then - duid='default-duid "\\000\\004'; - # EDK2 firmware sends the SMBIOS bytes, and product_uuid prints the first three fields byte-swapped. - for i in `sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/;s/-//g;s/\(..\)/\1 /g' /sys/devices/virtual/dmi/id/product_uuid`; do - octnum="\\"`printf "\\%03o" 0x$i` - duid=$duid$octnum - done - duid=$duid'";' - echo $duid > /var/lib/dhclient/dhclient6.leases + # makedhcp refuses the nil UUID and reserves the hardware address instead, so a DUID + # built from it matches no reservation. genesis-duid skips it for the same reason. + if [ "$(tr -d -c '0-9a-fA-F' /var/lib/dhclient/dhclient6.leases + fi fi rpcbind diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index db6cae004e..cb84dffdb6 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -59,12 +59,6 @@ sub httpport_suffix { return xCAT::HTTPUtils::httpport_suffix($httpport); } -sub _is_el10 -{ - my $os = shift; - return defined($os) && $os =~ /^(?:rh\w*|centos|alma|rocky|ol)10(?:\D|$)/i; -} - sub _dynamic_kickstart_network { my ($suffix, $ipv6_only) = @_; diff --git a/xCAT-server/lib/xcat/plugins/credentials.pm b/xCAT-server/lib/xcat/plugins/credentials.pm index 20dc04c40d..9333af6cac 100644 --- a/xCAT-server/lib/xcat/plugins/credentials.pm +++ b/xCAT-server/lib/xcat/plugins/credentials.pm @@ -37,7 +37,6 @@ use Time::HiRes qw(sleep); use xCAT::NetworkUtils; use xCAT::Utils; -use xCAT::NetworkUtils; use xCAT::PasswordUtils; use xCAT::TableUtils; use xCAT::StringUtils qw(trim); diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 41b556889c..2d2fe34dce 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -148,9 +148,9 @@ sub getzonesfornet { my $maskbits = xCAT::NetworkUtils->getIPv6PrefixLength($net, $mask); $net =~ s{/.*$}{}; return @zones unless defined($maskbits); - if ($maskbits % 4) { - die "Not supporting an IPv6 prefix length that is not divisible by 4 on network $net"; - } + # A reverse zone is delegated on a nibble, so a prefix that is not a multiple of 4 has + # no zone of its own. Use the enclosing nibble-aligned zone. + $maskbits -= $maskbits % 4; my $zone = xCAT::NetworkUtils->getIPv6ReverseZone($net, $maskbits); return @zones unless defined($zone); push @zones, $zone; diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 5871554786..2e01b38c2a 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -4952,10 +4952,10 @@ sub getzonesfornet { if ($net =~ /:/) { #ipv6, for now do the simple stuff under the assumption we won't have a mask indivisible by 4 my $maskbits = xCAT::NetworkUtils->getIPv6PrefixLength($net, $mask); return () unless defined($maskbits); - if ($maskbits % 4) { - die "Not supporting an IPv6 prefix length that is not divisible by 4 on network $net"; - } - my $zone = xCAT::NetworkUtils->getIPv6ReverseZone($net, $mask); + # A reverse zone is delegated on a nibble, so a prefix that is not a multiple of 4 has + # no zone of its own. Use the enclosing nibble-aligned zone. + $maskbits -= $maskbits % 4; + my $zone = xCAT::NetworkUtils->getIPv6ReverseZone($net, $maskbits); return defined($zone) ? ($zone) : (); } diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index a08f6a0a2f..11faea5d5e 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -158,10 +158,8 @@ sub _matching_host_indexes { $matches{$_} = 1 foreach keys %{ $host_indexes_by_ip{$key} }; } - # A node name matches only lines of the address family being written. A dual-stack node has - # an A line and an AAAA line under one name, and that is the only way to give it both records - # through /etc/hosts and makedns. Matching across families made the caller overwrite one line - # and blank the other, so writing the IPv4 address deleted the IPv6 entry. + # A dual-stack node has an A line and an AAAA line under one name, so a node name matches + # only lines of the family being written. A delete passes all_families. if (exists($host_indexes_by_node{$node})) { foreach my $idx (keys %{ $host_indexes_by_node{$node} }) diff --git a/xCAT-test/bats/genesis_duid_uuid.bats b/xCAT-test/bats/genesis_duid_uuid.bats index a3b3a9bb84..48715b99f2 100644 --- a/xCAT-test/bats/genesis_duid_uuid.bats +++ b/xCAT-test/bats/genesis_duid_uuid.bats @@ -42,3 +42,12 @@ sent_duid() run_genesis 0 --setenv BOOTIF 01-aa-bb-cc-dd-ee-ff [ ! -e "$leases" ] } + +@test "a machine whose SMBIOS UUID is the nil UUID sends no DUID-UUID" { + # makedhcp refuses the nil UUID and reserves the hardware address, so a DUID built from it + # matches no reservation and the node would take a pool address with no boot file. + printf '00000000-0000-0000-0000-000000000000\n' \ + >"$fixture/sys/devices/virtual/dmi/id/product_uuid" + run_genesis 0 --setenv BOOTIF 01-aa-bb-cc-dd-ee-ff + [ ! -e "$leases" ] +} diff --git a/xCAT-test/bats/genesis_openembedded_duid.bats b/xCAT-test/bats/genesis_openembedded_duid.bats index 1c30ca8e1a..87b78560c4 100644 --- a/xCAT-test/bats/genesis_openembedded_duid.bats +++ b/xCAT-test/bats/genesis_openembedded_duid.bats @@ -91,6 +91,15 @@ ipv6.dhcp-duid=00:04:33:22:11:00:55:44:77:66:88:99:aa:bb:cc:dd:ee:ff' ] grep -F 'no usable SMBIOS UUID' "$XCAT_TEST_LOG" } +@test "a machine whose SMBIOS UUID is the nil UUID keeps the packaged DUID-LL" { + # makedhcp refuses the nil UUID and reserves the hardware address, so a DUID built from it + # would match no reservation. dhcp6_uuid_is_placeholder is the other half of this pair. + run_duid 00000000-0000-0000-0000-000000000000 + [ "$status" -eq 0 ] + [ "$(conf_order)" = 10-xcat-genesis.conf ] + grep -F 'nil UUID' "$XCAT_TEST_LOG" +} + @test "a conf.d directory that cannot be created fails loudly" { # A regular file in the way, so mkdir -p fails for root as well. printf 'not a directory\n' >"$BATS_TEST_TMPDIR/blocked" diff --git a/xCAT-test/unit/ddns_ipv6.t b/xCAT-test/unit/ddns_ipv6.t index 1b3349a774..f943dbfdbd 100644 --- a/xCAT-test/unit/ddns_ipv6.t +++ b/xCAT-test/unit/ddns_ipv6.t @@ -140,6 +140,22 @@ SKIP: { 'ip6.arpa.', 'IPv6 /0 produces the root reverse zone without looping' ); + + # A prefix that is not a multiple of 4 has no reverse zone of its own, because a zone is + # delegated on a nibble. getzonesfornet used to die here and take makedns with it. + foreach my $case ( + [ '2001:db8:7309::/62', '0.0.0.9.0.3.7.8.b.d.0.1.0.0.2.ip6.arpa.', '/62', '/60', 15 ], + [ '2001:db8:7309::1/126', + '0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.0.3.7.8.b.d.0.1.0.0.2.ip6.arpa.', + '/126', '/124', 31 ], + ) + { + my ( $network, $expected, $prefix, $zone_prefix, $nibbles ) = @$case; + my @zones = eval { xCAT_plugin::ddns::getzonesfornet({ net => $network }) }; + ok( !$@, "an IPv6 $prefix does not abort makedns" ); + is( $zones[0], $expected, + "an IPv6 $prefix gives the enclosing $zone_prefix reverse zone, $nibbles nibbles" ); + } my $default_route_ctx = { hoststab => { default01 => [ { ip => '2001:db8::1' } ],