@@ -122,15 +122,16 @@ inline string trim(const std::string& str, const std::string& whitespace = " \t"
122122 return str.substr (strBegin, strRange);
123123}
124124
125- AclRule::AclRule (AclOrch *aclOrch, string rule, string table, acl_table_type_t type) :
125+ AclRule::AclRule (AclOrch *aclOrch, string rule, string table, acl_table_type_t type, bool createCounter ) :
126126 m_pAclOrch(aclOrch),
127127 m_id(rule),
128128 m_tableId(table),
129129 m_tableType(type),
130130 m_tableOid(SAI_NULL_OBJECT_ID),
131131 m_ruleOid(SAI_NULL_OBJECT_ID),
132132 m_counterOid(SAI_NULL_OBJECT_ID),
133- m_priority(0 )
133+ m_priority(0 ),
134+ m_createCounter(createCounter)
134135{
135136 m_tableOid = aclOrch->getTableById (m_tableId);
136137}
@@ -393,7 +394,7 @@ bool AclRule::create()
393394 sai_attribute_t attr;
394395 sai_status_t status;
395396
396- if (!createCounter ())
397+ if (m_createCounter && !createCounter ())
397398 {
398399 return false ;
399400 }
@@ -414,10 +415,13 @@ bool AclRule::create()
414415 rule_attrs.push_back (attr);
415416
416417 // add reference to the counter
417- attr.id = SAI_ACL_ENTRY_ATTR_ACTION_COUNTER;
418- attr.value .aclaction .parameter .oid = m_counterOid;
419- attr.value .aclaction .enable = true ;
420- rule_attrs.push_back (attr);
418+ if (m_createCounter)
419+ {
420+ attr.id = SAI_ACL_ENTRY_ATTR_ACTION_COUNTER;
421+ attr.value .aclaction .parameter .oid = m_counterOid;
422+ attr.value .aclaction .enable = true ;
423+ rule_attrs.push_back (attr);
424+ }
421425
422426 // store matches
423427 for (auto it : m_matches)
@@ -528,7 +532,10 @@ bool AclRule::remove()
528532 decreaseNextHopRefCount ();
529533
530534 res = removeRanges ();
531- res &= removeCounter ();
535+ if (m_createCounter)
536+ {
537+ res &= removeCounter ();
538+ }
532539
533540 return res;
534541}
@@ -537,6 +544,11 @@ AclRuleCounters AclRule::getCounters()
537544{
538545 SWSS_LOG_ENTER ();
539546
547+ if (!m_createCounter)
548+ {
549+ return AclRuleCounters ();
550+ }
551+
540552 sai_attribute_t counter_attr[2 ];
541553 counter_attr[0 ].id = SAI_ACL_COUNTER_ATTR_PACKETS;
542554 counter_attr[1 ].id = SAI_ACL_COUNTER_ATTR_BYTES;
@@ -693,8 +705,8 @@ bool AclRule::removeCounter()
693705 return true ;
694706}
695707
696- AclRuleL3::AclRuleL3 (AclOrch *aclOrch, string rule, string table, acl_table_type_t type) :
697- AclRule(aclOrch, rule, table, type)
708+ AclRuleL3::AclRuleL3 (AclOrch *aclOrch, string rule, string table, acl_table_type_t type, bool createCounter ) :
709+ AclRule(aclOrch, rule, table, type, createCounter )
698710{
699711}
700712
@@ -862,8 +874,8 @@ void AclRuleL3::update(SubjectType, void *)
862874}
863875
864876
865- AclRulePfcwd::AclRulePfcwd (AclOrch *aclOrch, string rule, string table, acl_table_type_t type) :
866- AclRuleL3(aclOrch, rule, table, type)
877+ AclRulePfcwd::AclRulePfcwd (AclOrch *aclOrch, string rule, string table, acl_table_type_t type, bool createCounter ) :
878+ AclRuleL3(aclOrch, rule, table, type, createCounter )
867879{
868880}
869881
0 commit comments