Skip to content

Commit 9f765f7

Browse files
daallstcheng
authored andcommitted
[aclorch]: Check for existing mirror table only when creating a new table (#1089)
* Display mirror table type Signed-off-by: Danny Allen <[email protected]>
1 parent 4c10260 commit 9f765f7

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

orchagent/aclorch.cpp

+25-9
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,31 @@ bool AclOrch::addAclTable(AclTable &newTable, string table_id)
24132413
return false;
24142414
}
24152415
}
2416+
else
2417+
{
2418+
// If ACL table is new, check for the existence of current mirror tables
2419+
// Note: only one table per mirror type can be created
2420+
auto table_type = newTable.type;
2421+
if (table_type == ACL_TABLE_MIRROR || table_type == ACL_TABLE_MIRRORV6)
2422+
{
2423+
string mirror_type;
2424+
if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty()))
2425+
{
2426+
mirror_type = TABLE_TYPE_MIRROR;
2427+
}
2428+
2429+
if (table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty())
2430+
{
2431+
mirror_type = TABLE_TYPE_MIRRORV6;
2432+
}
2433+
2434+
if (!mirror_type.empty())
2435+
{
2436+
SWSS_LOG_ERROR("Mirror table %s has already been created", mirror_type.c_str());
2437+
return false;
2438+
}
2439+
}
2440+
}
24162441

24172442
// Check if a separate mirror table is needed or not based on the platform
24182443
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)
28452870
SWSS_LOG_ERROR("Mirror table type %s is not supported", type.c_str());
28462871
return false;
28472872
}
2848-
2849-
// Check the existence of current mirror tables
2850-
// Note: only one table per type could be created
2851-
if ((table_type == ACL_TABLE_MIRROR && !m_mirrorTableId.empty()) ||
2852-
(table_type == ACL_TABLE_MIRRORV6 && !m_mirrorV6TableId.empty()))
2853-
{
2854-
SWSS_LOG_ERROR("Mirror table table_type %s has already been created", type.c_str());
2855-
return false;
2856-
}
28572873
}
28582874

28592875
return true;

0 commit comments

Comments
 (0)