Fix ipv4/ipv6 scenario detection

Due to the alias in the /etc/dnsmasq.conf:
```
cname=controller,controller.internal
cname=controller-0,controller-0.internal
cname=controller-1,controller-1.internal
```

The DNS answers the value:
"controller.internal." for the IPv6 dig command:
"dig +short AAAA controller" even for an IPv4 scenario
What makes the code to set the IPv6 parameters instead
if the IPv4.
So it is necessary to check if the dig result has an
IPv6 address and not just the "controller.internal."

Tests dome:
IPv4 AIO-SX fresh install
IPv4 AIO-DX fresh install
IPv4 AIO-DX with mgmt in vlan fresh install
IPv6 AIO-DX with mgmt in vlan 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 91ae9c3db2
1 changed files with 7 additions and 0 deletions

View File

@ -2726,6 +2726,13 @@ else # vlan
# 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}" ]]