@@ -22,6 +22,7 @@ import (
22
22
"github.com/projectcalico/calico/felix/proto"
23
23
24
24
"github.com/projectcalico/vpp-dataplane/v3/vpplink"
25
+ "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/capo"
25
26
"github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
26
27
)
27
28
@@ -180,10 +181,14 @@ func (h *HostEndpoint) getTapPolicies(state *PolicyState) (conf *types.Interface
180
181
// If a host endpoint is created and network policy is not in place,
181
182
// the Calico default is to deny traffic to/from that endpoint
182
183
// (except for traffic allowed by failsafe rules).
184
+ // note: this applies to ingress and egress separately, so if you don't have
185
+ // ingress only you drop ingress
183
186
conf .IngressPolicyIDs = []uint32 {h .server .workloadsToHostPolicy .VppID , h .server .failSafePolicy .VppID , h .server .denyAllPolicy .VppID }
184
187
} else {
185
188
if len (conf .IngressPolicyIDs ) > 0 {
186
- conf .UserDefinedTx = 1
189
+ conf .PolicyDefaultTx = capo .CAPO_DEFAULT_DENY
190
+ } else if len (conf .ProfileIDs ) > 0 {
191
+ conf .PolicyDefaultTx = capo .CAPO_DEFAULT_PASS
187
192
}
188
193
conf .IngressPolicyIDs = append ([]uint32 {h .server .failSafePolicy .VppID }, conf .IngressPolicyIDs ... )
189
194
conf .IngressPolicyIDs = append ([]uint32 {h .server .workloadsToHostPolicy .VppID }, conf .IngressPolicyIDs ... )
@@ -192,7 +197,9 @@ func (h *HostEndpoint) getTapPolicies(state *PolicyState) (conf *types.Interface
192
197
conf .EgressPolicyIDs = []uint32 {h .server .AllowFromHostPolicy .VppID , h .server .failSafePolicy .VppID , h .server .denyAllPolicy .VppID }
193
198
} else {
194
199
if len (conf .EgressPolicyIDs ) > 0 {
195
- conf .UserDefinedRx = 1
200
+ conf .PolicyDefaultRx = capo .CAPO_DEFAULT_DENY
201
+ } else if len (conf .ProfileIDs ) > 0 {
202
+ conf .PolicyDefaultRx = capo .CAPO_DEFAULT_PASS
196
203
}
197
204
conf .EgressPolicyIDs = append ([]uint32 {h .server .failSafePolicy .VppID }, conf .EgressPolicyIDs ... )
198
205
conf .EgressPolicyIDs = append ([]uint32 {h .server .AllowFromHostPolicy .VppID }, conf .EgressPolicyIDs ... )
@@ -207,11 +214,15 @@ func (h *HostEndpoint) getForwardPolicies(state *PolicyState) (conf *types.Inter
207
214
}
208
215
if len (conf .EgressPolicyIDs ) > 0 {
209
216
conf .EgressPolicyIDs = append ([]uint32 {h .server .allowToHostPolicy .VppID }, conf .EgressPolicyIDs ... )
210
- conf .UserDefinedRx = 1
217
+ conf .PolicyDefaultRx = capo .CAPO_DEFAULT_DENY
218
+ } else if len (conf .ProfileIDs ) > 0 {
219
+ conf .PolicyDefaultRx = capo .CAPO_DEFAULT_PASS
211
220
}
212
221
if len (conf .IngressPolicyIDs ) > 0 {
213
222
conf .IngressPolicyIDs = append ([]uint32 {h .server .allowToHostPolicy .VppID }, conf .IngressPolicyIDs ... )
214
- conf .UserDefinedTx = 1
223
+ conf .PolicyDefaultTx = capo .CAPO_DEFAULT_DENY
224
+ } else if len (conf .ProfileIDs ) > 0 {
225
+ conf .PolicyDefaultTx = capo .CAPO_DEFAULT_PASS
215
226
}
216
227
return conf , nil
217
228
}
@@ -288,6 +299,7 @@ func (h *HostEndpoint) Delete(vpp *vpplink.VppLink, state *PolicyState) (err err
288
299
h .server .log .Infof ("policy(del) interface swif=%d" , swIfIndex )
289
300
conf := types .NewInterfaceConfig ()
290
301
conf .IngressPolicyIDs = h .server .defaultTap0IngressConf
302
+ conf .EgressPolicyIDs = h .server .defaultTap0EgressConf
291
303
err = vpp .ConfigurePolicies (swIfIndex , conf , 0 )
292
304
if err != nil {
293
305
return errors .Wrapf (err , "cannot unconfigure policies on interface %d" , swIfIndex )
0 commit comments