From 7e080ab49f30f4fd5f4b7aa0eafcb7fecd98d3eb Mon Sep 17 00:00:00 2001 From: Prabhat Aravind Date: Tue, 13 Jun 2023 21:23:20 +0000 Subject: [PATCH] orchagent: copp: create trap group only if trap action is copy or trap Signed-off-by: Prabhat Aravind --- orchagent/copporch.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/orchagent/copporch.cpp b/orchagent/copporch.cpp index 8a58ae73a08..bc8aaf8a955 100644 --- a/orchagent/copporch.cpp +++ b/orchagent/copporch.cpp @@ -835,10 +835,6 @@ bool CoppOrch::trapGroupProcessTrapIdChange (string trap_group_name, { sai_attribute_t attr; vector add_trap_attr; - attr.id = SAI_HOSTIF_TRAP_ATTR_TRAP_GROUP; - attr.value.oid = m_trap_group_map[trap_group_name]; - - add_trap_attr.push_back(attr); for(auto i: add_trap_ids) { @@ -851,12 +847,26 @@ bool CoppOrch::trapGroupProcessTrapIdChange (string trap_group_name, } } + bool associate_trap_group = false; for (auto it: m_trap_group_trap_id_attrs[trap_group_name]) { attr.id = it.first; attr.value = it.second; add_trap_attr.push_back(attr); + if (attr.id == SAI_HOSTIF_TRAP_ATTR_PACKET_ACTION && + (attr.value.s32 == SAI_PACKET_ACTION_TRAP || attr.value.s32 == SAI_PACKET_ACTION_COPY)) + { + associate_trap_group = true; + } + } + + if (associate_trap_group) + { + attr.id = SAI_HOSTIF_TRAP_ATTR_TRAP_GROUP; + attr.value.oid = m_trap_group_map[trap_group_name]; + add_trap_attr.push_back(attr); } + if (!applyAttributesToTrapIds(m_trap_group_map[trap_group_name], add_trap_ids, add_trap_attr)) {