Skip to content

Commit dc2ff77

Browse files
author
Shuotian Cheng
authored
[portsorch]: Move status comparison outside updatePortOperStatus function (#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]>
1 parent afdcf34 commit dc2ff77

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

orchagent/portsorch.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -2908,13 +2908,17 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
29082908

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

2911-
Port p;
2912-
if (!getPort(id, p))
2911+
Port port;
2912+
if (!getPort(id, port))
29132913
{
29142914
SWSS_LOG_ERROR("Failed to get port object for port id 0x%lx", id);
29152915
continue;
29162916
}
2917-
updatePortOperStatus(p, status);
2917+
2918+
if (status != port.m_oper_status)
2919+
{
2920+
updatePortOperStatus(port, status);
2921+
}
29182922
}
29192923

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

29242928
void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
29252929
{
2926-
if (status != port.m_oper_status)
2930+
SWSS_LOG_NOTICE("Port %s oper state set from %s to %s",
2931+
port.m_alias.c_str(), oper_status_strings.at(port.m_oper_status).c_str(),
2932+
oper_status_strings.at(status).c_str());
2933+
2934+
this->updateDbPortOperStatus(port.m_port_id, status);
2935+
if (status == SAI_PORT_OPER_STATUS_UP || port.m_oper_status == SAI_PORT_OPER_STATUS_UP)
29272936
{
2928-
SWSS_LOG_NOTICE("Port state changed for %s from %s to %s", port.m_alias.c_str(),
2929-
oper_status_strings.at(port.m_oper_status).c_str(), oper_status_strings.at(status).c_str());
2930-
this->updateDbPortOperStatus(port.m_port_id, status);
2931-
if(status == SAI_PORT_OPER_STATUS_UP || port.m_oper_status == SAI_PORT_OPER_STATUS_UP)
2932-
{
2933-
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
2934-
}
2937+
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
29352938
}
29362939
}
2940+
29372941
/*
29382942
* sync up orchagent with libsai/ASIC for port state.
29392943
*

0 commit comments

Comments
 (0)