Skip to content

Commit

Permalink
[aclorch] Enable DSCP rules on IPv6 mirror tables (sonic-net#1146)
Browse files Browse the repository at this point in the history
- Enable DSCP field for MIRRORV6 tables
- Add vs test for MIRRORV6 table initialization

Signed-off-by: Danny Allen <[email protected]>
  • Loading branch information
daall authored and yxieca committed Dec 13, 2019
1 parent b8745f8 commit 823e426
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ bool AclTable::create()
attr.value.s32 = acl_stage;
table_attrs.push_back(attr);

if (type == ACL_TABLE_MIRROR)
if (type == ACL_TABLE_MIRROR || type == ACL_TABLE_MIRRORV6)
{
attr.id = SAI_ACL_TABLE_ATTR_FIELD_DSCP;
attr.value.booldata = true;
Expand Down
64 changes: 64 additions & 0 deletions tests/test_mirror_ipv6_separate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,70 @@ def remove_mirror_acl_rule(self, table, rule):
tbl._del(table + "|" + rule)
time.sleep(1)

def test_MirrorV6TableCreation(self, dvs, testlog):
self.setup_db(dvs)

acl_table_v6 = "MIRROR_TABLE_V6"
ports = ["Ethernet0", "Ethernet4"]

# Create the V6 table
self.create_acl_table(acl_table_v6, ports, "MIRRORV6")

# Check that the V6 table has been created
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
table_entries = [k for k in tbl.getKeys() if k not in dvs.asicdb.default_acl_tables]
assert len(table_entries) == 1

# Get the data from the V6 table
v6_table_id = table_entries[0]
status, attributes = tbl.get(v6_table_id)
assert status

# TODO: Refactor mirror table tests so that these attributes can be shared between tests for v4, v6, and
# dscp mirror tables.
expected_sai_attributes = [
"SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE",
"SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL",
"SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6",
"SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6",
"SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE",
"SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_CODE",
"SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT",
"SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT",
"SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS",
"SAI_ACL_TABLE_ATTR_FIELD_DSCP",
]

expected_sai_list_attributes = [
"SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE",
"SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST"
]

# Check that all of the V6 table attributes have been populated
for attribute in attributes:
key = attribute[0]
value = attribute[1]

if key in expected_sai_attributes:
assert value == "true"
elif key in expected_sai_list_attributes:
count = int(value[0:1])
list_attrs = value[2:].split(',')
if key == "SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE":
assert set(list_attrs) == set(["SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE", "SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE"])
elif key == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
assert set(list_attrs) == set(["SAI_ACL_BIND_POINT_TYPE_PORT", "SAI_ACL_BIND_POINT_TYPE_LAG"])
else:
print("Encountered unexpected range attribute on mirror table: {}".format(key))
assert False
elif key == "SAI_ACL_TABLE_ATTR_ACL_STAGE":
assert value == "SAI_ACL_STAGE_INGRESS"
else:
print("Encountered unexpected attribute on mirror table: {}".format(key))
assert False

# Delete the V6 table
self.remove_acl_table(acl_table_v6)

# Test case - create a MIRROR table and a MIRRORV6 table in separated mode
# 0. predefine the VS platform: mellanox platform
Expand Down

0 comments on commit 823e426

Please sign in to comment.