Skip to content

Commit ddb84fb

Browse files
authored
[aclorch] Enable IN_PORTS ACL qualifier on MIRROR tables (#1176)
Signed-off-by: Danny Allen <[email protected]>
1 parent 750982e commit ddb84fb

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed

orchagent/aclorch.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ bool AclTable::create()
13791379
* |------------------------------------------------------------------|
13801380
* | MARTCH_ETHERTYPE | √ | √ | |
13811381
* |------------------------------------------------------------------|
1382+
* | MATCH_IN_PORTS | √ | √ | |
1383+
* |------------------------------------------------------------------|
13821384
*/
13831385

13841386
if (type == ACL_TABLE_MIRROR)
@@ -1399,6 +1401,10 @@ bool AclTable::create()
13991401
attr.value.booldata = true;
14001402
table_attrs.push_back(attr);
14011403

1404+
attr.id = SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS;
1405+
attr.value.booldata = true;
1406+
table_attrs.push_back(attr);
1407+
14021408
// If the switch supports v6 and requires one single table
14031409
if (m_pAclOrch->m_mirrorTableCapabilities[ACL_TABLE_MIRRORV6] &&
14041410
m_pAclOrch->m_isCombinedMirrorV6Table)

tests/test_mirror_ipv6_combined.py

+73
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,79 @@ def remove_mirror_acl_rule(self, table, rule):
141141
tbl._del(table + "|" + rule)
142142
time.sleep(1)
143143

144+
def test_CombinedMirrorTableCreation(self, dvs, testlog):
145+
self.setup_db(dvs)
146+
147+
acl_table = "MIRROR_TABLE"
148+
ports = ["Ethernet0", "Ethernet4"]
149+
150+
# Create the table
151+
self.create_acl_table(acl_table, ports, "MIRROR")
152+
153+
# Check that the table has been created
154+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
155+
table_entries = [k for k in tbl.getKeys() if k not in dvs.asicdb.default_acl_tables]
156+
assert len(table_entries) == 1
157+
158+
# Get the data from the table
159+
table_id = table_entries[0]
160+
status, attributes = tbl.get(table_id)
161+
assert status
162+
163+
# TODO: Refactor mirror table tests so that these attributes can be shared between tests for v4, v6, and
164+
# dscp mirror tables.
165+
expected_sai_attributes = [
166+
"SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE",
167+
"SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL",
168+
"SAI_ACL_TABLE_ATTR_FIELD_SRC_IP",
169+
"SAI_ACL_TABLE_ATTR_FIELD_DST_IP",
170+
"SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE",
171+
"SAI_ACL_TABLE_ATTR_FIELD_ICMP_CODE",
172+
"SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT",
173+
"SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT",
174+
"SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS",
175+
"SAI_ACL_TABLE_ATTR_FIELD_DSCP",
176+
"SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE",
177+
"SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS",
178+
"SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6",
179+
"SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6",
180+
"SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE",
181+
"SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_CODE",
182+
]
183+
184+
expected_sai_list_attributes = [
185+
"SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE",
186+
"SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST"
187+
]
188+
189+
# Check that all of the V6 table attributes have been populated
190+
assert(len(attributes) == (len(expected_sai_attributes) + len(expected_sai_list_attributes) + 1))
191+
for attribute in attributes:
192+
key = attribute[0]
193+
value = attribute[1]
194+
195+
if key in expected_sai_attributes:
196+
assert value == "true"
197+
elif key in expected_sai_list_attributes:
198+
count = int(value[0:1])
199+
list_attrs = value[2:].split(',')
200+
if key == "SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE":
201+
assert set(list_attrs) == set(["SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE", "SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE"])
202+
elif key == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
203+
assert set(list_attrs) == set(["SAI_ACL_BIND_POINT_TYPE_PORT", "SAI_ACL_BIND_POINT_TYPE_LAG"])
204+
else:
205+
print("Encountered unexpected range attribute on mirror table: {}".format(key))
206+
assert False
207+
elif key == "SAI_ACL_TABLE_ATTR_ACL_STAGE":
208+
assert value == "SAI_ACL_STAGE_INGRESS"
209+
else:
210+
print("Encountered unexpected attribute on mirror table: {}".format(key))
211+
assert False
212+
213+
# Delete the table
214+
self.remove_acl_table(acl_table)
215+
216+
144217
# Test case - create a MIRROR table and a MIRRORV6 table in combined mode
145218
# 0. predefine the VS capability: combined
146219
# 1. create a mirror session

tests/test_mirror_ipv6_separate.py

+68
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,74 @@ def remove_mirror_acl_rule(self, table, rule):
135135
tbl._del(table + "|" + rule)
136136
time.sleep(1)
137137

138+
def test_MirrorTableCreation(self, dvs, testlog):
139+
self.setup_db(dvs)
140+
141+
acl_table = "MIRROR_TABLE"
142+
ports = ["Ethernet0", "Ethernet4"]
143+
144+
# Create the table
145+
self.create_acl_table(acl_table, ports, "MIRROR")
146+
147+
# Check that the table has been created
148+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
149+
table_entries = [k for k in tbl.getKeys() if k not in dvs.asicdb.default_acl_tables]
150+
assert len(table_entries) == 1
151+
152+
# Get the data from the table
153+
table_id = table_entries[0]
154+
status, attributes = tbl.get(table_id)
155+
assert status
156+
157+
# TODO: Refactor mirror table tests so that these attributes can be shared between tests for v4, v6, and
158+
# dscp mirror tables.
159+
expected_sai_attributes = [
160+
"SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE",
161+
"SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL",
162+
"SAI_ACL_TABLE_ATTR_FIELD_SRC_IP",
163+
"SAI_ACL_TABLE_ATTR_FIELD_DST_IP",
164+
"SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE",
165+
"SAI_ACL_TABLE_ATTR_FIELD_ICMP_CODE",
166+
"SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT",
167+
"SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT",
168+
"SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS",
169+
"SAI_ACL_TABLE_ATTR_FIELD_DSCP",
170+
"SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE",
171+
"SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS",
172+
]
173+
174+
expected_sai_list_attributes = [
175+
"SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE",
176+
"SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST"
177+
]
178+
179+
# Check that all of the V6 table attributes have been populated
180+
assert(len(attributes) == (len(expected_sai_attributes) + len(expected_sai_list_attributes) + 1))
181+
for attribute in attributes:
182+
key = attribute[0]
183+
value = attribute[1]
184+
185+
if key in expected_sai_attributes:
186+
assert value == "true"
187+
elif key in expected_sai_list_attributes:
188+
count = int(value[0:1])
189+
list_attrs = value[2:].split(',')
190+
if key == "SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE":
191+
assert set(list_attrs) == set(["SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE", "SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE"])
192+
elif key == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
193+
assert set(list_attrs) == set(["SAI_ACL_BIND_POINT_TYPE_PORT", "SAI_ACL_BIND_POINT_TYPE_LAG"])
194+
else:
195+
print("Encountered unexpected range attribute on mirror table: {}".format(key))
196+
assert False
197+
elif key == "SAI_ACL_TABLE_ATTR_ACL_STAGE":
198+
assert value == "SAI_ACL_STAGE_INGRESS"
199+
else:
200+
print("Encountered unexpected attribute on mirror table: {}".format(key))
201+
assert False
202+
203+
# Delete the table
204+
self.remove_acl_table(acl_table)
205+
138206
def test_MirrorV6TableCreation(self, dvs, testlog):
139207
self.setup_db(dvs)
140208

0 commit comments

Comments
 (0)