@@ -102,6 +102,7 @@ const (
102
102
ACL_CLIENT_L3_REDIRECT_ACL = "L3_REDIRECT_ACL@"
103
103
ACL_CLIENT_L3V6_SECURITY_ACL = "L3V6_SECURITY_ACL@"
104
104
ACL_CLIENT_L3V6_REDIRECT_ACL = "L3V6_REDIRECT_ACL@"
105
+ ACL_INTERNAL_FIELD_SOURCE = "_SOURCE"
105
106
)
106
107
107
108
var IP_PROTOCOL_MAP = map [ocbinds.E_OpenconfigPacketMatchTypes_IP_PROTOCOL ]uint8 {
@@ -934,6 +935,7 @@ func (app *AclApp) convertDBAclToInternal(dbs [db.MaxDB]*db.DB, aclkey db.Key) e
934
935
}
935
936
if entry .IsPopulated () {
936
937
if entry .Field [ACL_FIELD_TYPE ] == SONIC_ACL_TYPE_L2 || entry .Field [ACL_FIELD_TYPE ] == SONIC_ACL_TYPE_IPV4 || entry .Field [ACL_FIELD_TYPE ] == SONIC_ACL_TYPE_IPV6 {
938
+ entry .Field [ACL_INTERNAL_FIELD_SOURCE ] = "User"
937
939
app .aclTableMap [aclkey .Get (0 )] = entry
938
940
app .ruleTableMap [aclkey .Get (0 )] = make (map [string ]db.Value )
939
941
err = app .convertDBAclRulesToInternal (dbs , aclkey .Get (0 ), "" , db.Key {})
@@ -1438,7 +1440,7 @@ func convertInternalAclBindingStatusTypeToOC(status string) ocbinds.E_Openconfig
1438
1440
return ocStatusType
1439
1441
}
1440
1442
1441
- func (app * AclApp ) getAclExtStateInfoForNameStage (statedb * db.DB , intfId string , stage string , aclName string , aclType ocbinds.E_OpenconfigAcl_ACL_TYPE , aclSetState reflect.Value ) error {
1443
+ func (app * AclApp ) getAclExtStateInfoForNameStage (statedb * db.DB , intfId string , stage string , aclName string , aclType ocbinds.E_OpenconfigAcl_ACL_TYPE , aclSetState reflect.Value , pacBinding * bool ) error {
1442
1444
log .Infof ("Intf:%s stage:%s name:%s Type:%v" , intfId , stage , aclName , aclType )
1443
1445
1444
1446
bindingTblData , bindingTblErr := statedb .GetEntry (app .aclBindStateTs , db.Key {Comp : []string {intfId , stage }})
@@ -1452,6 +1454,7 @@ func (app *AclApp) getAclExtStateInfoForNameStage(statedb *db.DB, intfId string,
1452
1454
prio , _ := strconv .ParseUint (parts [3 ], 10 , 16 )
1453
1455
prio_uint := uint16 (prio )
1454
1456
source := convertInternalAclSourceTypeToOC (parts [1 ])
1457
+ * pacBinding = (SONIC_ACL_SOURCE_PAC == parts [1 ])
1455
1458
aclSetState .Elem ().FieldByName ("Priority" ).Set (reflect .ValueOf (& prio_uint ))
1456
1459
aclSetState .Elem ().FieldByName ("Source" ).Set (reflect .ValueOf (source ))
1457
1460
if parts [2 ] != "" {
@@ -1477,7 +1480,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag
1477
1480
// Validate and return error always.
1478
1481
aclDbName := app .getAclKeyByCheckingDbForNameWithoutType (dbs [db .ConfigDB ], aclName , aclType )
1479
1482
1480
- aclDataFromStateDB := false
1481
1483
var aclData db.Value
1482
1484
if len (app .aclTableMap ) > 0 && len (app .aclStateTableMap ) > 0 {
1483
1485
var found bool
@@ -1488,7 +1490,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag
1488
1490
log .Infof ("ACL:%s Type:%v not found" , aclDbName , aclType )
1489
1491
return tlerr .NotFound ("ACL:%s:%v not found" , aclName , aclType )
1490
1492
}
1491
- aclDataFromStateDB = true
1492
1493
}
1493
1494
} else {
1494
1495
var err error
@@ -1498,7 +1499,6 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag
1498
1499
if err != nil {
1499
1500
return err
1500
1501
} else {
1501
- aclDataFromStateDB = true
1502
1502
app .aclStateTableMap [aclDbName ] = aclData
1503
1503
}
1504
1504
} else {
@@ -1516,20 +1516,13 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag
1516
1516
return tlerr .NotFound ("requested binding not found for %s and %s at %s" , aclName , intfId , stage )
1517
1517
}
1518
1518
1519
- if ! aclDataFromStateDB {
1520
- aclSetCfg := aclSet .Elem ().FieldByName ("Config" )
1521
- if ! aclSetCfg .IsNil () {
1522
- aclSetCfg .Elem ().FieldByName ("SetName" ).Set (aclSet .Elem ().FieldByName ("SetName" ))
1523
- aclSetCfg .Elem ().FieldByName ("Type" ).Set (aclSet .Elem ().FieldByName ("Type" ))
1524
- }
1525
- }
1526
-
1519
+ pacBinding := false
1527
1520
aclSetState := aclSet .Elem ().FieldByName ("State" )
1528
1521
if ! aclSetState .IsNil () {
1529
1522
aclSetState .Elem ().FieldByName ("SetName" ).Set (aclSet .Elem ().FieldByName ("SetName" ))
1530
1523
aclSetState .Elem ().FieldByName ("Type" ).Set (aclSet .Elem ().FieldByName ("Type" ))
1531
1524
if intfId != ACL_GLOBAL_PORT && intfId != ACL_CTRL_PLANE_PORT {
1532
- err := app .getAclExtStateInfoForNameStage (dbs [db .StateDB ], intfId , stage , aclName , aclType , aclSetState )
1525
+ err := app .getAclExtStateInfoForNameStage (dbs [db .StateDB ], intfId , stage , aclName , aclType , aclSetState , & pacBinding )
1533
1526
if isNotFoundError (err ) {
1534
1527
return tlerr .NotFound ("Binding not found for ACL %s on %s at %s" , aclName , intfId , stage )
1535
1528
} else if err != nil {
@@ -1541,6 +1534,14 @@ func (app *AclApp) getOCIntfAclSetData(dbs [db.MaxDB]*db.DB, intfId string, stag
1541
1534
}
1542
1535
}
1543
1536
1537
+ if ! pacBinding {
1538
+ aclSetCfg := aclSet .Elem ().FieldByName ("Config" )
1539
+ if ! aclSetCfg .IsNil () {
1540
+ aclSetCfg .Elem ().FieldByName ("SetName" ).Set (aclSet .Elem ().FieldByName ("SetName" ))
1541
+ aclSetCfg .Elem ().FieldByName ("Type" ).Set (aclSet .Elem ().FieldByName ("Type" ))
1542
+ }
1543
+ }
1544
+
1544
1545
// At this stage we have verified that the ACL binding exists. Starts filling the actual data
1545
1546
// Check if the data was requested for a specific Entry else find all the rules
1546
1547
aclEntries := aclSet .Elem ().FieldByName ("AclEntries" )
@@ -3370,6 +3371,7 @@ func (app *AclApp) convertStateDBAclToInternal(dbs [db.MaxDB]*db.DB, aclkey db.K
3370
3371
3371
3372
if entry .IsPopulated () {
3372
3373
if entry .Field [ACL_CLIENT_FIELD_TYPE ] == SONIC_ACL_TYPE_L2 || entry .Field [ACL_CLIENT_FIELD_TYPE ] == SONIC_ACL_TYPE_IPV4 || entry .Field [ACL_CLIENT_FIELD_TYPE ] == SONIC_ACL_TYPE_IPV6 {
3374
+ entry .Field [ACL_INTERNAL_FIELD_SOURCE ] = "PAC"
3373
3375
app .aclStateTableMap [aclkey .Get (0 )] = entry
3374
3376
app .ruleStateTableMap [aclkey .Get (0 )] = make (map [string ]db.Value )
3375
3377
err = app .convertStateDBAclRulesToInternal (dbs , aclkey .Get (0 ), "" , db.Key {})
@@ -3398,6 +3400,7 @@ func (app *AclApp) convertStateDBInternalToOCAcl(aclName string, aclSets *ocbind
3398
3400
if len (aclName ) > 0 {
3399
3401
aclData := app .aclStateTableMap [aclName ]
3400
3402
if aclSet != nil {
3403
+ aclSet .Config = nil
3401
3404
aclSet .State .Name = aclSet .Name
3402
3405
aclSet .State .Type = aclSet .Type
3403
3406
@@ -3407,6 +3410,13 @@ func (app *AclApp) convertStateDBInternalToOCAcl(aclName string, aclSets *ocbind
3407
3410
aclSet .State .Description = & descr
3408
3411
} else if k == "ports@" {
3409
3412
continue
3413
+ } else if k == ACL_INTERNAL_FIELD_SOURCE {
3414
+ src := aclData .Get (k )
3415
+ if src == "PAC" {
3416
+ aclSet .State .Source = ocbinds .OpenconfigAclExt_ACL_SOURCE_TYPE_ACL_PAC_CREATED
3417
+ } else {
3418
+ aclSet .State .Source = ocbinds .OpenconfigAclExt_ACL_SOURCE_TYPE_ACL_USER_CREATED
3419
+ }
3410
3420
}
3411
3421
}
3412
3422
app .convertStateDBInternalToOCAclRule (aclName , aclSet .Type , "" , aclSet , nil )
0 commit comments