From 7880c7eb7fbe027d3d04bab0f8303a100f825248 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Mon, 12 Oct 2020 19:19:44 +0300 Subject: [PATCH] [portsorch]: Set proper initial forwarding state for LAG member (#1448) * [portsorch]: Set proper initial forwarding state for LAG member. * [portsorch]: Fix review comments. --- orchagent/portsorch.cpp | 23 +++++++++++++++++++++-- orchagent/portsorch.h | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 20663b35c24d..c50986839440 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -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; @@ -3764,7 +3764,7 @@ void PortsOrch::getLagMember(Port &lag, vector &portv) } } -bool PortsOrch::addLagMember(Port &lag, Port &port) +bool PortsOrch::addLagMember(Port &lag, Port &port, bool enableForwarding) { SWSS_LOG_ENTER(); @@ -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()); @@ -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; } @@ -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; } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 936f1ff07eac..2b5896b7bab8 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -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);