Skip to content

Commit bb0bdce

Browse files
committed
advertised network isolation: imporove DB ids
Use the constant value for global DB entries. Use the actual controller for per-network ACLs. Signed-off-by: Patryk Diak <[email protected]>
1 parent 1b15f8e commit bb0bdce

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

go-controller/pkg/ovn/gateway_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func generateAdvertisedUDNIsolationExpectedNB(testData []libovsdbtest.TestData,
4444

4545
}
4646
passACL := libovsdbutil.BuildACL(
47-
GetAdvertisedNetworkSubnetsPassACLdbIDs(networkName, networkID),
47+
GetAdvertisedNetworkSubnetsPassACLdbIDs(DefaultNetworkControllerName, networkName, networkID),
4848
types.AdvertisedNetworkPassPriority,
4949
strings.Join(passMatches, " || "),
5050
nbdb.ACLActionPass,

go-controller/pkg/ovn/udn_isolation.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,29 +240,28 @@ func (oc *DefaultNetworkController) getUDNOpenPortDbIDs(podNamespacedName string
240240
})
241241
}
242242

243-
const advertisedNetworkIsolationACLID = "advertised-network-isolation"
244-
const advertisedNetworkSubnetsAddressSet = "advertised-network-subnets"
245-
const advertisedNetworkSubnetsCtrl = "advertised-network-subnets-controller"
243+
// advertisedNetworkSubnetsKey is the object name key for the global advertised networks addressset and the global deny ACL
244+
const advertisedNetworkSubnetsKey = "advertised-network-subnets"
246245

247246
// GetAdvertisedNetworkSubnetsAddressSetDBIDs returns the DB IDs for the advertised network subnets addressset
248247
func GetAdvertisedNetworkSubnetsAddressSetDBIDs() *libovsdbops.DbObjectIDs {
249-
return libovsdbops.NewDbObjectIDs(libovsdbops.AddressSetAdvertisedNetwork, advertisedNetworkSubnetsCtrl, map[libovsdbops.ExternalIDKey]string{
250-
libovsdbops.ObjectNameKey: advertisedNetworkSubnetsAddressSet,
248+
return libovsdbops.NewDbObjectIDs(libovsdbops.AddressSetAdvertisedNetwork, DefaultNetworkControllerName, map[libovsdbops.ExternalIDKey]string{
249+
libovsdbops.ObjectNameKey: advertisedNetworkSubnetsKey,
251250
})
252251
}
253252

254253
// GetAdvertisedNetworkSubnetsDropACLdbIDs returns the DB IDs for the advertised network subnets drop ACL
255254
func GetAdvertisedNetworkSubnetsDropACLdbIDs() *libovsdbops.DbObjectIDs {
256-
return libovsdbops.NewDbObjectIDs(libovsdbops.ACLAdvertisedNetwork, advertisedNetworkIsolationACLID,
255+
return libovsdbops.NewDbObjectIDs(libovsdbops.ACLAdvertisedNetwork, DefaultNetworkControllerName,
257256
map[libovsdbops.ExternalIDKey]string{
258-
libovsdbops.ObjectNameKey: advertisedNetworkSubnetsCtrl,
257+
libovsdbops.ObjectNameKey: advertisedNetworkSubnetsKey,
259258
libovsdbops.NetworkKey: "",
260259
})
261260
}
262261

263262
// GetAdvertisedNetworkSubnetsPassACLdbIDs returns the DB IDs for the advertised network subnets pass ACL
264-
func GetAdvertisedNetworkSubnetsPassACLdbIDs(networkName string, networkID int) *libovsdbops.DbObjectIDs {
265-
return libovsdbops.NewDbObjectIDs(libovsdbops.ACLAdvertisedNetwork, advertisedNetworkIsolationACLID,
263+
func GetAdvertisedNetworkSubnetsPassACLdbIDs(controller, networkName string, networkID int) *libovsdbops.DbObjectIDs {
264+
return libovsdbops.NewDbObjectIDs(libovsdbops.ACLAdvertisedNetwork, controller,
266265
map[libovsdbops.ExternalIDKey]string{
267266
libovsdbops.ObjectNameKey: networkName,
268267
libovsdbops.NetworkKey: strconv.Itoa(networkID),
@@ -327,7 +326,7 @@ func (bnc *BaseNetworkController) addAdvertisedNetworkIsolation(nodeName string)
327326

328327
if len(passMatches) > 0 {
329328
passACL := libovsdbutil.BuildACL(
330-
GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.GetNetworkName(), bnc.GetNetworkID()),
329+
GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.controllerName, bnc.GetNetworkName(), bnc.GetNetworkID()),
331330
types.AdvertisedNetworkPassPriority,
332331
strings.Join(passMatches, " || "),
333332
nbdb.ACLActionPass,
@@ -337,7 +336,7 @@ func (bnc *BaseNetworkController) addAdvertisedNetworkIsolation(nodeName string)
337336

338337
ops, err = libovsdbops.CreateOrUpdateACLsOps(bnc.nbClient, ops, nil, passACL)
339338
if err != nil {
340-
return fmt.Errorf("failed to create or update network isolation pass ACL %s for network %s: %w", GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.GetNetworkName(), bnc.GetNetworkID()), bnc.GetNetworkName(), err)
339+
return fmt.Errorf("failed to create or update network isolation pass ACL %s for network %s: %w", GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.controllerName, bnc.GetNetworkName(), bnc.GetNetworkID()), bnc.GetNetworkName(), err)
341340
}
342341
ops, err = libovsdbops.AddACLsToLogicalSwitchOps(bnc.nbClient, ops, bnc.GetNetworkScopedSwitchName(nodeName), passACL)
343342
if err != nil {
@@ -377,7 +376,7 @@ func (bnc *BaseNetworkController) deleteAdvertisedNetworkIsolation(nodeName stri
377376
return err
378377
}
379378

380-
passACLIDs := GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.GetNetworkName(), bnc.GetNetworkID())
379+
passACLIDs := GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.controllerName, bnc.GetNetworkName(), bnc.GetNetworkID())
381380
passACLPredicate := libovsdbops.GetPredicate[*nbdb.ACL](passACLIDs, nil)
382381
passACLs, err := libovsdbops.FindACLsWithPredicate(bnc.nbClient, passACLPredicate)
383382
if err != nil {

0 commit comments

Comments
 (0)