@@ -51,10 +51,24 @@ func (k *K8sSWIFTv2Middleware) IPConfigsRequestHandlerWrapper(defaultHandler, fa
5151 }, errors .New ("failed to validate IP configs request" )
5252 }
5353 ipConfigsResp , err := defaultHandler (ctx , req )
54+
5455 // If the pod is not v2, return the response from the handler
5556 if ! req .SecondaryInterfacesExist {
5657 return ipConfigsResp , err
5758 }
59+
60+ // ipConfigsResp has infra IP configs -> if defaultDenyACLbool is enabled, add the default deny acl's pn the infra IP configs
61+ for i := range ipConfigsResp .PodIPInfo {
62+ ipInfo := & ipConfigsResp .PodIPInfo [i ]
63+ // there will be no pod connectivity to and from those pods
64+ if defaultDenyACLbool {
65+ err := addDefaultDenyACL (ipInfo )
66+ if err != nil {
67+ errors .Wrapf (err , "failed to add default deny acl's for pod %s" , podInfo .Name ())
68+ }
69+ }
70+ }
71+
5872 // If the pod is v2, get the infra IP configs from the handler first and then add the SWIFTv2 IP config
5973 defer func () {
6074 // Release the default IP config if there is an error
@@ -82,12 +96,6 @@ func (k *K8sSWIFTv2Middleware) IPConfigsRequestHandlerWrapper(defaultHandler, fa
8296 // Set routes for the pod
8397 for i := range ipConfigsResp .PodIPInfo {
8498 ipInfo := & ipConfigsResp .PodIPInfo [i ]
85- if defaultDenyACLbool {
86- err := addDefaultDenyACL (ipInfo )
87- if err != nil {
88- errors .Wrapf (err , "failed to add default deny acl's for pod %s" , podInfo .Name ())
89- }
90- }
9199 // Backend nics doesn't need routes to be set
92100 if ipInfo .NICType != cns .BackendNIC {
93101 err = k .setRoutes (ipInfo )
@@ -141,7 +149,10 @@ func (k *K8sSWIFTv2Middleware) validateIPConfigsRequest(ctx context.Context, req
141149 if ! mtpnc .IsReady () {
142150 return nil , types .UnexpectedError , errMTPNCNotReady .Error (), defaultDenyACLbool
143151 }
152+
153+ // setting defaultDenyACLbool from mtpnc
144154 defaultDenyACLbool = mtpnc .Status .DefaultDenyACL
155+
145156 // If primary Ip is set in status field, it indicates the presence of secondary interfaces
146157 if mtpnc .Status .PrimaryIP != "" {
147158 req .SecondaryInterfacesExist = true
0 commit comments