Skip to content

Commit

Permalink
Dynamic Port breakout fix the crash, port down event processing after… (
Browse files Browse the repository at this point in the history
sonic-net#727)

Fix the syncd crash during Dynamic Port Breakout (DPB). The syncd is processing in-transit port events after port has been removed. Add check to avoid it.
  • Loading branch information
vishnushetty committed Dec 10, 2020
1 parent 620d7a4 commit ccf59d7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
17 changes: 16 additions & 1 deletion syncd/NotificationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void NotificationProcessor::process_on_port_state_change(
for (uint32_t i = 0; i < count; i++)
{
sai_port_oper_status_notification_t *oper_stat = &data[i];
sai_object_id_t rid = oper_stat->port_id;

/*
* We are using switch_rid as null, since port should be already
Expand All @@ -397,7 +398,21 @@ void NotificationProcessor::process_on_port_state_change(
* switch vid.
*/

oper_stat->port_id = m_translator->translateRidToVid(oper_stat->port_id, SAI_NULL_OBJECT_ID);
SWSS_LOG_INFO("Port RID %s state change notification",
sai_serialize_object_id(rid).c_str());

if (false == m_translator->tryTranslateRidToVid(rid, oper_stat->port_id))
{
SWSS_LOG_WARN("Port RID %s transalted to null VID!!!", sai_serialize_object_id(rid).c_str());
}

/*
* Port may be in process of removal. OA may recieve notification for VID either
* SAI_NULL_OBJECT_ID or non exist at time of processing
*/

SWSS_LOG_INFO("Port VID %s state change notification",
sai_serialize_object_id(oper_stat->port_id).c_str());
}

std::string s = sai_serialize_port_oper_status_ntf(count, data);
Expand Down
35 changes: 35 additions & 0 deletions syncd/VirtualOidTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@ VirtualOidTranslator::VirtualOidTranslator(
// empty
}

bool VirtualOidTranslator::tryTranslateRidToVid(
_In_ sai_object_id_t rid,
_Out_ sai_object_id_t &vid)
{
SWSS_LOG_ENTER();

std::lock_guard<std::mutex> lock(m_mutex);

if (rid == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_DEBUG("translated RID null to VID null");

vid = SAI_NULL_OBJECT_ID;
return true;
}

auto it = m_rid2vid.find(vid);

if (it != m_rid2vid.end())
{
vid = it->second;
return true;
}

vid = m_client->getVidForRid(rid);

if (vid == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_DEBUG("translated RID %s to VID null", sai_serialize_object_id(rid).c_str());
return false;
}

return true;
}

sai_object_id_t VirtualOidTranslator::translateRidToVid(
_In_ sai_object_id_t rid,
_In_ sai_object_id_t switchVid)
Expand Down
10 changes: 10 additions & 0 deletions syncd/VirtualOidTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ namespace syncd
_In_ sai_object_id_t rid,
_In_ sai_object_id_t switchVid);

/*
* This method will try get VID for given RID.
* Returns true if input RID is null object and out VID is null object.
* Returns true if able to find RID and out VID object.
* Returns false if not able to find RID and out VID is null object.
*/
bool tryTranslateRidToVid(
_In_ sai_object_id_t rid,
_Out_ sai_object_id_t &vid);

void translateRidToVid(
_Inout_ sai_object_list_t& objectList,
_In_ sai_object_id_t switchVid);
Expand Down

0 comments on commit ccf59d7

Please sign in to comment.