Skip to content

Commit d80094b

Browse files
authored
[aclorch] Do not fail ACL rule remove flow if rule already deleted (sonic-net#2183)
- What I did Do not fail ACL rule remove flow if rule already deleted. - Why I did it When ACL table that contains rules is being deleted, its rules are being deleted automatically. In the case when ACL rule handler is called for a rule that was already deleted, handler should do nothing and pass. - How I verified it config acl add table -p Ethernet72 -s ingress DATAACL L3 config acl update full /tmp/56521_acl_file.json config acl add table -p Ethernet72 -s egress DATAACL L3 config acl update full 56521_acl_file.json docker exec -it syncd sx_api_flex_acl_dump.py => verify ACL rules exist in "ACL Rules" table. Co-authored-by: liora <[email protected]>
1 parent bea0b70 commit d80094b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

orchagent/aclorch.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3617,7 +3617,9 @@ bool AclOrch::removeAclRule(string table_id, string rule_id)
36173617
auto rule = getAclRule(table_id, rule_id);
36183618
if (!rule)
36193619
{
3620-
return false;
3620+
SWSS_LOG_NOTICE("ACL rule [%s] in table [%s] already deleted",
3621+
rule_id.c_str(), table_id.c_str());
3622+
return true;
36213623
}
36223624

36233625
if (rule->hasCounter())

tests/mock_tests/aclorch_ut.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -1719,4 +1719,28 @@ namespace aclorch_test
17191719
ASSERT_TRUE(orch->m_aclOrch->removeAclRule(rule->getTableId(), rule->getId()));
17201720
}
17211721

1722+
TEST_F(AclOrchTest, deleteNonExistingRule)
1723+
{
1724+
string tableId = "acl_table";
1725+
string ruleId = "acl_rule";
1726+
1727+
auto orch = createAclOrch();
1728+
1729+
// add acl table
1730+
auto kvfAclTable = deque<KeyOpFieldsValuesTuple>({{
1731+
tableId,
1732+
SET_COMMAND,
1733+
{
1734+
{ ACL_TABLE_DESCRIPTION, "L3 table" },
1735+
{ ACL_TABLE_TYPE, TABLE_TYPE_L3 },
1736+
{ ACL_TABLE_STAGE, STAGE_INGRESS },
1737+
{ ACL_TABLE_PORTS, "1,2" }
1738+
}
1739+
}});
1740+
1741+
orch->doAclTableTask(kvfAclTable);
1742+
1743+
// try to delete non existing acl rule
1744+
ASSERT_TRUE(orch->m_aclOrch->removeAclRule(tableId, ruleId));
1745+
}
17221746
} // namespace nsAclOrchTest

0 commit comments

Comments
 (0)