From 008325c1840fe35629942d29efe27c092e761fb4 Mon Sep 17 00:00:00 2001 From: chaoskao <48510427+chaoskao@users.noreply.github.com> Date: Fri, 29 Jan 2021 07:11:21 +0800 Subject: [PATCH] [PortsOrch] Add reference counting to ports for ACL bindings (#1614) What I did: Use reference count for protect interface, If interface bind to ACL the reference will increase and vice versa. Why I did it: If interface bind to ACL and remove LAG causes the ACL rule become global rule to match all interfaces. How I verified it: Run the pytest check ACL and Port test case passed. --- orchagent/portsorch.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 104aeb57f448..2c5ca7189423 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1247,6 +1247,13 @@ bool PortsOrch::unbindAclTable(sai_object_id_t port_oid, return false; } + + Port port; + if (getPort(port_oid, port)) + { + decreasePortRefCount(port.m_alias); + } + if (!unbindRemoveAclTableGroup(port_oid, acl_table_oid, acl_stage)) { return false; } @@ -1307,6 +1314,12 @@ bool PortsOrch::bindAclTable(sai_object_id_t port_oid, return false; } + Port port; + if (getPort(port_oid, port)) + { + increasePortRefCount(port.m_alias); + } + return true; }