Skip to content

Commit

Permalink
fix: sometimes alloc ipv6 address failed sometimes ipam.GetStaticAdd…
Browse files Browse the repository at this point in the history
…ress return NoAvailableAddress (#2132)

when use ipam.GetStaticAddress with param ipv6 address without clean Zero
 such as "fd00::00e9:0ed1", and exactly subnet.V6FreeIPList has a range
 with start fd00::e9:ed1 and end with any v6 address,or start with an any v6
 address and end with fd00::e9:ed1, it will cause ipr.Start.Equal(ip)
 or ipr.End.Equal(ip) failed, and no v6 address allocated
  • Loading branch information
changluyi committed Dec 7, 2022
1 parent 27d22b7 commit f58c88f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/ipam/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ func (subnet *Subnet) GetStaticAddress(podName, nicName string, ip IP, mac strin
if v4 && !subnet.V4CIDR.Contains(net.ParseIP(string(ip))) {
return ip, mac, ErrOutOfRange
}

if v6 {
ip = IP(net.ParseIP(string(ip)).String())
}

if v6 && !subnet.V6CIDR.Contains(net.ParseIP(string(ip))) {
return ip, mac, ErrOutOfRange
}
Expand Down

0 comments on commit f58c88f

Please sign in to comment.