From 2bef62b7fe5f32a6b456ffb49a31c07cea7e39b2 Mon Sep 17 00:00:00 2001 From: rupesh-k <53595165+rupesh-k@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:28:40 +0530 Subject: [PATCH] Validate LAG has members before mirror session create (#2130) * Validate LAG has members before mirror session create --- orchagent/mirrororch.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 0a73030f4072..6568c63d37c7 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -327,6 +327,7 @@ bool MirrorOrch::validateSrcPortList(const string& srcPortList) if (port.m_type == Port::LAG) { vector portv; + int portCount = 0; m_portsOrch->getLagMember(port, portv); for (const auto p : portv) { @@ -336,6 +337,13 @@ bool MirrorOrch::validateSrcPortList(const string& srcPortList) p.m_alias.c_str(), port.m_alias.c_str(), srcPortList.c_str()); return false; } + portCount++; + } + if (!portCount) + { + SWSS_LOG_ERROR("Source LAG %s is empty. set mirror session to inactive", + port.m_alias.c_str());; + return false; } } }