Implement DNS resolution for secondary pool addresses

Once we implement dual-stack, by adding secondary pool
addresses, dns resolution returns both A and AAAA records
for a hostname e.g. controller. This will break the current
single-stack logic of determining boot_address_family of a
IP based on presence/absence of AAAA record.

This commit changes the logic to determine the
boot_address_family, solely depending upon the IP itself.

Test Plan:
[PASS] AIO-SX/DX IPv4 bootstrap without issues
[PASS] AIO-SX/DX IPv6 bootstrap without issues

Story: 2011027
Task: 49768

Change-Id: I30ea3a26a5b46a9aad082e89fba83aa476c50079
Signed-off-by: Tara Nath Subedi <Tara.Subedi@windriver.com>
This commit is contained in:
Tara Subedi 2024-03-22 11:37:48 -04:00
parent 91ae9c3db2
commit 9821652bc8

View File

@ -2719,31 +2719,16 @@ else # vlan
ilog "Configuring vlan: boot_iface=vlan${mgmt_vlan}"
# Check whether to use inet or inet6
ipv6_addr=$(dig +short AAAA controller.internal)
if [[ -z "${ipv6_addr}" ]]
# Check for IPv4 format (3 digits followed by a dot, repeated 3 times, and another 3 digits)
if [[ $mgmt_ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]];
then
# during an upgrade the controller.internal may not be defined
# but the scenario could be IPv6. So try to resolve the controller
ipv6_addr=$(dig +short AAAA controller)
# due to the alias in the /etc/dnsmasq.conf:
# cname=controller,controller.internal
# An IPv4 scenario may answer "controller.internal." even for an IPv6 DIG
# for this reason, remove the "controller.internal." from the result
fqdn_pattern="controller.internal."
ipv6_addr=${ipv6_addr/${fqdn_pattern}/}
fi
if [[ -n "${ipv6_addr}" ]]
then
boot_address_family=inet6
ipv6init=yes
dhcpv6c=yes
else
boot_address_family=inet
ipv6init=no
dhcpv6c=no
else
boot_address_family=inet6
ipv6init=yes
dhcpv6c=yes
fi
# Persist the boot device to the platform configuration. This will get