From 9f765f72b5b88260c16032a8e559d6c0177150f3 Mon Sep 17 00:00:00 2001 From: Danny Allen <52468448+daall@users.noreply.github.com> Date: Fri, 11 Oct 2019 11:23:50 -0700 Subject: [PATCH] [aclorch]: Check for existing mirror table only when creating a new table (#1089) * Display mirror table type Signed-off-by: Danny Allen --- orchagent/aclorch.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 64037efe7350..2ce0ad9bf6e9 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2413,6 +2413,31 @@ bool AclOrch::addAclTable(AclTable &newTable, string table_id) return false; } } + else + { + // If ACL table is new, check for the existence of current mirror tables + // Note: only one table per mirror type can be created + auto table_type = newTable.type; + if (table_type == ACL_TABLE_MIRROR || table_type == ACL_TABLE_MIRRORV6) + { + string mirror_type; + if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty())) + { + mirror_type = TABLE_TYPE_MIRROR; + } + + if (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty()) + { + mirror_type = TABLE_TYPE_MIRRORV6; + } + + if (!mirror_type.empty()) + { + SWSS_LOG_ERROR("Mirror table %s has already been created", mirror_type.c_str()); + return false; + } + } + } // Check if a separate mirror table is needed or not based on the platform if (newTable.type == ACL_TABLE_MIRROR || newTable.type == ACL_TABLE_MIRRORV6) @@ -2845,15 +2870,6 @@ bool AclOrch::processAclTableType(string type, acl_table_type_t &table_type) SWSS_LOG_ERROR("Mirror table type %s is not supported", type.c_str()); return false; } - - // Check the existence of current mirror tables - // Note: only one table per type could be created - if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty()) || - (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty())) - { - SWSS_LOG_ERROR("Mirror table table_type %s has already been created", type.c_str()); - return false; - } } return true;