Skip to content

Commit 4137a50

Browse files
Merge pull request #17076 from JacobTanenbaum/segfault-CIDR
Automatic merge from submit-queue. fix a segfault with cidr addresses and correct the creation of cluster network object Currently the system segfaults if passed a cidr that is not in canonical form, this was due to scoping issues in ParseNetworkInfo(). Also fix the creation of the clusterNetworkObject to use the converted form of the cidr address when creating the clusterNetwork object to conform to how the system used to function @knobunc PTAL found while working on Bug: [1506017](https://bugzilla.redhat.com/show_bug.cgi?id=1506017)
2 parents a3a72e1 + 01f9efd commit 4137a50

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

pkg/network/common/common.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ func ParseNetworkInfo(clusterNetwork []networkapi.ClusterNetworkEntry, serviceNe
6464
return nil, fmt.Errorf("failed to parse ClusterNetwork CIDR %s: %v", entry.CIDR, err)
6565
}
6666
glog.Errorf("Configured clusterNetworks value %q is invalid; treating it as %q", entry.CIDR, cidr.String())
67+
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
68+
} else {
69+
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
6770
}
68-
cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength})
6971
}
7072

7173
sn, err := netutils.ParseCIDRMask(serviceNetwork)

pkg/network/master/master.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,22 @@ func Start(networkConfig osconfigapi.MasterNetworkConfig, networkClient networkc
6666
panic("No ClusterNetworks set in networkConfig; should have been defaulted in if not configured")
6767
}
6868

69+
var parsedClusterNetworkEntries []networkapi.ClusterNetworkEntry
70+
for _, entry := range master.networkInfo.ClusterNetworks {
71+
parsedClusterNetworkEntries = append(parsedClusterNetworkEntries, networkapi.ClusterNetworkEntry{CIDR: entry.ClusterCIDR.String(), HostSubnetLength: entry.HostSubnetLength})
72+
}
73+
6974
configCN := &networkapi.ClusterNetwork{
7075
TypeMeta: metav1.TypeMeta{Kind: "ClusterNetwork"},
7176
ObjectMeta: metav1.ObjectMeta{Name: networkapi.ClusterNetworkDefault},
7277

73-
ClusterNetworks: clusterNetworkEntries,
74-
ServiceNetwork: networkConfig.ServiceNetworkCIDR,
78+
ClusterNetworks: parsedClusterNetworkEntries,
79+
ServiceNetwork: master.networkInfo.ServiceNetwork.String(),
7580
PluginName: networkConfig.NetworkPluginName,
7681

7782
// Need to set these for backward compat
78-
Network: clusterNetworkEntries[0].CIDR,
79-
HostSubnetLength: clusterNetworkEntries[0].HostSubnetLength,
83+
Network: parsedClusterNetworkEntries[0].CIDR,
84+
HostSubnetLength: parsedClusterNetworkEntries[0].HostSubnetLength,
8085
}
8186
osapivalidation.SetDefaultClusterNetwork(*configCN)
8287

0 commit comments

Comments
 (0)