mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 09:30:30 +00:00
bgpd: Print totalRoutes and totalPaths in JSON output
E.g.: ``` r1# sh bgp ipv4 unicast neighbors 192.168.1.2 routes json { "vrfId": 0, "vrfName": "default", "tableVersion": 2, "routerId": "192.168.1.1", "defaultLocPrf": 100, "localAS": 65001, "routes": { "172.16.16.254/32": [{"valid":true,"bestpath":true,"selectionReason":"Nothing left to compare","pathFrom":"external","prefix":"172.16.16.254","prefixLen":32,"network":"172.16.16.254\/32","version":2,"weight":0,"peerId":"192.168.1.2","path":"65002 65006","origin":"incomplete","nexthops":[{"ip":"192.168.1.2","hostname":"r2","afi":"ipv4","used":true}]},{"valid":true,"multipath":true,"pathFrom":"external","prefix":"172.16.16.254","prefixLen":32,"network":"172.16.16.254\/32","version":2,"weight":0,"peerId":"192.168.1.2","path":"65002 65005","origin":"incomplete","nexthops":[{"ip":"192.168.1.2","hostname":"r2","afi":"ipv4","used":true}]}] } , "totalRoutes": 1, "totalPaths": 2 } ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
708f08cb18
commit
aade9a7992
@ -12121,8 +12121,13 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
|
|||||||
}
|
}
|
||||||
if (is_last) {
|
if (is_last) {
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for (i = 0; i < *json_header_depth; ++i)
|
for (i = 0; i < *json_header_depth; ++i) {
|
||||||
vty_out(vty, " } ");
|
vty_out(vty, " } ");
|
||||||
|
/* Put this information before closing the last `}` */
|
||||||
|
if (i == *json_header_depth - 2)
|
||||||
|
vty_out(vty, ", \"totalRoutes\": %ld, \"totalPaths\": %ld",
|
||||||
|
output_count, total_count);
|
||||||
|
}
|
||||||
if (!all)
|
if (!all)
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user