Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions tests/everflow/everflow_test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def load_acl_rules_config(table_name, rules_file):

def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_session, duthost, rx_port,
tx_ports, direction, queue, asic_ns, recircle_port,
expect_recv=True, valid_across_namespace=True):
erspan_ip_ver, expect_recv=True, valid_across_namespace=True):
tx_port_ids = self._get_tx_port_id_list(tx_ports)
default_ip = self.DEFAULT_DST_IP
router_mac = setup[direction]["ingress_router_mac"]
Expand All @@ -617,6 +617,7 @@ def verify_mirror_packets_on_recircle_port(self, ptfadapter, setup, mirror_sessi
dest_ports=tx_port_ids,
expect_recv=expect_recv,
valid_across_namespace=valid_across_namespace,
erspan_ip_ver=erspan_ip_ver
)

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

@staticmethod
def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, policer=None, erspan_ip_ver=4):
def apply_mirror_config(duthost, session_info, config_method=CONFIG_MODE_CLI, policer=None,
erspan_ip_ver=4, queue_num=None):
commands_list = list()
if config_method == CONFIG_MODE_CLI:
if erspan_ip_ver == 4:
command = f"config mirror_session add {session_info['session_name']} \
{session_info['session_src_ip']} {session_info['session_dst_ip']} \
{session_info['session_dscp']} {session_info['session_ttl']} \
{session_info['session_gre']}"
if queue_num:
command += f" {queue_num}"
if policer:
command += f" --policer {policer}"
commands_list.append(command)
else:
# Adding IPv6 ERSPAN sessions from the CLI is currently not supported.
command = f"sonic-db-cli CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' \
'dscp' '{session_info['session_dscp']}' 'dst_ip' '{session_info['session_dst_ipv6']}' \
'gre_type' '{session_info['session_gre']}' 'src_ip' '{session_info['session_src_ipv6']}' \
'ttl' '{session_info['session_ttl']}'"
if policer:
command += f" 'policer' {policer}"
for asic_index in duthost.get_frontend_asic_ids():
# Adding IPv6 ERSPAN sessions for each asic, from the CLI is currently not supported.
if asic_index is not None:
command = f"sonic-db-cli -n asic{asic_index} "
else:
command = "sonic-db-cli "
command += (
f"CONFIG_DB HSET 'MIRROR_SESSION|{session_info['session_name']}' "
f"'dscp' '{session_info['session_dscp']}' "
f"'dst_ip' '{session_info['session_dst_ipv6']}' "
f"'gre_type' '{session_info['session_gre']}' "
f"'type' '{session_info['session_type']}' "
f"'src_ip' '{session_info['session_src_ipv6']}' "
f"'ttl' '{session_info['session_ttl']}'"
)
if queue_num:
command += f" 'queue' {queue_num}"
if policer:
command += f" 'policer' {policer}"
commands_list.append(command)

elif config_method == CONFIG_MODE_CONFIGLET:
pass

duthost.command(command)
for command in commands_list:
duthost.command(command)

@staticmethod
def remove_mirror_config(duthost, session_name, config_method=CONFIG_MODE_CLI):
Expand Down Expand Up @@ -1278,6 +1298,7 @@ def mirror_session_info(session_name, asic_type):
session_dst_ipv6 = "2222::2:2:2:2"
session_dscp = "8"
session_ttl = "4"
session_type = "ERSPAN"

if "mellanox" == asic_type:
session_gre = 0x8949
Expand Down Expand Up @@ -1306,6 +1327,7 @@ def mirror_session_info(session_name, asic_type):
"session_dscp": session_dscp,
"session_ttl": session_ttl,
"session_gre": session_gre,
"session_type": session_type,
"session_prefixes": session_prefixes,
"session_prefixes_ipv6": session_prefixes_ipv6
}
Expand Down
32 changes: 15 additions & 17 deletions tests/everflow/test_everflow_testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ def background_traffic(run_count=None):

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

def update_acl_rule_config(table_name, session_name, config_method, rules=everflow_utils.EVERFLOW_V4_RULES):
def update_acl_rule_config(duthost, table_name, session_name, config_method,
rules=everflow_utils.EVERFLOW_V4_RULES):
rules_config = everflow_utils.load_acl_rules_config(table_name,
os.path.join(everflow_utils.FILE_DIR, rules))
rules_config['rules'] = [
Expand Down Expand Up @@ -1038,34 +1039,30 @@ def update_acl_rule_config(table_name, session_name, config_method, rules=everfl
BaseEverflowTest.remove_acl_rule_config(duthost, table_name, everflow_utils.CONFIG_MODE_CLI)

for duthost in duthost_set:
update_acl_rule_config(table_name, setup_mirror_session["session_name"], everflow_utils.CONFIG_MODE_CLI)
update_acl_rule_config(duthost, table_name, setup_mirror_session["session_name"],
everflow_utils.CONFIG_MODE_CLI)

def configure_mirror_session_with_queue(mirror_session, queue_num):
def configure_mirror_session_with_queue(mirror_session, queue_num, erspan_ip_ver):
if mirror_session["session_name"]:
remove_command = "config mirror_session remove {}".format(mirror_session["session_name"])
for duthost in duthost_set:
duthost.command(remove_command)
add_command = "config mirror_session add {} {} {} {} {} {} {}" \
.format(mirror_session["session_name"],
mirror_session["session_src_ip"],
mirror_session["session_dst_ip"],
mirror_session["session_dscp"],
mirror_session["session_ttl"],
mirror_session["session_gre"],
queue_num)
for duthost in duthost_set:
duthost.command(add_command)
BaseEverflowTest.apply_mirror_config(duthost, setup_mirror_session, erspan_ip_ver=erspan_ip_ver,
queue_num=queue_num)
else:
pytest.skip("Mirror session info is empty, can't proceed further!")

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

# Add a route to the mirror session destination IP
tx_port = setup_info[dest_port_type]["dest_port"][0]
peer_ip = everflow_utils.get_neighbor_info(remote_dut, tx_port, tbinfo)
everflow_utils.add_route(remote_dut, setup_mirror_session["session_prefixes"][0], peer_ip,
peer_ip = everflow_utils.get_neighbor_info(remote_dut, tx_port, tbinfo, ip_version=erspan_ip_ver)
session_prefixes = setup_mirror_session["session_prefixes"] if erspan_ip_ver == 4 \
else setup_mirror_session["session_prefixes_ipv6"]
everflow_utils.add_route(remote_dut, session_prefixes[0], peer_ip,
setup_info[dest_port_type]["remote_namespace"])

time.sleep(15)
Expand Down Expand Up @@ -1095,7 +1092,8 @@ def configure_mirror_session_with_queue(mirror_session, queue_num):
dest_port_type,
queue,
asic_ns,
recircle_port
recircle_port,
erspan_ip_ver
)
finally:
remote_dut.shell(remote_dut.get_vtysh_cmd_for_namespace(
Expand Down
Loading