@@ -593,7 +593,7 @@ def load_acl_rules_config(table_name, rules_file):
593593
594594def 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 }
0 commit comments