Skip to content

Commit 162714b

Browse files
committed
moved default deny acl under interfaceinfo
1 parent 4a4c990 commit 162714b

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

cni/network/invoker.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ type IPAMAddConfig struct {
2828
type IPAMAddResult struct {
2929
interfaceInfo map[string]network.InterfaceInfo
3030
// ncResponse and host subnet prefix were moved into interface info
31-
ipv6Enabled bool
32-
defaultDenyACL []cni.KVPair
31+
ipv6Enabled bool
3332
}
3433

3534
func (ipamAddResult IPAMAddResult) PrettyString() string {

cni/network/invoker_cns.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,6 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
447447
})
448448
}
449449

450-
addResult.defaultDenyACL = append(addResult.defaultDenyACL, info.defaultDenyACL...)
451-
452450
// if we have multiple infra ip result infos, we effectively append routes and ip configs to that same interface info each time
453451
// the host subnet prefix (in ipv4 or ipv6) will always refer to the same interface regardless of which ip result info we look at
454452
addResult.interfaceInfo[key] = network.InterfaceInfo{
@@ -457,6 +455,7 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
457455
IPConfigs: ipConfigs,
458456
Routes: resRoute,
459457
HostSubnetPrefix: *hostIPNet,
458+
DefaultDenyACL: info.defaultDenyACL,
460459
}
461460
}
462461

cni/network/invoker_cns_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,8 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
821821
ipamAddResult, err := invoker.Add(IPAMAddConfig{nwCfg: tt.args.nwCfg, args: tt.args.args, options: tt.args.options})
822822
if tt.wantErr {
823823
require.Error(err)
824-
require.Equalf([]cni.KVPair(nil), ipamAddResult.defaultDenyACL, "incorrect default deny ACL")
825824
} else {
826825
require.NoError(err)
827-
require.Equalf(expectedDefaultDenyACL, ipamAddResult.defaultDenyACL, "correct default deny ACL")
828826
}
829827

830828
for _, ifInfo := range ipamAddResult.interfaceInfo {
@@ -837,6 +835,7 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
837835
}
838836
if ifInfo.NICType == cns.InfraNIC {
839837
require.Equalf(tt.wantDefaultResult, ifInfo, "incorrect default response")
838+
require.Equalf(expectedDefaultDenyACL, ifInfo.DefaultDenyACL, "Correct default deny ACL")
840839
}
841840
}
842841
})

cni/network/network.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
564564
if len(ipamAddResult.interfaceInfo) > 1 && !plugin.isDualNicFeatureSupported(args.Netns) {
565565
errMsg := fmt.Sprintf("received multiple NC results %+v from CNS while dualnic feature is not supported", ipamAddResult.interfaceInfo)
566566
logger.Error("received multiple NC results from CNS while dualnic feature is not supported",
567-
zap.Any("results", ipamAddResult.interfaceInfo))
567+
zap.Any("Processing interfaceInfo", ipamAddResult.interfaceInfo))
568568
return plugin.Errorf(errMsg)
569569
}
570570
} else {
@@ -589,8 +589,12 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
589589
// sendEvent(plugin, fmt.Sprintf("Allocated IPAddress from ipam DefaultInterface: %+v, SecondaryInterfaces: %+v", ipamAddResult.interfaceInfo[ifIndex], ipamAddResult.interfaceInfo))
590590
}
591591

592-
logger.Info("The length of ipamAddResult defaultDenyACL's is", zap.Any("defaultDenyACLLength", ipamAddResult.defaultDenyACL))
593-
nwCfg.AdditionalArgs = append(nwCfg.AdditionalArgs, ipamAddResult.defaultDenyACL...)
592+
for key := range ipamAddResult.interfaceInfo {
593+
if key == string(cns.InfraNIC) {
594+
nwCfg.AdditionalArgs = append(nwCfg.AdditionalArgs, ipamAddResult.interfaceInfo[key].DefaultDenyACL...)
595+
logger.Info("nwCfg.AdditionalArgs2:", zap.Any("ifInfo", nwCfg.AdditionalArgs))
596+
}
597+
}
594598
policies := cni.GetPoliciesFromNwCfg(nwCfg.AdditionalArgs)
595599
// moved to addIpamInvoker
596600
// sendEvent(plugin, fmt.Sprintf("Allocated IPAddress from ipam interface: %+v", ipamAddResult.PrettyString()))

network/endpoint.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net"
1010
"strings"
1111

12+
"github.com/Azure/azure-container-networking/cni"
1213
"github.com/Azure/azure-container-networking/cni/log"
1314
"github.com/Azure/azure-container-networking/cns"
1415
"github.com/Azure/azure-container-networking/netio"
@@ -138,6 +139,7 @@ type InterfaceInfo struct {
138139
HostSubnetPrefix net.IPNet // Move this field from ipamAddResult
139140
NCResponse *cns.GetNetworkContainerResponse
140141
PnPID string
142+
DefaultDenyACL []cni.KVPair
141143
}
142144

143145
type IPConfig struct {

0 commit comments

Comments
 (0)