Skip to content

Commit af9d638

Browse files
Merge pull request #17117 from danwinship/cidr-checks
Automatic merge from submit-queue. Fix crash with invalid serviceNetworkCIDR #17076 fixed the corresponding crash with clusterNetworkCIDR, but serviceNetworkCIDR had the same problem. Also, this slightly simplifies the previous fix.
2 parents 8fc2fe6 + 34e9053 commit af9d638

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pkg/network/common/common.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,18 @@ func ParseNetworkInfo(clusterNetwork []networkapi.ClusterNetworkEntry, serviceNe
5757
for _, entry := range clusterNetwork {
5858
cidr, err := netutils.ParseCIDRMask(entry.CIDR)
5959
if err != nil {
60-
_, cidr, err := net.ParseCIDR(entry.CIDR)
60+
_, cidr, err = net.ParseCIDR(entry.CIDR)
6161
if err != nil {
6262
return nil, fmt.Errorf("failed to parse ClusterNetwork CIDR %s: %v", entry.CIDR, err)
6363
}
6464
glog.Errorf("Configured clusterNetworks value %q is invalid; treating it as %q", entry.CIDR, cidr.String())
65-
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
66-
} else {
67-
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
6865
}
66+
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
6967
}
7068

7169
sn, err := netutils.ParseCIDRMask(serviceNetwork)
7270
if err != nil {
73-
_, sn, err := net.ParseCIDR(serviceNetwork)
71+
_, sn, err = net.ParseCIDR(serviceNetwork)
7472
if err != nil {
7573
return nil, fmt.Errorf("failed to parse ServiceNetwork CIDR %s: %v", serviceNetwork, err)
7674
}

0 commit comments

Comments
 (0)