From 80b5589604daa25b35ce3c419d839364820f6846 Mon Sep 17 00:00:00 2001 From: alkanso Date: Tue, 15 Apr 2025 18:02:27 -0700 Subject: [PATCH] create APIPA with DelegatedNICs --- cni/network/network.go | 4 ++++ cns/NetworkContainerContract.go | 3 +++ network/endpoint_windows.go | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/cni/network/network.go b/cni/network/network.go index b25d3de5de..d9132aeb5e 100644 --- a/cni/network/network.go +++ b/cni/network/network.go @@ -614,6 +614,10 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error { ifInfo := ipamAddResult.interfaceInfo[key] logger.Info("Processing interfaceInfo:", zap.Any("ifInfo", ifInfo)) + if ifInfo.NICType == cns.DelegatedVMNIC { + logger.Info("The NIC type is Delegated VM NIC, we will also create the APIPA endpoint") + } + natInfo := getNATInfo(nwCfg, options[network.SNATIPKey], enableSnatForDNS) networkID, _ := plugin.getNetworkID(args.Netns, &ifInfo, nwCfg) diff --git a/cns/NetworkContainerContract.go b/cns/NetworkContainerContract.go index 5f64178a46..cfbc563dfd 100644 --- a/cns/NetworkContainerContract.go +++ b/cns/NetworkContainerContract.go @@ -88,6 +88,9 @@ const ( // NodeNetworkInterfaceAccelnetFrontendNIC is a type of front-end nic that offers accelerated networking performance NodeNetworkInterfaceAccelnetFrontendNIC NICType = "FrontendNIC_Accelnet" + // APIPA is the type of nic that is used for APIPA + NodeNetworkInterfaceAPIPANIC NICType = "APIPANIC" + // TODO: These two const are currently unused due to version compatibility with DNC. DelegatedVMNIC and NodeNetworkInterfaceBackendNIC should be renamed to align with the naming convention with DNC // NodeNetworkInterfaceFrontendNIC is the new name for DelegatedVMNIC NodeNetworkInterfaceFrontendNIC NICType = "FrontendNIC" diff --git a/network/endpoint_windows.go b/network/endpoint_windows.go index edd52327f2..21b56627ca 100644 --- a/network/endpoint_windows.go +++ b/network/endpoint_windows.go @@ -462,6 +462,14 @@ func (nw *network) newEndpointImplHnsV2(cli apipaClient, epInfo *EndpointInfo) ( } }() + // when using delegated nics, automatically allow inbound from nc to host + if (epInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC || epInfo.NICType == cns.NodeNetworkInterfaceAPIPANIC) { + if !epInfo.AllowInboundFromNCToHost { + logger.Info("setting AllowInboundFromNCToHost to true since the NC has a delegated nic", zap.String("PODName", epInfo.PODName), zap.String("NetworkContainerID", epInfo.NetworkContainerID)) + epInfo.AllowInboundFromNCToHost = true + } + } + // If the Host - container connectivity is requested, create endpoint in HostNCApipaNetwork if epInfo.AllowInboundFromHostToNC || epInfo.AllowInboundFromNCToHost { if err = nw.createHostNCApipaEndpoint(cli, epInfo); err != nil {