Skip to content

Commit

Permalink
[portsorch]: Set proper initial forwarding state for LAG member (soni…
Browse files Browse the repository at this point in the history
…c-net#1448)

* [portsorch]: Set proper initial forwarding state for LAG member.
* [portsorch]: Fix review comments.
  • Loading branch information
nazariig authored and abdosi committed Oct 21, 2020
1 parent 90b6def commit b274365
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ void PortsOrch::doLagMemberTask(Consumer &consumer)
/* Assert the port doesn't belong to any LAG already */
assert(!port.m_lag_id && !port.m_lag_member_id);

if (!addLagMember(lag, port))
if (!addLagMember(lag, port, (status == "enabled")))
{
it++;
continue;
Expand Down Expand Up @@ -3349,7 +3349,7 @@ void PortsOrch::getLagMember(Port &lag, vector<Port> &portv)
}
}

bool PortsOrch::addLagMember(Port &lag, Port &port)
bool PortsOrch::addLagMember(Port &lag, Port &port, bool enableForwarding)
{
SWSS_LOG_ENTER();

Expand All @@ -3370,6 +3370,17 @@ bool PortsOrch::addLagMember(Port &lag, Port &port)
attr.value.oid = port.m_port_id;
attrs.push_back(attr);

if (!enableForwarding)
{
attr.id = SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE;
attr.value.booldata = true;
attrs.push_back(attr);

attr.id = SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE;
attr.value.booldata = true;
attrs.push_back(attr);
}

sai_object_id_t lag_member_id;
sai_status_t status = sai_lag_api->create_lag_member(&lag_member_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());

Expand Down Expand Up @@ -3461,6 +3472,10 @@ bool PortsOrch::setCollectionOnLagMember(Port &lagMember, bool enableCollection)
return false;
}

SWSS_LOG_NOTICE("%s collection on LAG member %s",
enableCollection ? "Enable" : "Disable",
lagMember.m_alias.c_str());

return true;
}

Expand All @@ -3484,6 +3499,10 @@ bool PortsOrch::setDistributionOnLagMember(Port &lagMember, bool enableDistribut
return false;
}

SWSS_LOG_NOTICE("%s distribution on LAG member %s",
enableDistribution ? "Enable" : "Disable",
lagMember.m_alias.c_str());

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PortsOrch : public Orch, public Subject

bool addLag(string lag);
bool removeLag(Port lag);
bool addLagMember(Port &lag, Port &port);
bool addLagMember(Port &lag, Port &port, bool enableForwarding);
bool removeLagMember(Port &lag, Port &port);
bool setCollectionOnLagMember(Port &lagMember, bool enableCollection);
bool setDistributionOnLagMember(Port &lagMember, bool enableDistribution);
Expand Down

0 comments on commit b274365

Please sign in to comment.