Skip to content

Commit

Permalink
[portsorch]: Move status comparison outside updatePortOperStatus func…
Browse files Browse the repository at this point in the history
…tion (sonic-net#679)

updatePortOperStatus will update the port operation status regardless of the
previous operation status. The comparison logic is moved into the notification
receiving part.

Signed-off-by: Shu0T1an ChenG <[email protected]>
  • Loading branch information
Shuotian Cheng authored Nov 12, 2018
1 parent afdcf34 commit dc2ff77
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2908,13 +2908,17 @@ void PortsOrch::doTask(NotificationConsumer &consumer)

SWSS_LOG_NOTICE("Get port state change notification id:%lx status:%d", id, status);

Port p;
if (!getPort(id, p))
Port port;
if (!getPort(id, port))
{
SWSS_LOG_ERROR("Failed to get port object for port id 0x%lx", id);
continue;
}
updatePortOperStatus(p, status);

if (status != port.m_oper_status)
{
updatePortOperStatus(port, status);
}
}

sai_deserialize_free_port_oper_status_ntf(count, portoperstatus);
Expand All @@ -2923,17 +2927,17 @@ void PortsOrch::doTask(NotificationConsumer &consumer)

void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
{
if (status != port.m_oper_status)
SWSS_LOG_NOTICE("Port %s oper state set from %s to %s",
port.m_alias.c_str(), oper_status_strings.at(port.m_oper_status).c_str(),
oper_status_strings.at(status).c_str());

this->updateDbPortOperStatus(port.m_port_id, status);
if (status == SAI_PORT_OPER_STATUS_UP || port.m_oper_status == SAI_PORT_OPER_STATUS_UP)
{
SWSS_LOG_NOTICE("Port state changed for %s from %s to %s", port.m_alias.c_str(),
oper_status_strings.at(port.m_oper_status).c_str(), oper_status_strings.at(status).c_str());
this->updateDbPortOperStatus(port.m_port_id, status);
if(status == SAI_PORT_OPER_STATUS_UP || port.m_oper_status == SAI_PORT_OPER_STATUS_UP)
{
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
}
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
}
}

/*
* sync up orchagent with libsai/ASIC for port state.
*
Expand Down

0 comments on commit dc2ff77

Please sign in to comment.