From 0e0ee284fd5ce6be4626f53f44d91ed1b4a1ba93 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Wed, 9 Oct 2019 17:49:58 -0700 Subject: [PATCH 1/3] [aclorch]: Check for existing mirror table only when creating a new table Signed-off-by: Danny Allen --- orchagent/aclorch.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 24104fd484..fe00b8e424 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2446,6 +2446,21 @@ 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) + { + if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty()) || + (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty())) + { + SWSS_LOG_ERROR("Mirror table has already been created"); + 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) @@ -2878,15 +2893,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; From f897a7179aa9b42ae8f36e2c87455d8c227f0629 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Thu, 10 Oct 2019 17:45:29 -0700 Subject: [PATCH 2/3] Display mirror table type --- orchagent/aclorch.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index fe00b8e424..b74e6c4387 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2453,10 +2453,20 @@ bool AclOrch::addAclTable(AclTable &newTable, string table_id) auto table_type = newTable.type; if (table_type == ACL_TABLE_MIRROR || table_type == ACL_TABLE_MIRRORV6) { - if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty()) || - (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty())) + string mirror_type; + if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty())) { - SWSS_LOG_ERROR("Mirror table has already been created"); + 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; } } From eee1ed34e5b67b20bb5566a4c3bfd39edfea78bb Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Thu, 10 Oct 2019 18:09:04 -0700 Subject: [PATCH 3/3] Delete extra paren --- orchagent/aclorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index b74e6c4387..8d809ec652 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2459,7 +2459,7 @@ bool AclOrch::addAclTable(AclTable &newTable, string table_id) mirror_type = TABLE_TYPE_MIRROR; } - if (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty())) + if (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty()) { mirror_type = TABLE_TYPE_MIRRORV6; }