Skip to content

Commit a1cbc37

Browse files
author
Shuotian Cheng
authored
[orchagent]: Check VLAN is created before creating VLAN members (sonic-net#181)
Signed-off-by: Shuotian Cheng <[email protected]>
1 parent 8752d35 commit a1cbc37

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

orchagent/portsorch.cpp

+37-9
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up)
214214
up ? "UP" : "DOWN", id);
215215
return false;
216216
}
217-
SWSS_LOG_NOTICE("Set admin status %s to port pid:%lx",
217+
SWSS_LOG_INFO("Set admin status %s to port pid:%lx",
218218
up ? "UP" : "DOWN", id);
219219
return true;
220220
}
@@ -330,7 +330,9 @@ void PortsOrch::doPortTask(Consumer &consumer)
330330

331331
/* Determin if the port has already been initialized before */
332332
if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id)
333-
SWSS_LOG_NOTICE("Port has already been initialized before alias:%s", alias.c_str());
333+
{
334+
SWSS_LOG_INFO("Port has already been initialized before alias:%s", alias.c_str());
335+
}
334336
else
335337
{
336338
Port p(alias, Port::PHY);
@@ -368,10 +370,10 @@ void PortsOrch::doPortTask(Consumer &consumer)
368370
if (getPort(alias, p))
369371
{
370372
if (setPortAdminStatus(p.m_port_id, admin_status == "up"))
371-
SWSS_LOG_NOTICE("Port is set to admin %s alias:%s", admin_status.c_str(), alias.c_str());
373+
SWSS_LOG_NOTICE("Set port %s admin status to %s", alias.c_str(), admin_status.c_str());
372374
else
373375
{
374-
SWSS_LOG_ERROR("Failed to set port to admin %s alias:%s", admin_status.c_str(), alias.c_str());
376+
SWSS_LOG_ERROR("Failed to set port %s admin status to %s", alias.c_str(), admin_status.c_str());
375377
it++;
376378
continue;
377379
}
@@ -459,8 +461,21 @@ void PortsOrch::doVlanTask(Consumer &consumer)
459461
{
460462
assert(m_portList.find(vlan_alias) != m_portList.end());
461463
Port vlan, port;
462-
getPort(vlan_alias, vlan);
463-
getPort(port_alias, port);
464+
465+
/* When VLAN member is to be created before VLAN is created */
466+
if (!getPort(vlan_alias, vlan))
467+
{
468+
SWSS_LOG_INFO("Failed to locate VLAN %s", vlan_alias.c_str());
469+
it++;
470+
continue;
471+
}
472+
473+
if (!getPort(port_alias, port))
474+
{
475+
SWSS_LOG_ERROR("Failed to locate port %s", port_alias.c_str());
476+
it = consumer.m_toSync.erase(it);
477+
continue;
478+
}
464479

465480
if (op == SET_COMMAND)
466481
{
@@ -570,8 +585,21 @@ void PortsOrch::doLagTask(Consumer &consumer)
570585
{
571586
assert(m_portList.find(lag_alias) != m_portList.end());
572587
Port lag, port;
573-
getPort(lag_alias, lag);
574-
getPort(port_alias, port);
588+
589+
/* When LAG member is to be created before LAG is created */
590+
if (!getPort(lag_alias, lag))
591+
{
592+
SWSS_LOG_INFO("Failed to locate LAG %s", lag_alias.c_str());
593+
it++;
594+
continue;
595+
}
596+
597+
if (!getPort(port_alias, port))
598+
{
599+
SWSS_LOG_ERROR("Failed to locate port %s", port_alias.c_str());
600+
it = consumer.m_toSync.erase(it);
601+
continue;
602+
}
575603

576604
/* Add a LAG member */
577605
if (op == SET_COMMAND)
@@ -871,7 +899,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port)
871899
return false;
872900
}
873901

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

876904
port.m_vlan_id = vlan.m_vlan_id;
877905
port.m_port_vlan_id = vlan.m_vlan_id;

0 commit comments

Comments
 (0)