forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine v4 and v6 L3 ACL rules on optimized platforms sonic-net#1267
Support a new ACL table type called L3V4V6. This table supports both v4 and v6 Match types. Add unit tests for this new ACL table type. HLD: sonic-net/SONiC#1267 Signed-off-by: Ravi(Marvell) [email protected]
- Loading branch information
1 parent
5c43ed0
commit e0a138a
Showing
4 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pytest | ||
from requests import request | ||
|
||
L3V4V6_TABLE_TYPE = "L3V4V6" | ||
L3V4V6_TABLE_NAME = "L3_V4V6_TEST" | ||
L3V4V6_BIND_PORTS = ["Ethernet0", "Ethernet4", "Ethernet8"] | ||
L3V4V6_RULE_NAME = "L3V4V6_TEST_RULE" | ||
|
||
class TestAcl: | ||
@pytest.fixture | ||
def l3v4v6_acl_table(self, dvs_acl): | ||
try: | ||
dvs_acl.create_acl_table(L3V4V6_TABLE_NAME, | ||
L3V4V6_TABLE_TYPE, | ||
L3V4V6_BIND_PORTS) | ||
yield dvs_acl.get_acl_table_ids(1)[0] | ||
finally: | ||
dvs_acl.remove_acl_table(L3V4V6_TABLE_NAME) | ||
dvs_acl.verify_acl_table_count(0) | ||
|
||
@pytest.fixture | ||
def setup_teardown_neighbor(self, dvs): | ||
try: | ||
# NOTE: set_interface_status has a dependency on cdb within dvs, | ||
# so we still need to setup the db. This should be refactored. | ||
dvs.setup_db() | ||
|
||
# Bring up an IP interface with a neighbor | ||
dvs.set_interface_status("Ethernet4", "up") | ||
dvs.add_ip_address("Ethernet4", "10.0.0.1/24") | ||
dvs.add_neighbor("Ethernet4", "10.0.0.2", "00:01:02:03:04:05") | ||
|
||
yield dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP", 1)[0] | ||
finally: | ||
# Clean up the IP interface and neighbor | ||
dvs.remove_neighbor("Ethernet4", "10.0.0.2") | ||
dvs.remove_ip_address("Ethernet4", "10.0.0.1/24") | ||
dvs.set_interface_status("Ethernet4", "down") | ||
|
||
def test_L3V4V6AclTableCreationDeletion(self, dvs_acl): | ||
try: | ||
# Create an L3V4V6 ACL table with default ACL actions | ||
dvs_acl.create_acl_table(L3V4V6_TABLE_NAME, L3V4V6_TABLE_TYPE, L3V4V6_BIND_PORTS) | ||
|
||
acl_table_id = dvs_acl.get_acl_table_ids(1)[0] | ||
acl_table_group_ids = dvs_acl.get_acl_table_group_ids(len(L3V4V6_BIND_PORTS)) | ||
|
||
dvs_acl.verify_acl_table_group_members(acl_table_id, acl_table_group_ids, 1) | ||
dvs_acl.verify_acl_table_port_binding(acl_table_id, L3V4V6_BIND_PORTS, 1) | ||
# Verify status is written into STATE_DB | ||
dvs_acl.verify_acl_table_status(L3V4V6_TABLE_NAME, "Active") | ||
finally: | ||
dvs_acl.remove_acl_table(L3V4V6_TABLE_NAME) | ||
dvs_acl.verify_acl_table_count(0) | ||
# Verify the STATE_DB entry is removed | ||
dvs_acl.verify_acl_table_status(L3V4V6_TABLE_NAME, None) | ||
|
||
|
||
# Add Dummy always-pass test at end as workaroud | ||
# for issue when Flaky fail on final test it invokes module tear-down before retrying | ||
def test_nonflaky_dummy(): | ||
pass |