Skip to content

Commit 75972e7

Browse files
jipanyanglguohan
authored andcommitted
Restore port oper status form appDB port table during restore phase o… (#683)
* Restore port oper status form appDB port table during restore phase of warm restart Signed-off-by: Jipan Yang <[email protected]> * Restore port oper_status upon initializePort() for warm start Signed-off-by: Jipan Yang <[email protected]>
1 parent 48c3bfb commit 75972e7

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

orchagent/portsorch.cpp

+26-10
Original file line numberDiff line numberDiff line change
@@ -2304,6 +2304,24 @@ bool PortsOrch::initializePort(Port &p)
23042304
p.m_oper_status = SAI_PORT_OPER_STATUS_UP;
23052305
}
23062306

2307+
/*
2308+
* If oper_status is not empty, orchagent is doing warm start, restore hostif oper status.
2309+
*/
2310+
if (!operStatus.empty())
2311+
{
2312+
sai_attribute_t attr;
2313+
attr.id = SAI_HOSTIF_ATTR_OPER_STATUS;
2314+
attr.value.booldata = (p.m_oper_status == SAI_PORT_OPER_STATUS_UP);
2315+
2316+
sai_status_t status = sai_hostif_api->set_hostif_attribute(p.m_hif_id, &attr);
2317+
if (status != SAI_STATUS_SUCCESS)
2318+
{
2319+
SWSS_LOG_WARN("Failed to set operation status %s to host interface %s",
2320+
operStatus.c_str(), p.m_alias.c_str());
2321+
return false;
2322+
}
2323+
}
2324+
23072325
return true;
23082326
}
23092327

@@ -2914,11 +2932,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
29142932
SWSS_LOG_ERROR("Failed to get port object for port id 0x%lx", id);
29152933
continue;
29162934
}
2917-
2918-
if (status != port.m_oper_status)
2919-
{
2920-
updatePortOperStatus(port, status);
2921-
}
2935+
updatePortOperStatus(port, status);
29222936
}
29232937

29242938
sai_deserialize_free_port_oper_status_ntf(count, portoperstatus);
@@ -2930,11 +2944,13 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
29302944
SWSS_LOG_NOTICE("Port %s oper state set from %s to %s",
29312945
port.m_alias.c_str(), oper_status_strings.at(port.m_oper_status).c_str(),
29322946
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)
2947+
if (status != port.m_oper_status)
29362948
{
2937-
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
2949+
this->updateDbPortOperStatus(port.m_port_id, status);
2950+
if (status == SAI_PORT_OPER_STATUS_UP || port.m_oper_status == SAI_PORT_OPER_STATUS_UP)
2951+
{
2952+
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
2953+
}
29382954
}
29392955
}
29402956

@@ -2972,4 +2988,4 @@ void PortsOrch::refreshPortStatus()
29722988
updatePortOperStatus(p, status);
29732989
}
29742990
}
2975-
}
2991+
}

0 commit comments

Comments
 (0)