@@ -608,13 +608,33 @@ def get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_a
608608 dest_address = mux_cfg_dict .get (name , None )
609609
610610 if dest_address is not None :
611+ # Check kernel tunnel route
611612 kernel_route_keys = per_npu_appl_db [asic_id ].keys (
612613 per_npu_appl_db [asic_id ].APPL_DB , 'TUNNEL_ROUTE_TABLE:*{}' .format (dest_address ))
613614 if_kernel_tunnel_route_programed = kernel_route_keys is not None and len (kernel_route_keys )
614615
616+ # Mux neighbors use prefix based routes
617+ # Check ASIC route with nexthop type verification
615618 asic_route_keys = per_npu_asic_db [asic_id ].keys (
616619 per_npu_asic_db [asic_id ].ASIC_DB , 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:*{}*' .format (dest_address ))
617- if_asic_tunnel_route_programed = asic_route_keys is not None and len (asic_route_keys )
620+
621+ if_asic_tunnel_route_programed = False
622+ if asic_route_keys is not None and len (asic_route_keys ):
623+ # Get the route entry to check nexthop type
624+ for route_key in asic_route_keys :
625+ route_data = per_npu_asic_db [asic_id ].get_all (per_npu_asic_db [asic_id ].ASIC_DB , route_key )
626+ nexthop_id = route_data .get ('SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID' , None )
627+
628+ if nexthop_id :
629+ # Check nexthop type
630+ nexthop_key = 'ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:{}' .format (nexthop_id )
631+ nexthop_data = per_npu_asic_db [asic_id ].get_all (per_npu_asic_db [asic_id ].ASIC_DB , nexthop_key )
632+ nexthop_type = nexthop_data .get ('SAI_NEXT_HOP_ATTR_TYPE' , None )
633+
634+ # Only count as tunnel route if nexthop type is tunnel
635+ if nexthop_type == 'SAI_NEXT_HOP_TYPE_TUNNEL_ENCAP' :
636+ if_asic_tunnel_route_programed = True
637+ break
618638
619639 if if_kernel_tunnel_route_programed or if_asic_tunnel_route_programed :
620640 port_tunnel_route ["TUNNEL_ROUTE" ][port ] = port_tunnel_route ["TUNNEL_ROUTE" ].get (port , {})
0 commit comments