@@ -122,15 +122,16 @@ inline string trim(const std::string& str, const std::string& whitespace = " \t"
122
122
return str.substr (strBegin, strRange);
123
123
}
124
124
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 ) :
126
126
m_pAclOrch(aclOrch),
127
127
m_id(rule),
128
128
m_tableId(table),
129
129
m_tableType(type),
130
130
m_tableOid(SAI_NULL_OBJECT_ID),
131
131
m_ruleOid(SAI_NULL_OBJECT_ID),
132
132
m_counterOid(SAI_NULL_OBJECT_ID),
133
- m_priority(0 )
133
+ m_priority(0 ),
134
+ m_createCounter(createCounter)
134
135
{
135
136
m_tableOid = aclOrch->getTableById (m_tableId);
136
137
}
@@ -393,7 +394,7 @@ bool AclRule::create()
393
394
sai_attribute_t attr;
394
395
sai_status_t status;
395
396
396
- if (!createCounter ())
397
+ if (m_createCounter && !createCounter ())
397
398
{
398
399
return false ;
399
400
}
@@ -414,10 +415,13 @@ bool AclRule::create()
414
415
rule_attrs.push_back (attr);
415
416
416
417
// 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
+ }
421
425
422
426
// store matches
423
427
for (auto it : m_matches)
@@ -528,7 +532,10 @@ bool AclRule::remove()
528
532
decreaseNextHopRefCount ();
529
533
530
534
res = removeRanges ();
531
- res &= removeCounter ();
535
+ if (m_createCounter)
536
+ {
537
+ res &= removeCounter ();
538
+ }
532
539
533
540
return res;
534
541
}
@@ -537,6 +544,11 @@ AclRuleCounters AclRule::getCounters()
537
544
{
538
545
SWSS_LOG_ENTER ();
539
546
547
+ if (!m_createCounter)
548
+ {
549
+ return AclRuleCounters ();
550
+ }
551
+
540
552
sai_attribute_t counter_attr[2 ];
541
553
counter_attr[0 ].id = SAI_ACL_COUNTER_ATTR_PACKETS;
542
554
counter_attr[1 ].id = SAI_ACL_COUNTER_ATTR_BYTES;
@@ -693,8 +705,8 @@ bool AclRule::removeCounter()
693
705
return true ;
694
706
}
695
707
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 )
698
710
{
699
711
}
700
712
@@ -862,8 +874,8 @@ void AclRuleL3::update(SubjectType, void *)
862
874
}
863
875
864
876
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 )
867
879
{
868
880
}
869
881
0 commit comments