From 49cc3cd7a270fb105dba4dba079c13f61ae50cfa Mon Sep 17 00:00:00 2001 From: ryandenney Date: Mon, 23 Dec 2024 17:19:13 -0500 Subject: [PATCH] Don't use primary prefix for Vnet prefix for /32 --- .../nodenetworkconfig/conversion_linux.go | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/cns/kubecontroller/nodenetworkconfig/conversion_linux.go b/cns/kubecontroller/nodenetworkconfig/conversion_linux.go index 4f074a9e02..a16664e9bf 100644 --- a/cns/kubecontroller/nodenetworkconfig/conversion_linux.go +++ b/cns/kubecontroller/nodenetworkconfig/conversion_linux.go @@ -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