diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index f8bf775868..e9636ed6c8 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2023,6 +2023,23 @@ bool AclRuleMirror::validate() return true; } +bool AclRuleMirror::createCounter() +{ + SWSS_LOG_ENTER(); + + bool state = false; + + m_pMirrorOrch->getSessionStatus(m_sessionName, state); + + // If the mirror session is active, create the ACL counter + if(state) + { + return AclRule::createCounter(); + } + + return true; +} + bool AclRuleMirror::createRule() { SWSS_LOG_ENTER(); @@ -2152,7 +2169,11 @@ void AclRuleMirror::onUpdate(SubjectType type, void *cntx) if (update->active) { SWSS_LOG_INFO("Activating mirroring ACL %s for session %s", m_id.c_str(), m_sessionName.c_str()); - activate(); + // During mirror session activation, the newly created counter needs to be registered to the FC. + if(activate() && hasCounter()) + { + m_pAclOrch->registerFlexCounter(*this); + } } else { diff --git a/orchagent/aclorch.h b/orchagent/aclorch.h index 5458e970be..71ff7cd592 100644 --- a/orchagent/aclorch.h +++ b/orchagent/aclorch.h @@ -343,6 +343,7 @@ class AclRuleMirror: public AclRule AclRuleMirror(AclOrch *m_pAclOrch, MirrorOrch *m_pMirrorOrch, string rule, string table); bool validateAddAction(string attr_name, string attr_value); bool validate(); + bool createCounter(); bool createRule(); bool removeRule(); void onUpdate(SubjectType, void *) override;