2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-21 01:42:15 +00:00

fix(xcat-core): a DHCPv6 reservation carries a DUID the client does not send

makedhcp reversed the first three fields of vpd.uuid to build the DUID-UUID,
and the OpenEmbedded Genesis image reported product_uuid in the opposite order
to the legacy image. Kea matched neither reservation, so an IPv6 node took a
pool address with no bootfile-url.

vpd.uuid holds the sixteen octets in the order the client sends them. kvm.pm
swaps the first three SMBIOS fields to build the libvirt <uuid>, dodiscovery
and doxcat swap product_uuid before they report or send it, and both DHCP
backends on master use the column as the DUID payload unchanged. On xcat76-cn
the firmware sent 00:04 followed by that column verbatim.

kea_duid_from_uuid now colonises vpd.uuid and prefixes 00:04, and
genesis-discover reports the DMI uuid in the same order as its legacy sibling.
The s390x and device-tree paths read their uuid elsewhere and are untouched.

Five assertions in dhcp_kea_plugin_intent.t and the genesis-discover assertion
in genesis_openembedded_discovery.bats fail without this change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-24 08:03:29 -03:00
parent 6382f7baae
commit 9e234189ef
2 changed files with 25 additions and 17 deletions
@@ -76,6 +76,21 @@ read_value() {
tr -d '\000\r\n' <"$value_file" | head -c 512
}
# sysfs renders the SMBIOS UUID canonically, and SMBIOS 2.6 and later store the first three fields
# little-endian. vpd.uuid holds the raw order: dodiscovery swaps them, kvm.pm swaps them back to
# build the libvirt <uuid>, and makedhcp uses the column as the DUID-UUID payload. Report the same
# order, or one machine has two vpd.uuid values depending on the Genesis generation.
smbios_uuid_order() {
local value=$1 pair='[0-9a-fA-F]{2}'
if [[ $value =~ ^($pair)($pair)($pair)($pair)-($pair)($pair)-($pair)($pair)(-.+)$ ]]; then
value=${BASH_REMATCH[4]}${BASH_REMATCH[3]}${BASH_REMATCH[2]}${BASH_REMATCH[1]}
value+=-${BASH_REMATCH[6]}${BASH_REMATCH[5]}
value+=-${BASH_REMATCH[8]}${BASH_REMATCH[7]}${BASH_REMATCH[9]}
fi
printf '%s' "$value"
}
read_sysinfo_value() {
local name=$1
@@ -142,7 +157,8 @@ esac
product_name=$(read_value "$sys_root/sys/devices/virtual/dmi/id/product_name" || true)
system_vendor=$(read_value "$sys_root/sys/devices/virtual/dmi/id/sys_vendor" || true)
serial=$(read_value "$sys_root/sys/devices/virtual/dmi/id/product_serial" || true)
uuid=$(read_value "$sys_root/sys/devices/virtual/dmi/id/product_uuid" || true)
uuid=$(smbios_uuid_order \
"$(read_value "$sys_root/sys/devices/virtual/dmi/id/product_uuid" || true)")
machine_type=
s390_virtual=
[[ -z $system_vendor && -z $product_name ]] \
+8 -16
View File
@@ -802,9 +802,7 @@ sub addnode6 {
#don't think dhclient is smart enough to assemble advertised domain with it's own name and then
#request FQDN update
#goal is simple enough, we want `hostname` to look sane *and* we want DNS to look right
# The same DUID-UUID the Kea path builds: the first three UUID fields are reversed, because
# SMBIOS stores them little-endian and a UEFI client sends them that way. One sub, so the two
# backends cannot disagree about what a client's DUID looks like.
# One sub, so the two backends cannot disagree about what a client's DUID looks like.
my $uuid = kea_duid_from_uuid($ent->{uuid});
# A uuid that is not sixteen octets has no DUID. The old inline transformation produced a
# malformed string and wrote it to omshell; skipping with the same warning the missing-uuid
@@ -4503,19 +4501,13 @@ sub kea_duid_from_uuid
return unless $uuid;
$uuid =~ s/[^0-9a-fA-F]//g;
return unless length($uuid) == 32;
# RFC 6355 carries the sixteen octets of the UUID as the FIRMWARE holds them. SMBIOS 2.6 and
# later store time_low, time_mid and time_hi_and_version little-endian, and vpd.uuid holds the
# canonical spelling that Linux reports in product_uuid, so the first three fields are reversed
# here. Without this the DUID does not match what the client sends, Kea never matches the
# reservation, and the node takes a pool address with no bootfile-url.
my @octets = unpack('(A2)16', $uuid);
@octets = (
reverse(@octets[0 .. 3]),
reverse(@octets[4 .. 5]),
reverse(@octets[6 .. 7]),
@octets[8 .. 15],
);
return '00:04:' . join(':', @octets);
# RFC 6355 carries the sixteen octets of the UUID in the order the client sends them, and
# vpd.uuid already holds that order: discovery swaps the first three SMBIOS fields before it
# reports them, and kvm.pm swaps them back to build the libvirt <uuid>. A swap here is a
# second one.
$uuid =~ s/(..)/$1:/g;
$uuid =~ s/:$//;
return "00:04:$uuid";
}
sub kea_reservation_matches_for_nodes