Skip to content

Commit 9c70c88

Browse files
committed
"erspan_ip_ver" support for recycle port queue tests
Add missing session_type
1 parent 8612dc1 commit 9c70c88

2 files changed

Lines changed: 54 additions & 27 deletions

File tree

tests/everflow/everflow_test_utilities.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def load_acl_rules_config(table_name, rules_file):
593593

594594
def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_session, duthost, rx_port,
595595
tx_ports, direction, queue, asic_ns, recircle_port,
596-
expect_recv=True, valid_across_namespace=True):
596+
erspan_ip_ver, expect_recv=True, valid_across_namespace=True):
597597
tx_port_ids = self._get_tx_port_id_list(tx_ports)
598598
default_ip = self.DEFAULT_DST_IP
599599
router_mac = setup[direction]["ingress_router_mac"]
@@ -615,6 +615,7 @@ def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_sessi
615615
dest_ports=tx_port_ids,
616616
expect_recv=expect_recv,
617617
valid_across_namespace=valid_across_namespace,
618+
erspan_ip_ver=erspan_ip_ver
618619
)
619620

620621
# Assert the specific asic recircle port's queue
@@ -729,28 +730,54 @@ def policer_mirror_session(self, config_method, setup_info, erspan_ip_ver):
729730
self.remove_policer_config(duthost, policer, config_method)
730731

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

750776
elif config_method == CONFIG_MODE_CONFIGLET:
751777
pass
752778

753-
duthost.command(command)
779+
for command in commands_list:
780+
duthost.command(command)
754781

755782
@staticmethod
756783
def remove_mirror_config(duthost, session_name, config_method=CONFIG_MODE_CLI):
@@ -1214,6 +1241,7 @@ def mirror_session_info(session_name, asic_type):
12141241
session_dst_ipv6 = "2222::2:2:2:2"
12151242
session_dscp = "8"
12161243
session_ttl = "4"
1244+
session_type = "ERSPAN"
12171245

12181246
if "mellanox" == asic_type:
12191247
session_gre = 0x8949
@@ -1242,6 +1270,7 @@ def mirror_session_info(session_name, asic_type):
12421270
"session_dscp": session_dscp,
12431271
"session_ttl": session_ttl,
12441272
"session_gre": session_gre,
1273+
"session_type": session_type,
12451274
"session_prefixes": session_prefixes,
12461275
"session_prefixes_ipv6": session_prefixes_ipv6
12471276
}

tests/everflow/test_everflow_testbed.py

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

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

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

10401041
for duthost in duthost_set:
1041-
update_acl_rule_config(table_name, setup_mirror_session["session_name"], everflow_utils.CONFIG_MODE_CLI)
1042+
update_acl_rule_config(duthost, table_name, setup_mirror_session["session_name"],
1043+
everflow_utils.CONFIG_MODE_CLI)
10421044

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

10611056
queue = str(random.randint(1, 7))
10621057
# Apply mirror session config with a different queue value other than default '0'
1063-
configure_mirror_session_with_queue(setup_mirror_session, queue)
1058+
configure_mirror_session_with_queue(setup_mirror_session, queue, erspan_ip_ver)
10641059

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

10711068
time.sleep(15)
@@ -1095,7 +1092,8 @@ def configure_mirror_session_with_queue(mirror_session, queue_num):
10951092
dest_port_type,
10961093
queue,
10971094
asic_ns,
1098-
recircle_port
1095+
recircle_port,
1096+
erspan_ip_ver
10991097
)
11001098
finally:
11011099
remote_dut.shell(remote_dut.get_vtysh_cmd_for_namespace(

0 commit comments

Comments
 (0)