Merge pull request #9076 from CFSworks/fix-ipv6-pref
Fix `ip_pref` configuration option
This commit is contained in:
commit
841c693710
@ -612,7 +612,7 @@ func selectPodIPs(ctx context.Context, configs []*cni.IPConfig, preference strin
|
||||
}
|
||||
case "ipv6":
|
||||
for i, ip := range configs {
|
||||
if ip.IP.To16() != nil {
|
||||
if ip.IP.To4() == nil {
|
||||
return ipString(ip), append(extra, toStrings(configs[i+1:])...)
|
||||
}
|
||||
extra = append(extra, ipString(ip))
|
||||
|
@ -145,7 +145,7 @@ func TestSelectPodIP(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "ipv6 should be picked even if ipv4 comes first",
|
||||
ips: []string{"2001:db8:85a3::8a2e:370:7334", "192.168.17.43"},
|
||||
ips: []string{"192.168.17.43", "2001:db8:85a3::8a2e:370:7334"},
|
||||
expectedIP: "2001:db8:85a3::8a2e:370:7334",
|
||||
expectedAdditionalIPs: []string{"192.168.17.43"},
|
||||
pref: "ipv6",
|
||||
|
@ -692,7 +692,7 @@ func selectPodIPs(ctx context.Context, configs []*cni.IPConfig, preference strin
|
||||
}
|
||||
case "ipv6":
|
||||
for i, ip := range configs {
|
||||
if ip.IP.To16() != nil {
|
||||
if ip.IP.To4() == nil {
|
||||
return ipString(ip), append(extra, toStrings(configs[i+1:])...)
|
||||
}
|
||||
extra = append(extra, ipString(ip))
|
||||
|
@ -293,7 +293,7 @@ func TestSelectPodIP(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "ipv6 should be picked even if ipv4 comes first",
|
||||
ips: []string{"2001:db8:85a3::8a2e:370:7334", "192.168.17.43"},
|
||||
ips: []string{"192.168.17.43", "2001:db8:85a3::8a2e:370:7334"},
|
||||
expectedIP: "2001:db8:85a3::8a2e:370:7334",
|
||||
expectedAdditionalIPs: []string{"192.168.17.43"},
|
||||
pref: "ipv6",
|
||||
|
Loading…
Reference in New Issue
Block a user