Skip to content

Commit 9ed3026

Browse files
[NAT] ACL Rule with DO_NOT_NAT action is getting failed. (#1502)
Issue: The ACL rule addition with PACKET_ACTION= "DO_NOT_NAT" failed as the SAI acl "no-nat" action not supported for INGRESS stage. Fix: Made changes to add "SAI_ACL_ACTION_TYPE_NO_NAT" action as supported for INGRESS stage. After the fix, verified that ACL Table and rule is created. Signed-off-by: Akhilesh Samineni <[email protected]>
1 parent c39a4b1 commit 9ed3026

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

orchagent/aclorch.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ static const acl_capabilities_t defaultAclActionsSupported =
124124
ACL_STAGE_INGRESS,
125125
{
126126
SAI_ACL_ACTION_TYPE_PACKET_ACTION,
127-
SAI_ACL_ACTION_TYPE_MIRROR_INGRESS
127+
SAI_ACL_ACTION_TYPE_MIRROR_INGRESS,
128+
SAI_ACL_ACTION_TYPE_NO_NAT
128129
}
129130
},
130131
{

tests/dvslib/dvs_acl.py

+23
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,26 @@ def verify_redirect_acl_rule(
389389
self._check_acl_entry_base(fvs, sai_qualifiers, "REDIRECT", priority)
390390
self._check_acl_entry_redirect_action(fvs, expected_destination)
391391

392+
def verify_nat_acl_rule(
393+
self,
394+
sai_qualifiers: Dict[str, str],
395+
priority: str = "2020",
396+
acl_rule_id=None
397+
) -> None:
398+
"""Verify that an ACL nat rule has the correct ASIC DB representation.
399+
400+
Args:
401+
sai_qualifiers: The expected set of SAI qualifiers to be found in ASIC DB.
402+
priority: The priority of the rule.
403+
acl_rule_id: A specific OID to check in ASIC DB. If left empty, this method
404+
assumes that only one rule exists in ASIC DB.
405+
"""
406+
if not acl_rule_id:
407+
acl_rule_id = self._get_acl_rule_id()
408+
409+
fvs = self.asic_db.wait_for_entry("ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY", acl_rule_id)
410+
self._check_acl_entry_base(fvs, sai_qualifiers, "DO_NOT_NAT", priority)
411+
392412
def verify_mirror_acl_rule(
393413
self,
394414
sai_qualifiers: Dict[str, str],
@@ -527,6 +547,9 @@ def _check_acl_entry_base(
527547
assert action == "REDIRECT"
528548
elif "SAI_ACL_ENTRY_ATTR_ACTION_MIRROR" in k:
529549
assert action == "MIRROR"
550+
elif "SAI_ACL_ENTRY_ATTR_ACTION_NO_NAT" in k:
551+
assert action == "DO_NOT_NAT"
552+
assert v == "true"
530553
elif k in qualifiers:
531554
assert qualifiers[k](v)
532555
else:

tests/test_nat.py

+33
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
from dvslib.dvs_common import wait_for_result
44

5+
L3_TABLE_TYPE = "L3"
6+
L3_TABLE_NAME = "L3_TEST"
7+
L3_BIND_PORTS = ["Ethernet0"]
8+
L3_RULE_NAME = "L3_TEST_RULE"
59

610
class TestNat(object):
711
def setup_db(self, dvs):
@@ -320,6 +324,35 @@ def _check_conntrack_for_static_entry():
320324
# delete a static nat entry
321325
dvs.runcmd("config nat remove static basic 67.66.65.1 18.18.18.2")
322326

327+
def test_DoNotNatAclAction(self, dvs_acl, testlog):
328+
329+
# Creating the ACL Table
330+
dvs_acl.create_acl_table(L3_TABLE_NAME, L3_TABLE_TYPE, L3_BIND_PORTS, stage="ingress")
331+
332+
acl_table_id = dvs_acl.get_acl_table_ids(1)[0]
333+
acl_table_group_ids = dvs_acl.get_acl_table_group_ids(len(L3_BIND_PORTS))
334+
335+
dvs_acl.verify_acl_table_group_members(acl_table_id, acl_table_group_ids, 1)
336+
dvs_acl.verify_acl_table_port_binding(acl_table_id, L3_BIND_PORTS, 1)
337+
338+
# Create a ACL Rule with "do_not_nat" packet action
339+
config_qualifiers = {"SRC_IP": "14.1.0.1/32"}
340+
dvs_acl.create_acl_rule(L3_TABLE_NAME, L3_RULE_NAME, config_qualifiers, action="DO_NOT_NAT", priority="97")
341+
342+
expected_sai_qualifiers = {
343+
"SAI_ACL_ENTRY_ATTR_FIELD_SRC_IP": dvs_acl.get_simple_qualifier_comparator("14.1.0.1&mask:255.255.255.255")
344+
}
345+
346+
dvs_acl.verify_nat_acl_rule(expected_sai_qualifiers, priority="97")
347+
348+
# Deleting the ACL Rule
349+
dvs_acl.remove_acl_rule(L3_TABLE_NAME, L3_RULE_NAME)
350+
dvs_acl.verify_no_acl_rules()
351+
352+
# Deleting the ACL Table
353+
dvs_acl.remove_acl_table(L3_TABLE_NAME)
354+
dvs_acl.verify_acl_table_count(0)
355+
323356

324357
# Add Dummy always-pass test at end as workaroud
325358
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)