Skip to content

Commit 9863067

Browse files
committed
Multi-asic support for everflow IPV6 mirror-session config
1 parent e1d168d commit 9863067

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

tests/everflow/everflow_test_utilities.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ def policer_mirror_session(self, config_method, setup_info, erspan_ip_ver):
580580

581581
@staticmethod
582582
def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, policer=None, erspan_ip_ver=4):
583+
commands_list = list()
583584
if config_method == CONFIG_MODE_CLI:
584585
if erspan_ip_ver == 4:
585586
command = f"config mirror_session add {session_info['session_name']} \
@@ -588,19 +589,34 @@ def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, po
588589
{session_info['session_gre']}"
589590
if policer:
590591
command += f" --policer {policer}"
592+
commands_list.append(command)
591593
else:
592-
# Adding IPv6 ERSPAN sessions from the CLI is currently not supported.
593-
command = f"sonic-db-cli CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' \
594-
'dscp' '{session_info['session_dscp']}' 'dst_ip' '{session_info['session_dst_ipv6']}' \
595-
'gre_type' '{session_info['session_gre']}' 'src_ip' '{session_info['session_src_ipv6']}' \
596-
'ttl' '{session_info['session_ttl']}'"
597-
if policer:
598-
command += f" 'policer' {policer}"
594+
for asic_index in duthost.get_frontend_asic_ids():
595+
if asic_index is not None:
596+
# Adding IPv6 ERSPAN sessions for each asic, from the CLI is currently not supported.
597+
command = f"sonic-db-cli -n asic{asic_index} CONFIG_DB HSET " \
598+
f"'MIRROR_SESSION|{session_info['session_name']}' " \
599+
f"'dscp' '{session_info['session_dscp']}' " \
600+
f"'dst_ip' '{session_info['session_dst_ipv6']}' " \
601+
f"'gre_type' '{session_info['session_gre']}' " \
602+
f"'type' '{session_info['session_type']}' " \
603+
f"'src_ip' '{session_info['session_src_ipv6']}' 'ttl' '{session_info['session_ttl']}'"
604+
commands_list.append(command)
605+
else:
606+
# Adding IPv6 ERSPAN sessions, from the CLI is currently not supported.
607+
command = f"sonic-db-cli CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' \
608+
'dscp' '{session_info['session_dscp']}' 'dst_ip' '{session_info['session_dst_ipv6']}' \
609+
'gre_type' '{session_info['session_gre']}' 'src_ip' '{session_info['session_src_ipv6']}' \
610+
'ttl' '{session_info['session_ttl']}'"
611+
commands_list.append(command)
599612

600613
elif config_method == CONFIG_MODE_CONFIGLET:
601614
pass
602615

603-
duthost.command(command)
616+
for command in commands_list:
617+
if policer:
618+
command += f" 'policer' {policer}"
619+
duthost.command(command)
604620

605621
@staticmethod
606622
def remove_mirror_config(duthost, session_name, config_method=CONFIG_MODE_CLI):
@@ -992,6 +1008,7 @@ def mirror_session_info(session_name, asic_type):
9921008
session_dst_ipv6 = "2222::2:2:2:2"
9931009
session_dscp = "8"
9941010
session_ttl = "4"
1011+
session_type = "ERSPAN"
9951012

9961013
if "mellanox" == asic_type:
9971014
session_gre = 0x8949
@@ -1020,6 +1037,7 @@ def mirror_session_info(session_name, asic_type):
10201037
"session_dscp": session_dscp,
10211038
"session_ttl": session_ttl,
10221039
"session_gre": session_gre,
1040+
"session_type": session_type,
10231041
"session_prefixes": session_prefixes,
10241042
"session_prefixes_ipv6": session_prefixes_ipv6
10251043
}

0 commit comments

Comments
 (0)