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 Oct 12, 2020
1 parent eff5456 commit 7880c7e
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 @@ -2994,7 +2994,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 @@ -3764,7 +3764,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 @@ -3785,6 +3785,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 @@ -3876,6 +3887,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 @@ -3899,6 +3914,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 @@ -226,7 +226,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 7880c7e

Please sign in to comment.