From 596450159788ef29c34312857e185b8ee5645fd6 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Sun, 8 Nov 2026 06:48:31 -0300 Subject: [PATCH] fix(xcat-core): a KVM node reserves its IPv6 address for the wrong byte order makedhcp derived the DHCPv6 address reservation of a node from the byte swap of vpd.uuid, on the grounds that EDK2 copies the SMBIOS UUID bytes into its DUID and SMBIOS stores the first three fields little-endian. That holds for a physical node. For a KVM guest that xCAT defines it is wrong: getNodeUUID writes the byte swap of vpd.uuid into the libvirt domain, qemu stores that little-endian in SMBIOS, and the two swaps cancel, so the firmware of the guest sends vpd.uuid unswapped. Measured on xcat88-cn: the firmware and the OpenEmbedded Genesis image both sent 00:04:0c:3f:8d:41:... from vpd.uuid 0c3f8d41-6a52-4e7b-..., while iPXE sent the swap. The address was reserved for the swap, so the image took an address from the dynamic range and xcatd could not name it. dhcp6_firmware_uuid_order reads nodehm.mgt and answers canonical for a kvm node and firmware for any other, and dhcp6_client_duid uses it when the node sets no duid attribute. A node that names an order itself is unchanged. dhcp6_firmware_uuid_order.t covers the predicate. dhcp_dhcpv6_duid.t asserts that a kvm node holds its address on the canonical order and that a node xCAT does not define keeps the swap. Both fail with the predicate forced to one order. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/dhcp6_firmware_uuid_order.t | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 xCAT-test/unit/dhcp6_firmware_uuid_order.t diff --git a/xCAT-test/unit/dhcp6_firmware_uuid_order.t b/xCAT-test/unit/dhcp6_firmware_uuid_order.t new file mode 100644 index 0000000000..8b88853499 --- /dev/null +++ b/xCAT-test/unit/dhcp6_firmware_uuid_order.t @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +# Which byte order of vpd.uuid the firmware of a node sends in its DUID-UUID, which decides which +# DHCPv6 client of the node the reserved address belongs to. +# +# EDK2 copies the SMBIOS UUID bytes into its DUID, and SMBIOS 2.6 and later store the first three +# fields little-endian, so on a physical node the firmware sends the byte swap of the vpd.uuid +# text. A KVM guest that xCAT defines is the other way round: getNodeUUID writes the byte swap of +# vpd.uuid into the libvirt domain, qemu stores THAT little-endian, and the two swaps cancel. The +# firmware of such a guest sends vpd.uuid unswapped, which is the RFC 4122 or canonical order. +# +# Measured 2026-11-08 on xcat88-cn: the firmware and the OpenEmbedded Genesis image both sent +# 00:04:0c:3f:8d:41:... from vpd.uuid 0c3f8d41-6a52-4e7b-..., the canonical order, while iPXE sent +# the swap. The address was reserved for the swap, so Genesis took a dynamic address and xcatd +# could not name it. +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../../perl-xCAT"; + +use Test::More; +use xCAT::DHCP::BootPolicy; + +can_ok( 'xCAT::DHCP::BootPolicy', 'dhcp6_firmware_uuid_order' ); + +sub order_for { + my (@args) = @_; + my $out = eval { xCAT::DHCP::BootPolicy->dhcp6_firmware_uuid_order(@args) }; + diag($@) if $@; + return $out; +} + +is( order_for('kvm'), 'canonical', + 'xCAT defines the domain of a kvm node, so its firmware sends vpd.uuid unswapped' ); +is( order_for('KVM'), 'canonical', 'the mgt value is matched without regard to case' ); + +foreach my $mgt ( 'ipmi', 'openbmc', 'hmc', 'blade', '' ) { + is( order_for($mgt), 'firmware', + "a node managed by '$mgt' has firmware that swaps the bytes of vpd.uuid" ); +} +is( order_for(undef), 'firmware', 'a node with no mgt attribute is treated as physical' ); +is( order_for(), 'firmware', 'no argument is treated as physical' ); + +done_testing();