@@ -43,8 +43,10 @@ def dpu_setup_vnet(duthost, dpuhosts, dpu_index, skip_config):
4343 dpu_cmds .append ("config loopback add Loopback0" )
4444 dpu_cmds .append (f"config int ip add Loopback0 { APPLIANCE_VIP } /32" )
4545
46- dpu_cmds .append (f"ip route replace default via { dpuhost .npu_data_port_ip } " )
47- dpuhost .shell_cmds (cmds = dpu_cmds )
46+ if dpuhost .npu_data_port_ip :
47+ dpu_cmds .append (f"ip route replace default via { dpuhost .npu_data_port_ip } " )
48+ if len (dpu_cmds ) > 0 :
49+ dpuhost .shell_cmds (cmds = dpu_cmds )
4850
4951
5052@pytest .fixture (scope = "module" , autouse = True )
@@ -54,7 +56,8 @@ def add_npu_static_routes_vnet(duthost, dash_smartswitch_vnet_config, skip_confi
5456 cmds = []
5557 pe_nexthop_ip = get_interface_ip (duthost , dash_smartswitch_vnet_config [REMOTE_DUT_INTF ]).ip + 1
5658 cmds .append (f"ip route replace { dash_smartswitch_vnet_config [REMOTE_PA_IP ]} /32 via { pe_nexthop_ip } " )
57- cmds .append (f"ip route replace { APPLIANCE_VIP } /32 via { dpuhost .dpu_data_port_ip } " )
59+ if dpuhost .dpu_data_port_ip :
60+ cmds .append (f"ip route replace { APPLIANCE_VIP } /32 via { dpuhost .dpu_data_port_ip } " )
5861 logger .info (f"Adding static routes: { cmds } " )
5962 duthost .shell_cmds (cmds = cmds )
6063
@@ -63,7 +66,8 @@ def add_npu_static_routes_vnet(duthost, dash_smartswitch_vnet_config, skip_confi
6366 if not skip_config and not skip_cleanup :
6467 dpuhost = dpuhosts [dpu_index ]
6568 cmds = []
66- cmds .append (f"ip route del { dash_smartswitch_vnet_config [REMOTE_PA_IP ]} /32 via { pe_nexthop_ip } " )
69+ if dpuhost .dpu_data_port_ip :
70+ cmds .append (f"ip route del { dash_smartswitch_vnet_config [REMOTE_PA_IP ]} /32 via { pe_nexthop_ip } " )
6771 cmds .append (f"ip route del { APPLIANCE_VIP } /32 via { dpuhost .dpu_data_port_ip } " )
6872 logger .info (f"Removing static routes: { cmds } " )
6973 duthost .shell_cmds (cmds = cmds )
0 commit comments