From 69cf0872ce65dbb765d84920fd2361c4d8d19db0 Mon Sep 17 00:00:00 2001 From: fountzou <169114916+fountzou@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:37:03 +0300 Subject: [PATCH] [orchagent]: Skip installing ACL counter when ACL mirror rule is inactive (#3223) * [orchagent]: Resolving issue #18844 * Don't install counters when session rule is inactive. Mirror session is not activated and thus, the ACL rule is not created in sairedis/SAI (there is no next hop for the mirror destination IP). However, orchagent creates and registers the ACL counter with the flexcounter (FC) and the counter is being polled every polling interval. Since the ACL counter is not attached to any ACL rule, the BCM SAI introduces print errors in syslog. --- orchagent/aclorch.cpp | 23 ++++++++++++++++++++++- orchagent/aclorch.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index b20b382009..8e43a66db3 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2024,6 +2024,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(); @@ -2153,7 +2170,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 be6c1f2af5..6c0246ce4a 100644 --- a/orchagent/aclorch.h +++ b/orchagent/aclorch.h @@ -344,6 +344,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;