diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index b12644efd213..b25d18a44c82 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -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; diff --git a/tests/test_mirror_ipv6_separate.py b/tests/test_mirror_ipv6_separate.py index 8b12d0fbecdd..06f64e86911d 100644 --- a/tests/test_mirror_ipv6_separate.py +++ b/tests/test_mirror_ipv6_separate.py @@ -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