Skip to content

Commit fb307b2

Browse files
author
Shuotian Cheng
authored
orchagent: Adding remove LAG member logic using linkup status (sonic-net#108)
1 parent f3676e0 commit fb307b2

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

orchagent/intfsorch.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ void IntfsOrch::doTask(Consumer &consumer)
110110
}
111111

112112
Port port;
113+
/* Cannot locate interface */
113114
if (!gPortsOrch->getPort(alias, port))
114115
{
115-
SWSS_LOG_ERROR("Failed to locate interface %s", alias.c_str());
116-
throw logic_error("Failed to locate interface.");
116+
it = consumer.m_toSync.erase(it);
117+
continue;
117118
}
118119

119120
if (m_syncdIntfses.find(alias) != m_syncdIntfses.end())

orchagent/portsorch.cpp

+48-11
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,12 @@ void PortsOrch::doLagTask(Consumer &consumer)
517517
else if (op == DEL_COMMAND)
518518
{
519519
Port lag;
520-
getPort(lag_alias, lag);
520+
/* Cannot locate LAG */
521+
if (!getPort(lag_alias, lag))
522+
{
523+
it = consumer.m_toSync.erase(it);
524+
continue;
525+
}
521526

522527
if (removeLag(lag))
523528
it = consumer.m_toSync.erase(it);
@@ -540,20 +545,52 @@ void PortsOrch::doLagTask(Consumer &consumer)
540545

541546
if (op == SET_COMMAND)
542547
{
543-
/* Duplicate entry */
544-
if (lag.m_members.find(port_alias) != lag.m_members.end())
548+
string linkup_status;
549+
for (auto i : kfvFieldsValues(t))
545550
{
546-
it = consumer.m_toSync.erase(it);
547-
continue;
551+
if (fvField(i) == "linkup")
552+
linkup_status = fvValue(i);
548553
}
549554

550-
/* Assert the port doesn't belong to any LAG */
551-
assert(!port.m_lag_id && !port.m_lag_member_id);
555+
/* Add LAG member */
556+
if (linkup_status == "up")
557+
{
558+
/* Duplicate entry */
559+
if (lag.m_members.find(port_alias) != lag.m_members.end())
560+
{
561+
it = consumer.m_toSync.erase(it);
562+
continue;
563+
}
564+
565+
/* Assert the port doesn't belong to any LAG */
566+
assert(!port.m_lag_id && !port.m_lag_member_id);
567+
568+
if (addLagMember(lag, port))
569+
it = consumer.m_toSync.erase(it);
570+
else
571+
it++;
572+
}
573+
/* Remove LAG member */
574+
else /* linkup_status == "down" */
575+
{
576+
assert(lag.m_members.find(port_alias) != lag.m_members.end());
577+
578+
/* Cannot locate LAG or LAG member
579+
* This happens at the time when teamd starts. The linkup
580+
* is set to down in the beginning.
581+
*/
582+
if (!port.m_lag_id || !port.m_lag_member_id)
583+
{
584+
it = consumer.m_toSync.erase(it);
585+
continue;
586+
}
587+
588+
if (removeLagMember(lag, port))
589+
it = consumer.m_toSync.erase(it);
590+
else
591+
it++;
592+
}
552593

553-
if (addLagMember(lag, port))
554-
it = consumer.m_toSync.erase(it);
555-
else
556-
it++;
557594
}
558595
else if (op == DEL_COMMAND)
559596
{

0 commit comments

Comments
 (0)