diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index f3126c31ad0a..4feb597b705e 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -784,7 +784,7 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_ setPort(port.m_alias, port); - gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, ingress ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS, SAI_ACL_BIND_POINT_TYPE_PORT); + gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, ingress ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS, bind_type); switch (port.m_type) { @@ -1264,7 +1264,7 @@ bool PortsOrch::removePort(sai_object_id_t port_id) SWSS_LOG_ERROR("Failed to remove port %lx, rv:%d", port_id, status); return false; } - + removeAclTableGroup(p); SWSS_LOG_NOTICE("Remove port %lx", port_id); return true; @@ -2602,6 +2602,8 @@ bool PortsOrch::removeVlan(Port vlan) return false; } + removeAclTableGroup(vlan); + SWSS_LOG_NOTICE("Remove VLAN %s vid:%hu", vlan.m_alias.c_str(), vlan.m_vlan_info.vlan_id); @@ -2778,6 +2780,8 @@ bool PortsOrch::removeLag(Port lag) return false; } + removeAclTableGroup(lag); + SWSS_LOG_NOTICE("Remove LAG %s lid:%lx", lag.m_alias.c_str(), lag.m_lag_id); m_portList.erase(lag.m_alias); @@ -3178,3 +3182,46 @@ bool PortsOrch::getPortOperStatus(const Port& port, sai_port_oper_status_t& stat return true; } +bool PortsOrch::removeAclTableGroup(const Port &p) +{ + sai_acl_bind_point_type_t bind_type; + switch (p.m_type) + { + case Port::PHY: + bind_type = SAI_ACL_BIND_POINT_TYPE_PORT; + break; + case Port::LAG: + bind_type = SAI_ACL_BIND_POINT_TYPE_LAG; + break; + case Port::VLAN: + bind_type = SAI_ACL_BIND_POINT_TYPE_VLAN; + break; + default: + // Dealing with port, lag and vlan for now. + return true; + } + sai_status_t ret; + if (p.m_ingress_acl_table_group_id != 0) + { + ret = sai_acl_api->remove_acl_table_group(p.m_ingress_acl_table_group_id); + if (ret != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to remove ingress acl table group for %s", p.m_alias.c_str()); + return false; + } + gCrmOrch->decCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, SAI_ACL_STAGE_INGRESS, bind_type, p.m_ingress_acl_table_group_id); + } + + if (p.m_egress_acl_table_group_id != 0) + { + ret = sai_acl_api->remove_acl_table_group(p.m_egress_acl_table_group_id); + if (ret != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to remove egress acl table group for %s", p.m_alias.c_str()); + return false; + } + gCrmOrch->decCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, SAI_ACL_STAGE_EGRESS, bind_type, p.m_egress_acl_table_group_id); + } + return true; +} + diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 265c1d8d2bc1..87e88a892654 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -81,7 +81,7 @@ class PortsOrch : public Orch, public Subject void generatePriorityGroupMap(); void refreshPortStatus(); - + bool removeAclTableGroup(const Port &p); private: unique_ptr