Skip to content

Commit

Permalink
add judge before use the index about cidrBlocks and ips
Browse files Browse the repository at this point in the history
  • Loading branch information
pengbinbin1 committed Aug 11, 2021
1 parent 4485c39 commit f7077d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,11 @@ func GetIpAddrWithMask(ip, cidr string) string {
if CheckProtocol(cidr) == kubeovnv1.ProtocolDual {
cidrBlocks := strings.Split(cidr, ",")
ips := strings.Split(ip, ",")
v4IP := fmt.Sprintf("%s/%s", ips[0], strings.Split(cidrBlocks[0], "/")[1])
v6IP := fmt.Sprintf("%s/%s", ips[1], strings.Split(cidrBlocks[1], "/")[1])
ipAddr = v4IP + "," + v6IP
if len(cidrBlocks) == 2 && len(ips) == 2 {
v4IP := fmt.Sprintf("%s/%s", ips[0], strings.Split(cidrBlocks[0], "/")[1])
v6IP := fmt.Sprintf("%s/%s", ips[1], strings.Split(cidrBlocks[1], "/")[1])
ipAddr = v4IP + "," + v6IP
}
} else {
ipAddr = fmt.Sprintf("%s/%s", ip, strings.Split(cidr, "/")[1])
}
Expand Down

0 comments on commit f7077d5

Please sign in to comment.