@@ -784,7 +784,7 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
784784
785785 setPort (port.m_alias , port);
786786
787- gCrmOrch ->incCrmAclUsedCounter (CrmResourceType::CRM_ACL_GROUP, ingress ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS, SAI_ACL_BIND_POINT_TYPE_PORT );
787+ gCrmOrch ->incCrmAclUsedCounter (CrmResourceType::CRM_ACL_GROUP, ingress ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS, bind_type );
788788
789789 switch (port.m_type )
790790 {
@@ -1264,7 +1264,7 @@ bool PortsOrch::removePort(sai_object_id_t port_id)
12641264 SWSS_LOG_ERROR (" Failed to remove port %lx, rv:%d" , port_id, status);
12651265 return false ;
12661266 }
1267-
1267+ removeAclTableGroup (p);
12681268 SWSS_LOG_NOTICE (" Remove port %lx" , port_id);
12691269
12701270 return true ;
@@ -2602,6 +2602,8 @@ bool PortsOrch::removeVlan(Port vlan)
26022602 return false ;
26032603 }
26042604
2605+ removeAclTableGroup (vlan);
2606+
26052607 SWSS_LOG_NOTICE (" Remove VLAN %s vid:%hu" , vlan.m_alias .c_str (),
26062608 vlan.m_vlan_info .vlan_id );
26072609
@@ -2778,6 +2780,8 @@ bool PortsOrch::removeLag(Port lag)
27782780 return false ;
27792781 }
27802782
2783+ removeAclTableGroup (lag);
2784+
27812785 SWSS_LOG_NOTICE (" Remove LAG %s lid:%lx" , lag.m_alias .c_str (), lag.m_lag_id );
27822786
27832787 m_portList.erase (lag.m_alias );
@@ -3178,3 +3182,46 @@ bool PortsOrch::getPortOperStatus(const Port& port, sai_port_oper_status_t& stat
31783182 return true ;
31793183}
31803184
3185+ bool PortsOrch::removeAclTableGroup (const Port &p)
3186+ {
3187+ sai_acl_bind_point_type_t bind_type;
3188+ switch (p.m_type )
3189+ {
3190+ case Port::PHY:
3191+ bind_type = SAI_ACL_BIND_POINT_TYPE_PORT;
3192+ break ;
3193+ case Port::LAG:
3194+ bind_type = SAI_ACL_BIND_POINT_TYPE_LAG;
3195+ break ;
3196+ case Port::VLAN:
3197+ bind_type = SAI_ACL_BIND_POINT_TYPE_VLAN;
3198+ break ;
3199+ default :
3200+ // Dealing with port, lag and vlan for now.
3201+ return true ;
3202+ }
3203+ sai_status_t ret;
3204+ if (p.m_ingress_acl_table_group_id != 0 )
3205+ {
3206+ ret = sai_acl_api->remove_acl_table_group (p.m_ingress_acl_table_group_id );
3207+ if (ret != SAI_STATUS_SUCCESS)
3208+ {
3209+ SWSS_LOG_ERROR (" Failed to remove ingress acl table group for %s" , p.m_alias .c_str ());
3210+ return false ;
3211+ }
3212+ gCrmOrch ->decCrmAclUsedCounter (CrmResourceType::CRM_ACL_GROUP, SAI_ACL_STAGE_INGRESS, bind_type, p.m_ingress_acl_table_group_id );
3213+ }
3214+
3215+ if (p.m_egress_acl_table_group_id != 0 )
3216+ {
3217+ ret = sai_acl_api->remove_acl_table_group (p.m_egress_acl_table_group_id );
3218+ if (ret != SAI_STATUS_SUCCESS)
3219+ {
3220+ SWSS_LOG_ERROR (" Failed to remove egress acl table group for %s" , p.m_alias .c_str ());
3221+ return false ;
3222+ }
3223+ gCrmOrch ->decCrmAclUsedCounter (CrmResourceType::CRM_ACL_GROUP, SAI_ACL_STAGE_EGRESS, bind_type, p.m_egress_acl_table_group_id );
3224+ }
3225+ return true ;
3226+ }
3227+
0 commit comments