Fix ipv4/ipv6 scenario detection

Using the format of mgmt_ip to set the IP address
family.Fix ipv4/ipv6 scenario detection

Using the format of mgmt_ip to set the IP address family.
Due to the use of the FQDN, the DNS answered the value:
"controller.internal" for the command:
"dig +short AAAA controller" even for an IPv4 install
It happened due to the alias entry in the /etc/dnsmasq.conf

```
cname=controller,controller.internal
cname=controller-0,controller-0.internal
cname=controller-1,controller-1.internal
```

Tests dome:
IPv4 AIO-SX fresh install
IPv6 AIO-SX fresh install
IPv4 AIO-DX fresh install
IPv6 AIO-DX fresh install
IPv4 AIO-DX swact
IPv6 AIO-DX swact

Closes-Bug: #2059722

Change-Id: I92978263646fe6d07e96edd2054d42bed6d389b1
Signed-off-by: Fabiano Correa Mercer <fabiano.correamercer@windriver.com>
This commit is contained in:
Fabiano Correa Mercer 2024-03-28 15:33:58 -03:00
parent cc679681e2
commit c6bdc8b728
1 changed files with 6 additions and 14 deletions

View File

@ -2719,24 +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 4 times)
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)
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