diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-12-19 17:21:07 +0100 |
---|---|---|
committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-12-19 17:21:07 +0100 |
commit | aade9a7992750e45634b8ce54f141c93e1f6c6de (patch) | |
tree | 7d59a61c41e925a7fce1a13155f7c254b6dfa32b /bgpd/bgp_route.c | |
parent | bgpd: Show applied route-map attributes for `neighbor X advertised-routes det... (diff) | |
download | frr-aade9a7992750e45634b8ce54f141c93e1f6c6de.tar.xz frr-aade9a7992750e45634b8ce54f141c93e1f6c6de.zip |
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>
Diffstat (limited to '')
-rw-r--r-- | bgpd/bgp_route.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index b0a394234..cd96e171c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -12121,8 +12121,13 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa } if (is_last) { unsigned long i; - for (i = 0; i < *json_header_depth; ++i) + for (i = 0; i < *json_header_depth; ++i) { 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) vty_out(vty, "\n"); } |