Skip to content

Commit

Permalink
orchagent: Adding remove LAG member logic using linkup status (sonic-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuotian Cheng authored Oct 17, 2016
1 parent f3676e0 commit fb307b2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
5 changes: 3 additions & 2 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ void IntfsOrch::doTask(Consumer &consumer)
}

Port port;
/* Cannot locate interface */
if (!gPortsOrch->getPort(alias, port))
{
SWSS_LOG_ERROR("Failed to locate interface %s", alias.c_str());
throw logic_error("Failed to locate interface.");
it = consumer.m_toSync.erase(it);
continue;
}

if (m_syncdIntfses.find(alias) != m_syncdIntfses.end())
Expand Down
59 changes: 48 additions & 11 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,12 @@ void PortsOrch::doLagTask(Consumer &consumer)
else if (op == DEL_COMMAND)
{
Port lag;
getPort(lag_alias, lag);
/* Cannot locate LAG */
if (!getPort(lag_alias, lag))
{
it = consumer.m_toSync.erase(it);
continue;
}

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

if (op == SET_COMMAND)
{
/* Duplicate entry */
if (lag.m_members.find(port_alias) != lag.m_members.end())
string linkup_status;
for (auto i : kfvFieldsValues(t))
{
it = consumer.m_toSync.erase(it);
continue;
if (fvField(i) == "linkup")
linkup_status = fvValue(i);
}

/* Assert the port doesn't belong to any LAG */
assert(!port.m_lag_id && !port.m_lag_member_id);
/* Add LAG member */
if (linkup_status == "up")
{
/* Duplicate entry */
if (lag.m_members.find(port_alias) != lag.m_members.end())
{
it = consumer.m_toSync.erase(it);
continue;
}

/* Assert the port doesn't belong to any LAG */
assert(!port.m_lag_id && !port.m_lag_member_id);

if (addLagMember(lag, port))
it = consumer.m_toSync.erase(it);
else
it++;
}
/* Remove LAG member */
else /* linkup_status == "down" */
{
assert(lag.m_members.find(port_alias) != lag.m_members.end());

/* Cannot locate LAG or LAG member
* This happens at the time when teamd starts. The linkup
* is set to down in the beginning.
*/
if (!port.m_lag_id || !port.m_lag_member_id)
{
it = consumer.m_toSync.erase(it);
continue;
}

if (removeLagMember(lag, port))
it = consumer.m_toSync.erase(it);
else
it++;
}

if (addLagMember(lag, port))
it = consumer.m_toSync.erase(it);
else
it++;
}
else if (op == DEL_COMMAND)
{
Expand Down

0 comments on commit fb307b2

Please sign in to comment.