From a8cf7a243addc6b3fcb984ae544efbcb8a3d0cd1 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Wed, 11 May 2022 14:49:16 -0500 Subject: [PATCH] include 0th address when parsing overlay cidrs (#1365) Signed-off-by: Evan Baker --- cns/singletenantcontroller/conversion.go | 3 +-- cns/singletenantcontroller/conversion_test.go | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cns/singletenantcontroller/conversion.go b/cns/singletenantcontroller/conversion.go index afab6c034..413a2d667 100644 --- a/cns/singletenantcontroller/conversion.go +++ b/cns/singletenantcontroller/conversion.go @@ -88,8 +88,7 @@ func CreateNCRequestFromStaticNC(nc v1alpha.NetworkContainer) (*cns.CreateNetwor // iterate through all IP addresses in the subnet described by primaryPrefix and // add them to the request as secondary IPConfigs. - zeroAddr := primaryPrefix.Masked().Addr() // the masked address is the 0th IP in the subnet - for addr := zeroAddr.Next(); primaryPrefix.Contains(addr); addr = addr.Next() { + for addr := primaryPrefix.Masked().Addr(); primaryPrefix.Contains(addr); addr = addr.Next() { secondaryIPConfigs[addr.String()] = cns.SecondaryIPConfig{ IPAddress: addr.String(), NCVersion: int(nc.Version), diff --git a/cns/singletenantcontroller/conversion_test.go b/cns/singletenantcontroller/conversion_test.go index 3df4e0fc9..e6ce30f72 100644 --- a/cns/singletenantcontroller/conversion_test.go +++ b/cns/singletenantcontroller/conversion_test.go @@ -94,6 +94,10 @@ var validOverlayRequest = &cns.CreateNetworkContainerRequest{ NetworkContainerid: ncID, NetworkContainerType: cns.Docker, SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{ + "10.0.0.0": { + IPAddress: "10.0.0.0", + NCVersion: version, + }, "10.0.0.1": { IPAddress: "10.0.0.1", NCVersion: version,