Skip to content

Commit 50df9ea

Browse files
authored
Adapt 'show muxcable tunnel-route' for prefix route based mux neighbors (sonic-net#4007)
What I did Mux neighbors now use prefix-based routes based on changes from the following PR: sonic-net/sonic-swss#3722 Presence of route prefix for neighbors does not mean tunnel-route use anymore. Show command now uses nexthop type to distinguish between tunnel and normal neighbor route. How to verify it Verified output on hardware. Signed-off-by: Manas Kumar Mandal <[email protected]>
1 parent 868189c commit 50df9ea

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

show/muxcable.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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, {})

tests/mock_tables/asic_db.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
"oid:0xd00000000056d": "oid:0xd",
2121
"oid:0x10000000004a4": "oid:0x1690000000001"
2222
},
23+
"ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:oid:0x40000000015d8": {
24+
"SAI_NEXT_HOP_ATTR_TYPE": "SAI_NEXT_HOP_TYPE_TUNNEL_ENCAP",
25+
"SAI_NEXT_HOP_ATTR_TUNNEL_ID": "oid:0x2a000000000520"
26+
},
27+
"ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:oid:0x40000000006b3": {
28+
"SAI_NEXT_HOP_ATTR_TYPE": "SAI_NEXT_HOP_TYPE_IP",
29+
"SAI_NEXT_HOP_ATTR_IP": "10.3.1.1",
30+
"SAI_NEXT_HOP_ATTR_ROUTER_INTERFACE_ID": "oid:0x6000000000501"
31+
},
32+
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"10.3.1.1\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
33+
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
34+
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000006b3"
35+
},
2336
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"10.2.1.1\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
2437
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
2538
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000015d8"

tests/muxcable_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
"server_ipv4": {
570570
"DEST": "10.2.1.1",
571571
"kernel": 1,
572-
"asic": 1
572+
"asic": true
573573
}
574574
},
575575
"Ethernet4": {
@@ -583,7 +583,7 @@
583583
"soc_ipv6": {
584584
"DEST": "fc00::76",
585585
"kernel": false,
586-
"asic": 1
586+
"asic": true
587587
}
588588
}
589589
}
@@ -605,7 +605,7 @@
605605
"server_ipv4": {
606606
"DEST": "10.2.1.1",
607607
"kernel": 1,
608-
"asic": 1
608+
"asic": true
609609
}
610610
}
611611
}

0 commit comments

Comments
 (0)