Skip to content

Commit

Permalink
Restore port oper status form appDB port table during restore phase o… (
Browse files Browse the repository at this point in the history
sonic-net#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]>
  • Loading branch information
jipanyang authored and lguohan committed Nov 14, 2018
1 parent 48c3bfb commit 75972e7
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,24 @@ bool PortsOrch::initializePort(Port &p)
p.m_oper_status = SAI_PORT_OPER_STATUS_UP;
}

/*
* If oper_status is not empty, orchagent is doing warm start, restore hostif oper status.
*/
if (!operStatus.empty())
{
sai_attribute_t attr;
attr.id = SAI_HOSTIF_ATTR_OPER_STATUS;
attr.value.booldata = (p.m_oper_status == SAI_PORT_OPER_STATUS_UP);

sai_status_t status = sai_hostif_api->set_hostif_attribute(p.m_hif_id, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("Failed to set operation status %s to host interface %s",
operStatus.c_str(), p.m_alias.c_str());
return false;
}
}

return true;
}

Expand Down Expand Up @@ -2914,11 +2932,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
SWSS_LOG_ERROR("Failed to get port object for port id 0x%lx", id);
continue;
}

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

sai_deserialize_free_port_oper_status_ntf(count, portoperstatus);
Expand All @@ -2930,11 +2944,13 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t 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)
if (status != port.m_oper_status)
{
this->setHostIntfsOperStatus(port.m_port_id, status == SAI_PORT_OPER_STATUS_UP);
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);
}
}
}

Expand Down Expand Up @@ -2972,4 +2988,4 @@ void PortsOrch::refreshPortStatus()
updatePortOperStatus(p, status);
}
}
}
}

0 comments on commit 75972e7

Please sign in to comment.