Skip to content

Commit

Permalink
[orchagent]: Check VLAN is created before creating VLAN members (soni…
Browse files Browse the repository at this point in the history
…c-net#181)

Signed-off-by: Shuotian Cheng <shuche@microsoft.com>
  • Loading branch information
Shuotian Cheng authored Mar 27, 2017
1 parent 8752d35 commit a1cbc37
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up)
up ? "UP" : "DOWN", id);
return false;
}
SWSS_LOG_NOTICE("Set admin status %s to port pid:%lx",
SWSS_LOG_INFO("Set admin status %s to port pid:%lx",
up ? "UP" : "DOWN", id);
return true;
}
Expand Down Expand Up @@ -330,7 +330,9 @@ void PortsOrch::doPortTask(Consumer &consumer)

/* Determin if the port has already been initialized before */
if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id)
SWSS_LOG_NOTICE("Port has already been initialized before alias:%s", alias.c_str());
{
SWSS_LOG_INFO("Port has already been initialized before alias:%s", alias.c_str());
}
else
{
Port p(alias, Port::PHY);
Expand Down Expand Up @@ -368,10 +370,10 @@ void PortsOrch::doPortTask(Consumer &consumer)
if (getPort(alias, p))
{
if (setPortAdminStatus(p.m_port_id, admin_status == "up"))
SWSS_LOG_NOTICE("Port is set to admin %s alias:%s", admin_status.c_str(), alias.c_str());
SWSS_LOG_NOTICE("Set port %s admin status to %s", alias.c_str(), admin_status.c_str());
else
{
SWSS_LOG_ERROR("Failed to set port to admin %s alias:%s", admin_status.c_str(), alias.c_str());
SWSS_LOG_ERROR("Failed to set port %s admin status to %s", alias.c_str(), admin_status.c_str());
it++;
continue;
}
Expand Down Expand Up @@ -459,8 +461,21 @@ void PortsOrch::doVlanTask(Consumer &consumer)
{
assert(m_portList.find(vlan_alias) != m_portList.end());
Port vlan, port;
getPort(vlan_alias, vlan);
getPort(port_alias, port);

/* When VLAN member is to be created before VLAN is created */
if (!getPort(vlan_alias, vlan))
{
SWSS_LOG_INFO("Failed to locate VLAN %s", vlan_alias.c_str());
it++;
continue;
}

if (!getPort(port_alias, port))
{
SWSS_LOG_ERROR("Failed to locate port %s", port_alias.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

if (op == SET_COMMAND)
{
Expand Down Expand Up @@ -570,8 +585,21 @@ void PortsOrch::doLagTask(Consumer &consumer)
{
assert(m_portList.find(lag_alias) != m_portList.end());
Port lag, port;
getPort(lag_alias, lag);
getPort(port_alias, port);

/* When LAG member is to be created before LAG is created */
if (!getPort(lag_alias, lag))
{
SWSS_LOG_INFO("Failed to locate LAG %s", lag_alias.c_str());
it++;
continue;
}

if (!getPort(port_alias, port))
{
SWSS_LOG_ERROR("Failed to locate port %s", port_alias.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

/* Add a LAG member */
if (op == SET_COMMAND)
Expand Down Expand Up @@ -871,7 +899,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port)
return false;
}

SWSS_LOG_NOTICE("Set port %s VLAN ID to %hu", port.m_alias.c_str(), vlan.m_vlan_id);
SWSS_LOG_INFO("Set port %s VLAN ID to %hu", port.m_alias.c_str(), vlan.m_vlan_id);

port.m_vlan_id = vlan.m_vlan_id;
port.m_port_vlan_id = vlan.m_vlan_id;
Expand Down

0 comments on commit a1cbc37

Please # to comment.