From 1962d0914dc0846d32bab5471ee7d6b662cc7d50 Mon Sep 17 00:00:00 2001 From: InspurSDN Date: Thu, 16 Nov 2023 16:28:32 +0800 Subject: [PATCH] orchagent would crash, when portsorch failed to remove bridge port Root cause: Failed to remove bridge port becasue reference count is not 0 Solution: 1. put DEL task into m_toSync, when portsorch failed to remove bridge port 2. if port was removed from vlan but m_bridge_port_id is not SAI_NULL_OBJECT_ID, portsorch will try to remove bridgeport again until reference count is 0 --- orchagent/portsorch.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index a7a6e25548..ff19acb376 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4065,7 +4065,12 @@ void PortsOrch::doVlanMemberTask(Consumer &consumer) { if (m_portVlanMember[port.m_alias].empty()) { - removeBridgePort(port); + if (!removeBridgePort(port)) + { + SWSS_LOG_NOTICE("Failed to removeBridgePort %s",port.m_alias.c_str()); + it++; + continue; + } } it = consumer.m_toSync.erase(it); } @@ -4074,6 +4079,19 @@ void PortsOrch::doVlanMemberTask(Consumer &consumer) it++; } } + else if (m_portVlanMember[port.m_alias].empty() && port.m_bridge_port_id != SAI_NULL_OBJECT_ID) + { + SWSS_LOG_WARN("Port %s was removed from vlan, but it is still as bridge port OID %" PRIx64 ", try to remove bridge port again", port.m_alias.c_str(), port.m_bridge_port_id); + if (!removeBridgePort(port)) + { + it++; + continue; + } + else + { + it = consumer.m_toSync.erase(it); + } + } else /* Cannot locate the VLAN */ it = consumer.m_toSync.erase(it); @@ -4990,11 +5008,15 @@ bool PortsOrch::removeBridgePort(Port &port) { SWSS_LOG_ERROR("Failed to remove bridge port %s from default 1Q bridge, rv:%d", port.m_alias.c_str(), status); +#if 0 task_process_status handle_status = handleSaiRemoveStatus(SAI_API_BRIDGE, status); if (handle_status != task_success) { return parseHandleSaiStatusFailure(handle_status); } +#else + return false; +#endif } saiOidToAlias.erase(port.m_bridge_port_id); port.m_bridge_port_id = SAI_NULL_OBJECT_ID;