Skip to content

Commit 49cc3cd

Browse files
committed
Don't use primary prefix for Vnet prefix for /32
1 parent 705c09e commit 49cc3cd

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

cns/kubecontroller/nodenetworkconfig/conversion_linux.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@ func createNCRequestFromStaticNCHelper(nc v1alpha.NetworkContainer, primaryIPPre
1818
secondaryIPConfigs := map[string]cns.SecondaryIPConfig{}
1919
ipFamilies := map[cns.IPFamily]struct{}{}
2020

21-
// iterate through all IP addresses in the subnet described by primaryPrefix and
22-
// add them to the request as secondary IPConfigs.
23-
for addr := primaryIPPrefix.Masked().Addr(); primaryIPPrefix.Contains(addr); addr = addr.Next() {
24-
secondaryIPConfigs[addr.String()] = cns.SecondaryIPConfig{
25-
IPAddress: addr.String(),
26-
NCVersion: int(nc.Version),
21+
// in the case of vnet prefix on swift v2 the primary IP is a /32 and should not be added to secondary IP configs
22+
if !primaryIPPrefix.IsSingleIP() {
23+
// iterate through all IP addresses in the subnet described by primaryPrefix and
24+
// add them to the request as secondary IPConfigs.
25+
for addr := primaryIPPrefix.Masked().Addr(); primaryIPPrefix.Contains(addr); addr = addr.Next() {
26+
secondaryIPConfigs[addr.String()] = cns.SecondaryIPConfig{
27+
IPAddress: addr.String(),
28+
NCVersion: int(nc.Version),
29+
}
30+
}
31+
// adds the IPFamily of the primary CIDR to the set
32+
if primaryIPPrefix.Addr().Is4() {
33+
ipFamilies[cns.IPv4Family] = struct{}{}
34+
} else {
35+
ipFamilies[cns.IPv6Family] = struct{}{}
2736
}
28-
}
29-
// adds the IPFamily of the primary CIDR to the set
30-
if primaryIPPrefix.Addr().Is4() {
31-
ipFamilies[cns.IPv4Family] = struct{}{}
32-
} else {
33-
ipFamilies[cns.IPv6Family] = struct{}{}
3437
}
3538

3639
// Add IPs from CIDR block to the secondary IPConfigs

0 commit comments

Comments
 (0)