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
22 changes: 21 additions & 1 deletion show/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,33 @@ def get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_a
dest_address = mux_cfg_dict.get(name, None)

if dest_address is not None:
# Check kernel tunnel route
kernel_route_keys = per_npu_appl_db[asic_id].keys(
per_npu_appl_db[asic_id].APPL_DB, 'TUNNEL_ROUTE_TABLE:*{}'.format(dest_address))
if_kernel_tunnel_route_programed = kernel_route_keys is not None and len(kernel_route_keys)

# Mux neighbors use prefix based routes
# Check ASIC route with nexthop type verification
asic_route_keys = per_npu_asic_db[asic_id].keys(
per_npu_asic_db[asic_id].ASIC_DB, 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:*{}*'.format(dest_address))
if_asic_tunnel_route_programed = asic_route_keys is not None and len(asic_route_keys)

if_asic_tunnel_route_programed = False
if asic_route_keys is not None and len(asic_route_keys):
# Get the route entry to check nexthop type
for route_key in asic_route_keys:
route_data = per_npu_asic_db[asic_id].get_all(per_npu_asic_db[asic_id].ASIC_DB, route_key)
nexthop_id = route_data.get('SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID', None)

if nexthop_id:
# Check nexthop type
nexthop_key = 'ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:{}'.format(nexthop_id)
nexthop_data = per_npu_asic_db[asic_id].get_all(per_npu_asic_db[asic_id].ASIC_DB, nexthop_key)
nexthop_type = nexthop_data.get('SAI_NEXT_HOP_ATTR_TYPE', None)

# Only count as tunnel route if nexthop type is tunnel
if nexthop_type == 'SAI_NEXT_HOP_TYPE_TUNNEL_ENCAP':
if_asic_tunnel_route_programed = True
break

if if_kernel_tunnel_route_programed or if_asic_tunnel_route_programed:
port_tunnel_route["TUNNEL_ROUTE"][port] = port_tunnel_route["TUNNEL_ROUTE"].get(port, {})
Expand Down
13 changes: 13 additions & 0 deletions tests/mock_tables/asic_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
"oid:0xd00000000056d": "oid:0xd",
"oid:0x10000000004a4": "oid:0x1690000000001"
},
"ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:oid:0x40000000015d8": {
"SAI_NEXT_HOP_ATTR_TYPE": "SAI_NEXT_HOP_TYPE_TUNNEL_ENCAP",
"SAI_NEXT_HOP_ATTR_TUNNEL_ID": "oid:0x2a000000000520"
},
"ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:oid:0x40000000006b3": {
"SAI_NEXT_HOP_ATTR_TYPE": "SAI_NEXT_HOP_TYPE_IP",
"SAI_NEXT_HOP_ATTR_IP": "10.3.1.1",
"SAI_NEXT_HOP_ATTR_ROUTER_INTERFACE_ID": "oid:0x6000000000501"
},
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"10.3.1.1\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000006b3"
},
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"10.2.1.1\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000015d8"
Expand Down
6 changes: 3 additions & 3 deletions tests/muxcable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@
"server_ipv4": {
"DEST": "10.2.1.1",
"kernel": 1,
"asic": 1
"asic": true
}
},
"Ethernet4": {
Expand All @@ -583,7 +583,7 @@
"soc_ipv6": {
"DEST": "fc00::76",
"kernel": false,
"asic": 1
"asic": true
}
}
}
Expand All @@ -605,7 +605,7 @@
"server_ipv4": {
"DEST": "10.2.1.1",
"kernel": 1,
"asic": 1
"asic": true
}
}
}
Expand Down
Loading