Skip to content

Commit

Permalink
Don't use primary prefix for Vnet prefix for /32
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdenney committed Dec 27, 2024
1 parent 1876663 commit 88959a1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions cns/kubecontroller/nodenetworkconfig/conversion_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ func createNCRequestFromStaticNCHelper(nc v1alpha.NetworkContainer, primaryIPPre
secondaryIPConfigs := map[string]cns.SecondaryIPConfig{}
ipFamilies := map[cns.IPFamily]struct{}{}

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

// Add IPs from CIDR block to the secondary IPConfigs
Expand Down

0 comments on commit 88959a1

Please sign in to comment.