diff --git a/xCAT-test/autotest/testcase/makedhcp/cases0 b/xCAT-test/autotest/testcase/makedhcp/cases0 index b04b9db534..7c8113979d 100644 --- a/xCAT-test/autotest/testcase/makedhcp/cases0 +++ b/xCAT-test/autotest/testcase/makedhcp/cases0 @@ -243,10 +243,12 @@ check:rc==0 cmd:mkdef -t network -o ci-ipv6 net=2001:db8:176:: mask=/64 mgtifname=$$SECONDNIC dynamicrange=2001:db8:176::1000-2001:db8:176::1fff check:rc==0 # A node that answers only on IPv6. Its uuid is fixed, because the DUID asserted below is derived -# from it and a generated uuid would make the expected value unknowable. +# from it and a generated uuid would make the expected value unknowable. The spelling is the one +# discovery writes: dodiscovery and genesis-discover swap the first three SMBIOS fields, so the +# libvirt domain this uuid describes reports product_uuid c78c76bf-3286-46f3-b80d-8fe079dd6de7. cmd:mkdef -t node ci-ipv6-cn groups=all mgt=kvm netboot=grub2 ip=2001:db8:176::20 mac=aa:bb:cc:dd:ee:01 check:rc==0 -cmd:chtab node=ci-ipv6-cn vpd.uuid=c78c76bf-3286-46f3-b80d-8fe079dd6de7 +cmd:chtab node=ci-ipv6-cn vpd.uuid=bf768cc7-8632-f346-b80d-8fe079dd6de7 check:rc==0 cmd:makehosts ci-ipv6-cn check:rc==0 @@ -259,10 +261,10 @@ check:rc==0 # Kea must accept its own configuration. A reservation xCAT renders and Kea rejects serves nobody. cmd:kea-dhcp6 -t /etc/kea/kea-dhcp6.conf check:rc==0 -# The DUID, read out of the JSON and compared EXACTLY. RFC 6355 carries the UUID as the firmware -# holds it, and SMBIOS stores the first three fields little-endian, so these octets are the -# canonical spelling of the uuid above with those fields reversed. A grep for "duid" would pass on -# the key alone. +# The DUID, read out of the JSON and compared EXACTLY. RFC 6355 carries the sixteen octets in the +# order the client sends them, which is the order vpd.uuid holds, so these octets are 00:04 and +# the uuid above unchanged. They are what the firmware on xcat76-cn sent on 2026-10-23. A grep for +# "duid" would pass on the key alone. cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));print("".join(r.get("duid","") for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("hostname")=="ci-ipv6-cn"))' check:rc==0 check:output==00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7 diff --git a/xCAT-test/bats/genesis_duid_uuid.bats b/xCAT-test/bats/genesis_duid_uuid.bats new file mode 100644 index 0000000000..a3b3a9bb84 --- /dev/null +++ b/xCAT-test/bats/genesis_duid_uuid.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# The byte order of a DUID-UUID, as the legacy Genesis image sends it. +# +# doxcat writes a default-duid for the ISC client from the SMBIOS UUID, and makedhcp writes the +# same octets into the DHCPv6 reservation. They have to agree, so this is the reference for both +# the Kea DUID (xCAT-test/unit/dhcp_kea_plugin_intent.t) and what discovery reports into vpd.uuid. +# dodiscovery carries the same expression, and needs xcatd and a network to reach it. + +load 'helpers/doxcat_sandbox' + +setup() +{ + setup_doxcat + add_doxcat_link boot0 BROADCAST,MULTICAST,UP ether aa:bb:cc:dd:ee:ff + mkdir -p "$fixture/sys/devices/virtual/dmi/id" + leases="$fixture/var/lib/dhclient/dhclient6.leases" +} + +# doxcat writes the DUID as escaped octal. Render it as the colon-separated hex that makedhcp +# puts in the reservation, so one DUID can be compared with the other. +sent_duid() +{ + local octets octet duid= + + octets=$(sed -e 's/^default-duid "//' -e 's/";$//' \ + -e 's/\\\\\([0-7][0-7][0-7]\)/\1 /g' "$leases") + for octet in $octets; do + duid="$duid:$(printf '%02x' "$((8#$octet))")" + done + printf '%s' "${duid#:}" +} + +@test "the DUID carries the first three SMBIOS fields in firmware order" { + printf '00112233-4455-6677-8899-aabbccddeeff\n' \ + >"$fixture/sys/devices/virtual/dmi/id/product_uuid" + run_genesis 0 --setenv BOOTIF 01-aa-bb-cc-dd-ee-ff + [ "$(sent_duid)" = 00:04:33:22:11:00:55:44:77:66:88:99:aa:bb:cc:dd:ee:ff ] +} + +@test "a machine with no SMBIOS UUID sends no DUID-UUID" { + run_genesis 0 --setenv BOOTIF 01-aa-bb-cc-dd-ee-ff + [ ! -e "$leases" ] +} diff --git a/xCAT-test/bats/genesis_openembedded_discovery.bats b/xCAT-test/bats/genesis_openembedded_discovery.bats index 39bd62d8d2..5db058f966 100644 --- a/xCAT-test/bats/genesis_openembedded_discovery.bats +++ b/xCAT-test/bats/genesis_openembedded_discovery.bats @@ -190,6 +190,18 @@ not_in_packet() grep -qx STATE=READY "$XCAT_STATUS_DIR/discovery.env" } +@test "discovery reports the system UUID in the order a DUID-UUID carries it" { + # vpd.uuid holds this value, and makedhcp writes 00:04 followed by these octets into the + # DHCPv6 reservation. SMBIOS 2.6 and later store the first three fields little-endian and + # sysfs renders them canonically, so reporting product_uuid unchanged gave the same machine a + # different vpd.uuid depending on which Genesis generation discovered it. dodiscovery in the + # legacy image swaps the same three fields. + discover + [ "$status" -eq 0 ] + in_packet '33221100-5544-7766-8899-aabbccddeeff' + not_in_packet '00112233-4455-6677-8899-aabbccddeeff' +} + @test "successful discovery does not depend on logging" { XCAT_TEST_LOGGER_FAIL=1 discover [ "$status" -eq 0 ] diff --git a/xCAT-test/unit/dhcp_kea_plugin_intent.t b/xCAT-test/unit/dhcp_kea_plugin_intent.t index ffb919e37d..5476256674 100644 --- a/xCAT-test/unit/dhcp_kea_plugin_intent.t +++ b/xCAT-test/unit/dhcp_kea_plugin_intent.t @@ -1324,7 +1324,7 @@ foreach my $case (@invalid_mac_cases) { 'query and delete retain alias matches when the associated MAC is malformed' ); ok( - grep( { ( $_->{duid} || '' ) eq '00:04:33:22:11:00:55:44:77:66:88:99:aa:bb:cc:dd:ee:ff' } @$matches ), + grep( { ( $_->{duid} || '' ) eq '00:04:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' } @$matches ), 'query and delete retain DUID matches when the associated MAC is malformed' ); } @@ -2472,10 +2472,8 @@ for my $case (['80', ''], ['080', ':080'], ['8080', ':8080']) { my %by_hostname = map { $_->{hostname} => $_ } @$reservations; my $grub2 = $by_hostname{nodev6}; - # The first three UUID fields are reversed, because that is what a UEFI client sends -- - # see kea_duid_from_uuid. This expectation held the canonical spelling and so agreed with a - # DUID no firmware ever presents. - is( $grub2->{duid}, '00:04:33:22:11:00:55:44:77:66:88:99:aa:bb:cc:dd:ee:ff', 'DHCPv6 reservation matches the DUID-UUID a UEFI client sends' ); + # vpd.uuid is the DUID payload, in the order the client sends it. See kea_duid_from_uuid. + is( $grub2->{duid}, '00:04:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff', 'DHCPv6 reservation matches the DUID-UUID a UEFI client sends' ); is( $grub2->{'option-data'}[0]{name}, 'bootfile-url', 'grub2 reservation carries RFC 5970 bootfile-url' ); is( $grub2->{'option-data'}[0]{data}, 'tftp://[2001:db8::1]/boot/grub2/grub2-nodev6', 'grub2 bootfile URL uses the IPv6-facing xCAT server and bracketed authority' ); ok( $grub2->{'option-data'}[0]{'always-send'}, 'grub2 bootfile URL is always sent' ); @@ -2618,29 +2616,28 @@ for my $case (['80', ''], ['080', ':080'], ['8080', ':8080']) { 'an IPv6-only node never reaches the IPv4 next-server resolver' ); } -# A DUID-UUID CARRIES THE UUID AS THE FIRMWARE HOLDS IT, NOT AS vpd.uuid SPELLS IT. +# A DUID-UUID CARRIES vpd.uuid VERBATIM. # -# RFC 6355 puts the sixteen octets of the system UUID in the DUID. SMBIOS 2.6 and later store -# time_low, time_mid and time_hi_and_version LITTLE-ENDIAN, while vpd.uuid holds the canonical -# spelling -- which is what Linux reports in product_uuid and what discovery writes. So the two -# disagree in the first eight octets, Kea never matches the reservation, and the node takes a pool -# address with no bootfile-url and stops at PXE-E21. +# RFC 6355 puts the sixteen octets of the system UUID in the DUID, in the order the client sends +# them. 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 . A swap here is a second +# one, Kea never matches the reservation, and the node takes a pool address with no bootfile-url. # -# Measured on xcat76-cn, 2026-10-23, with vpd.uuid c78c76bf-3286-46f3-b80d-8fe079dd6de7: -# xCAT wrote 00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7 -# the firmware sent 00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7 +# xcat76-cn, 2026-10-23: the libvirt domain UUID is c78c76bf-3286-46f3-b80d-8fe079dd6de7, which +# kvm.pm built from vpd.uuid bf768cc7-8632-f346-b80d-8fe079dd6de7. The firmware sent +# 00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7, which is that vpd.uuid unchanged. { - is( xCAT_plugin::dhcp::kea_duid_from_uuid('c78c76bf-3286-46f3-b80d-8fe079dd6de7'), + is( xCAT_plugin::dhcp::kea_duid_from_uuid('bf768cc7-8632-f346-b80d-8fe079dd6de7'), '00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7', - 'the DUID reverses the first three UUID fields, as the firmware sends them' ); + 'the DUID is 00:04 and vpd.uuid unchanged, the octets the firmware on xcat76-cn sent' ); - # The last eight octets are byte order independent and must NOT move. + # An asymmetric uuid: every field would move under a swap, and none may. my $duid = xCAT_plugin::dhcp::kea_duid_from_uuid('00112233-4455-6677-8899-aabbccddeeff'); - is( $duid, '00:04:33:22:11:00:55:44:77:66:88:99:aa:bb:cc:dd:ee:ff', - 'the clock-seq and node fields keep their order' ); + is( $duid, '00:04:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff', + 'time_low, time_mid and time_hi keep the order vpd.uuid spells them in' ); # A UUID with no separators is the same value. - is( xCAT_plugin::dhcp::kea_duid_from_uuid('c78c76bf328646f3b80d8fe079dd6de7'), + is( xCAT_plugin::dhcp::kea_duid_from_uuid('bf768cc78632f346b80d8fe079dd6de7'), '00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7', 'separators in vpd.uuid do not change the DUID' );