Skip to content

Commit

Permalink
[aclorch]: Check for existing mirror table only when creating a new t…
Browse files Browse the repository at this point in the history
…able (sonic-net#1089)

* Display mirror table type
Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored and stcheng committed Oct 11, 2019
1 parent 4c10260 commit 9f765f7
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9f765f7

Please sign in to comment.