Skip to content

Commit

Permalink
ipam: return error for invalid ip range (#3088)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian authored Jul 31, 2023
1 parent a7e7a83 commit 18580ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/ipam/ip_range_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func NewIPRangeListFrom(x ...string) (*IPRangeList, error) {
if err != nil {
return nil, err
}
if start.GreaterThan(end) {
return nil, fmt.Errorf("invalid ip range %q: %s is greater than %s", s, start, end)
}
r = NewIPRange(start, end)
} else if strings.ContainsRune(s, '/') {
_, cidr, err := net.ParseCIDR(s)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func randomPool(cidr string, count int) []string {
x, y := k%len(ips), (k+1)%len(ips)
n1, _ := rl.Find(ips[x])
n2, _ := rl.Find(ips[y])
if n1 == n2 {
if n1 == n2 && ips[x].LessThan(ips[y]) {
set.Add(fmt.Sprintf("%s..%s", ips[x].String(), ips[y].String()))
i, k = i+1, k+2
continue
Expand Down

0 comments on commit 18580ed

Please sign in to comment.