Skip to content

Commit 9b19e8e

Browse files
sanjair-gitabhishek-nexthop
authored andcommitted
[T2] Everflow - "erspan_ip_ver" support for the new recycle port queue tests (sonic-net#19594)
This PR adds erspan-ip-ver support to the newly added 'test_everflow_fwd_recircle_port_queue_check' It adds 'erspan_ip_ver' to the mirror session configuration for the respective test. Signed-off-by: Abhishek <[email protected]>
1 parent 950d216 commit 9b19e8e

2 files changed

Lines changed: 47 additions & 27 deletions

File tree

tests/everflow/everflow_test_utilities.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def load_acl_rules_config(table_name, rules_file):
595595

596596
def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_session, duthost, rx_port,
597597
tx_ports, direction, queue, asic_ns, recircle_port,
598-
expect_recv=True, valid_across_namespace=True):
598+
erspan_ip_ver, expect_recv=True, valid_across_namespace=True):
599599
tx_port_ids = self._get_tx_port_id_list(tx_ports)
600600
default_ip = self.DEFAULT_DST_IP
601601
router_mac = setup[direction]["ingress_router_mac"]
@@ -617,6 +617,7 @@ def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_sessi
617617
dest_ports=tx_port_ids,
618618
expect_recv=expect_recv,
619619
valid_across_namespace=valid_across_namespace,
620+
erspan_ip_ver=erspan_ip_ver
620621
)
621622

622623
# Assert the specific asic recircle port's queue
@@ -731,28 +732,47 @@ def policer_mirror_session(self, config_method, setup_info, erspan_ip_ver):
731732
self.remove_policer_config(duthost, policer, config_method)
732733

733734
@staticmethod
734-
def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, policer=None, erspan_ip_ver=4):
735+
def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, policer=None,
736+
erspan_ip_ver=4, queue_num=None):
737+
commands_list = list()
735738
if config_method == CONFIG_MODE_CLI:
736739
if erspan_ip_ver == 4:
737740
command = f"config mirror_session add {session_info['session_name']} \
738741
{session_info['session_src_ip']} {session_info['session_dst_ip']} \
739742
{session_info['session_dscp']} {session_info['session_ttl']} \
740743
{session_info['session_gre']}"
744+
if queue_num:
745+
command += f" {queue_num}"
741746
if policer:
742747
command += f" --policer {policer}"
748+
commands_list.append(command)
743749
else:
744-
# Adding IPv6 ERSPAN sessions from the CLI is currently not supported.
745-
command = f"sonic-db-cli CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' \
746-
'dscp' '{session_info['session_dscp']}' 'dst_ip' '{session_info['session_dst_ipv6']}' \
747-
'gre_type' '{session_info['session_gre']}' 'src_ip' '{session_info['session_src_ipv6']}' \
748-
'ttl' '{session_info['session_ttl']}'"
749-
if policer:
750-
command += f" 'policer' {policer}"
750+
for asic_index in duthost.get_frontend_asic_ids():
751+
# Adding IPv6 ERSPAN sessions for each asic, from the CLI is currently not supported.
752+
if asic_index is not None:
753+
command = f"sonic-db-cli -n asic{asic_index} "
754+
else:
755+
command = "sonic-db-cli "
756+
command += (
757+
f"CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' "
758+
f"'dscp' '{session_info['session_dscp']}' "
759+
f"'dst_ip' '{session_info['session_dst_ipv6']}' "
760+
f"'gre_type' '{session_info['session_gre']}' "
761+
f"'type' '{session_info['session_type']}' "
762+
f"'src_ip' '{session_info['session_src_ipv6']}' "
763+
f"'ttl' '{session_info['session_ttl']}'"
764+
)
765+
if queue_num:
766+
command += f" 'queue' {queue_num}"
767+
if policer:
768+
command += f" 'policer' {policer}"
769+
commands_list.append(command)
751770

752771
elif config_method == CONFIG_MODE_CONFIGLET:
753772
pass
754773

755-
duthost.command(command)
774+
for command in commands_list:
775+
duthost.command(command)
756776

757777
@staticmethod
758778
def remove_mirror_config(duthost, session_name, config_method=CONFIG_MODE_CLI):
@@ -1278,6 +1298,7 @@ def mirror_session_info(session_name, asic_type):
12781298
session_dst_ipv6 = "2222::2:2:2:2"
12791299
session_dscp = "8"
12801300
session_ttl = "4"
1301+
session_type = "ERSPAN"
12811302

12821303
if "mellanox" == asic_type:
12831304
session_gre = 0x8949
@@ -1306,6 +1327,7 @@ def mirror_session_info(session_name, asic_type):
13061327
"session_dscp": session_dscp,
13071328
"session_ttl": session_ttl,
13081329
"session_gre": session_gre,
1330+
"session_type": session_type,
13091331
"session_prefixes": session_prefixes,
13101332
"session_prefixes_ipv6": session_prefixes_ipv6
13111333
}

tests/everflow/test_everflow_testbed.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ def background_traffic(run_count=None):
989989

990990
def test_everflow_fwd_recircle_port_queue_check(self, setup_info, setup_mirror_session, # noqa F811
991991
dest_port_type, ptfadapter, tbinfo,
992-
toggle_all_simulator_ports_to_rand_selected_tor, # noqa F811
992+
erspan_ip_ver, toggle_all_simulator_ports_to_rand_selected_tor, # noqa F811
993993
setup_standby_ports_on_rand_unselected_tor_unconditionally): # noqa F811
994994
"""
995995
Verify basic forwarding scenario with mirror session config having specific queue for the Everflow feature.
@@ -1002,7 +1002,8 @@ def test_everflow_fwd_recircle_port_queue_check(self, setup_info, setup_mirror_s
10021002
"vtysh -c \"configure terminal\" -c \"no ip nht resolve-via-default\"",
10031003
setup_info[dest_port_type]["remote_namespace"]))
10041004

1005-
def update_acl_rule_config(table_name, session_name, config_method, rules=everflow_utils.EVERFLOW_V4_RULES):
1005+
def update_acl_rule_config(duthost, table_name, session_name, config_method,
1006+
rules=everflow_utils.EVERFLOW_V4_RULES):
10061007
rules_config = everflow_utils.load_acl_rules_config(table_name,
10071008
os.path.join(everflow_utils.FILE_DIR, rules))
10081009
rules_config['rules'] = [
@@ -1039,34 +1040,30 @@ def update_acl_rule_config(table_name, session_name, config_method, rules=everfl
10391040
BaseEverflowTest.remove_acl_rule_config(duthost, table_name, everflow_utils.CONFIG_MODE_CLI)
10401041

10411042
for duthost in duthost_set:
1042-
update_acl_rule_config(table_name, setup_mirror_session["session_name"], everflow_utils.CONFIG_MODE_CLI)
1043+
update_acl_rule_config(duthost, table_name, setup_mirror_session["session_name"],
1044+
everflow_utils.CONFIG_MODE_CLI)
10431045

1044-
def configure_mirror_session_with_queue(mirror_session, queue_num):
1046+
def configure_mirror_session_with_queue(mirror_session, queue_num, erspan_ip_ver):
10451047
if mirror_session["session_name"]:
10461048
remove_command = "config mirror_session remove {}".format(mirror_session["session_name"])
10471049
for duthost in duthost_set:
10481050
duthost.command(remove_command)
1049-
add_command = "config mirror_session add {} {} {} {} {} {} {}" \
1050-
.format(mirror_session["session_name"],
1051-
mirror_session["session_src_ip"],
1052-
mirror_session["session_dst_ip"],
1053-
mirror_session["session_dscp"],
1054-
mirror_session["session_ttl"],
1055-
mirror_session["session_gre"],
1056-
queue_num)
10571051
for duthost in duthost_set:
1058-
duthost.command(add_command)
1052+
BaseEverflowTest.apply_mirror_config(duthost, setup_mirror_session, erspan_ip_ver=erspan_ip_ver,
1053+
queue_num=queue_num)
10591054
else:
10601055
pytest.skip("Mirror session info is empty, can't proceed further!")
10611056

10621057
queue = str(random.randint(1, 7))
10631058
# Apply mirror session config with a different queue value other than default '0'
1064-
configure_mirror_session_with_queue(setup_mirror_session, queue)
1059+
configure_mirror_session_with_queue(setup_mirror_session, queue, erspan_ip_ver)
10651060

10661061
# Add a route to the mirror session destination IP
10671062
tx_port = setup_info[dest_port_type]["dest_port"][0]
1068-
peer_ip = everflow_utils.get_neighbor_info(remote_dut, tx_port, tbinfo)
1069-
everflow_utils.add_route(remote_dut, setup_mirror_session["session_prefixes"][0], peer_ip,
1063+
peer_ip = everflow_utils.get_neighbor_info(remote_dut, tx_port, tbinfo, ip_version=erspan_ip_ver)
1064+
session_prefixes = setup_mirror_session["session_prefixes"] if erspan_ip_ver == 4 \
1065+
else setup_mirror_session["session_prefixes_ipv6"]
1066+
everflow_utils.add_route(remote_dut, session_prefixes[0], peer_ip,
10701067
setup_info[dest_port_type]["remote_namespace"])
10711068

10721069
time.sleep(15)
@@ -1096,7 +1093,8 @@ def configure_mirror_session_with_queue(mirror_session, queue_num):
10961093
dest_port_type,
10971094
queue,
10981095
asic_ns,
1099-
recircle_port
1096+
recircle_port,
1097+
erspan_ip_ver
11001098
)
11011099
finally:
11021100
remote_dut.shell(remote_dut.get_vtysh_cmd_for_namespace(

0 commit comments

Comments
 (0)