Add AddressPool validation check for invalid ranges where first address of the range is after the second
An AddressPool where the first address of the range is after the second
should be an invalid range. In such case the LoadBalancer service is
unable to get an IP.
package config // import "go.universe.tf/metallb/internal/config"
import (
+ "bytes"
"errors"
"fmt"
"net"
@@ -458,6 +459,10 @@ func parseCIDR(cidr string) ([]*net.IPNet, error) {
return nil, fmt.Errorf("invalid IP range %q: invalid end IP %q", cidr, fs[1])
}
+ if bytes.Compare(start, end) >= 0 {
+ return nil, fmt.Errorf("invalid IP range %q: start IP %q is after the end IP %q", cidr, start, end)
+ }
+
var ret []*net.IPNet
for _, pfx := range ipaddr.Summarize(start, end) {
n := &net.IPNet{
