fix: deploy gai.conf if both v4 and v6 present (#23160)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2025-08-25 18:19:19 +08:00
committed by GitHub
co-authored by Qiu Jian
parent be04e9f5b2
commit ab5f25c991
+20
View File
@@ -458,6 +458,26 @@ func (l *sLinuxRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*ty
log.Errorf("rootFs.GenerateSshHostKeys fail %s", err)
}
}
{
// deploy /etc/gai.conf if both IPv4 and IPv6 are enabled
v4Enabled := false
v6Enabled := false
for _, nic := range nics {
if nic.Ip != "" {
v4Enabled = true
}
if nic.Ip6 != "" {
v6Enabled = true
}
if v4Enabled && v6Enabled {
// prefer IPv4 over IPv6 by default of /etc/gai.conf not present
if !rootFs.Exists("/etc/gai.conf", false) {
rootFs.FilePutContents("/etc/gai.conf", "precedence ::ffff:0:0/96 100\n", false, false)
}
break
}
}
}
return nil
}