bgpd: support brief json for bgp v4 and v6 neighbors route - #21414
Conversation
Greptile SummaryThis PR adds
Confidence Score: 5/5This PR is safe to merge; the new brief-JSON path is self-contained and the previously reported flap-statistics/dampened-routes null-dereference is guarded by a runtime sh_type check. The core change correctly threads brief through the call chain, the DEFUNβDEFPY conversion removes the now-redundant use_json() call while preserving the established argc-- pattern, and the bgp_fib_flags_info comma/fibInstallFailed fixes resolve real raw-JSON malformation. The four new topotests cover both address families in both full and brief modes, and the topology config additions are consistent. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User (vtysh)
participant D as DEFPY handler show_ip_bgp_neighbor_routes
participant N as bgp_show_neighbor_route
participant S as bgp_show / bgp_show_table
participant F as bgp_fib_flags_info
U->>D: show bgp vrf RED ipv4 unicast neighbors X routes json brief
D->>D: "uj=true, brief=true, argc--"
D->>D: "argv_find routes -> sh_type=bgp_show_type_neighbor"
D->>D: "brief && sh_type==neighbor -> OK"
D->>N: "bgp_show_neighbor_route(..., uj=true, brief=true)"
N->>N: SET_FLAG(show_flags, BGP_SHOW_OPT_JSON)
N->>S: "bgp_show(..., show_flags, brief=true)"
S->>S: "use_json && brief -> json_paths=NULL"
loop per dest prefix
S->>F: bgp_fib_flags_info(vty, bgp, dest, json_flags, best_selected)
F-->>S: populate json_flags object
S-->>S: emit brief JSON: pathCount, multiPathCount, flags
end
S-->>U: "{routes:{...},totalRoutes:N,totalPaths:M,numRoutes:N}"
Reviews (4): Last reviewed commit: "tests: Enhanced tests to validate new co..." | Re-trigger Greptile |
62550f2 to
b768291
Compare
e35da60 to
9840507
Compare
|
ci:rerun |
9840507 to
2c132ff
Compare
|
@ton31337 I have addressed all the comments, if there is no concern , can we please merge this? Thanks. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
2c132ff to
85935db
Compare
7bfe9c7 to
e04b56c
Compare
|
@greptileai review |
|
@greptileai can you verify all your comments have been addressed? |
|
Most comments have been addressed, but there's one outstanding concern: Addressed:
Not fully resolved:
This change to |
brief-json support is added for show bgp v4 and v6 unicast neighbour routes. Commands supported: show bgp vrf <vrf> ipv4 unicast neighbors <neigh> routes json brief show bgp vrf <vrf> ipv6 unicast neighbors <neigh> routes json brief Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
show bgp vrf <> ipv4 unicast neighbors routes brief json show bgp vrf <>ipv6 unicast neighbors routes brief json Signed-off-by: harini <hnattamaisub@nvidia.com>
e04b56c to
28b3ffe
Compare
|
@ton31337 All the comments are addressed, please help in re-review and merging this , thanks |
|
@greptileai rereview |
brief-json support is added for show bgp v4 and v6 unicast neighbour routes.
Commands supported:
show bgp vrf ipv4 unicast neighbors routes brief json
show bgp vrf ipv6 unicast neighbors routes brief json
cpe1# show bgp vrf default ipv6 unicast neighbors 2001:db8:10::2 routes json brief
{
"routes": { "2001:db8:2::/64": {
"pathCount":1
,"multiPathCount":1
,"flags": {"bestPathExists":true,"fibInstalled":false,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} ,"2001:db8:10::/64": {
"pathCount":1
,"multiPathCount":0
,"flags": {"bestPathExists":false,"fibInstalled":true,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} } , "totalRoutes": 2, "totalPaths": 5,"numRoutes":2
}
cpe1#
cpe1# show bgp vrf default ipv6 unicast neighbors 2001:db8:10::2 routes json
{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 4,
"routerId": "172.16.255.1",
"defaultLocPrf": 100,
"localAS": 65000,
"routes": { "2001:db8:2::/64": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","prefix":"2001:db8:2::","prefixLen":64,"network":"2001:db8:2::/64","version":3,"metric":0,"locPrf":100,"weight":0,"peerId":"2001:db8:10::2","path":"","origin":"incomplete","nexthops":[{"ip":"2001:db8:10::2","hostname":"cpe2","afi":"ipv6","scope":"global","linkLocalOnly":false,"length":32},{"ip":"fe80::c00b:65ff:feab:769f","hostname":"cpe2","afi":"ipv6","scope":"link-local","used":true}]}]
,"2001:db8:10::/64": [{"valid":true,"pathFrom":"internal","prefix":"2001:db8:10::","prefixLen":64,"network":"2001:db8:10::/64","version":2,"metric":0,"locPrf":100,"weight":0,"peerId":"2001:db8:10::2","path":"","origin":"incomplete","nexthops":[{"ip":"2001:db8:10::2","hostname":"cpe2","afi":"ipv6","scope":"global","linkLocalOnly":false,"length":32},{"ip":"fe80::c00b:65ff:feab:769f","hostname":"cpe2","afi":"ipv6","scope":"link-local","used":true}]}]
} , "totalRoutes": 2, "totalPaths": 5,"numRoutes":2
}
cpe1#
pe1# show bgp vrf RED ipv4 unicast neighbors 192.168.1.1 routes json brief
{
"routes": { "10.0.0.0/24": {
"pathCount":1
,"multiPathCount":2
,"flags": {"bestPathExists":true,"fibInstalled":false,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} ,"172.16.255.1/32": {
"pathCount":1
,"multiPathCount":2
,"flags": {"bestPathExists":true,"fibInstalled":false,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} ,"192.168.1.0/24": {
"pathCount":1
,"multiPathCount":2
,"flags": {"bestPathExists":true,"fibInstalled":false,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} ,"192.168.2.0/24": {
"pathCount":1
,"multiPathCount":2
,"flags": {"bestPathExists":true,"fibInstalled":false,"fibWaitForInstall":false,"fibSuppress":false,"fibInstallFailed":false}
} } , "totalRoutes": 4, "totalPaths": 12,"numRoutes":4
}
pe1#
pe1# show bgp vrf RED ipv4 unicast neighbors 192.168.1.1 routes json
{
"vrfId": 4,
"vrfName": "RED",
"tableVersion": 12,
"routerId": "192.168.1.2",
"defaultLocPrf": 100,
"localAS": 65001,
"routes": { "10.0.0.0/24": [{"valid":true,"bestpath":true,"selectionReason":"Peer Type","multipath":true,"pathFrom":"external","prefix":"10.0.0.0","prefixLen":24,"network":"10.0.0.0/24","version":9,"metric":0,"weight":0,"peerId":"192.168.1.1","path":"65000","origin":"incomplete","nexthops":[{"ip":"192.168.1.1","hostname":"cpe1","afi":"ipv4","used":true}]}]
,"172.16.255.1/32": [{"valid":true,"bestpath":true,"selectionReason":"Peer Type","multipath":true,"pathFrom":"external","prefix":"172.16.255.1","prefixLen":32,"network":"172.16.255.1/32","version":11,"metric":0,"weight":0,"peerId":"192.168.1.1","path":"65000","origin":"incomplete","nexthops":[{"ip":"192.168.1.1","hostname":"cpe1","afi":"ipv4","used":true}]}]
,"192.168.1.0/24": [{"valid":true,"bestpath":true,"selectionReason":"Peer Type","multipath":true,"pathFrom":"external","prefix":"192.168.1.0","prefixLen":24,"network":"192.168.1.0/24","version":12,"metric":0,"weight":0,"peerId":"192.168.1.1","path":"65000","origin":"incomplete","nexthops":[{"ip":"192.168.1.1","hostname":"cpe1","afi":"ipv4","used":true}]}]
,"192.168.2.0/24": [{"valid":true,"bestpath":true,"selectionReason":"Peer Type","multipath":true,"pathFrom":"external","prefix":"192.168.2.0","prefixLen":24,"network":"192.168.2.0/24","version":10,"weight":0,"peerId":"192.168.1.1","path":"65000","origin":"incomplete","nexthops":[{"ip":"192.168.1.1","hostname":"cpe1","afi":"ipv4","used":true}]}]
} , "totalRoutes": 4, "totalPaths": 12,"numRoutes":4
}
pe1#