mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-19 17:02:15 +00:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
+10
@@ -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.
|
||||
|
||||
@@ -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' </sys/devices/virtual/dmi/id/product_uuid)" = 00000000000000000000000000000000 ]; then
|
||||
logger -s -t $log_label -p local4.info "SMBIOS UUID is the nil UUID, sending no DUID-UUID"
|
||||
else
|
||||
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
|
||||
fi
|
||||
fi
|
||||
|
||||
rpcbind
|
||||
|
||||
@@ -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) = @_;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) : ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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} })
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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' } ],
|
||||
|
||||
Reference in New Issue
Block a user