From: Donatas Abraitis Date: Tue, 17 Dec 2019 10:49:30 +0000 (+0200) Subject: bgpd: Print pretty json output for bgp_show_table() X-Git-Tag: base_7.3~34^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f4ec52f7cc99f709756d9030623a20c98a086125;p=mirror%2Ffrr.git bgpd: Print pretty json output for bgp_show_table() This is not very cool: ``` { "vrfId": 0, "vrfName": "default", "tableVersion": 4, "routerId": "192.168.0.1", "defaultLocPrf": 100, "localAS": 200, "routes": { "10.0.0.150/32": [{"valid":true,"bestpath":true,"pathFrom":"external","prefix":"10.0.0.150","prefixLen":32,"network":"10.0.0.150\/32","med":0,"metric":0,"weight":32768,"peerId":"(unspec)","aspath":"200 200 200","path":"200 200 200","origin":"incomplete","nexthops":[{"ip":"0.0.0.0","afi":"ipv4","used":true}]}],"10.0.0.200/32": [{"valid":true,"bestpath":true,"pathFrom":"external","prefix":"10.0.0.200","prefixLen":32,"network":"10.0.0.200\/32","med":0,"metric":0,"weight":32768,"peerId":"(unspec)","aspath":"200 200 200","path":"200 200 200","origin":"incomplete","nexthops":[{"ip":"0.0.0.0","afi":"ipv4","used":true}]}],"10.0.2.0/24": [{"valid":true,"bestpath":true,"pathFrom":"external","prefix":"10.0.2.0","prefixLen":24,"network":"10.0.2.0\/24","med":0,"metric":0,"weight":32768,"peerId":"(unspec)","aspath":"200 200 200","path":"200 200 200","origin":"incomplete","nexthops":[{"ip":"0.0.0.0","afi":"ipv4","used":true}]}],"192.168.0.0/24": [{"valid":true,"bestpath":true,"pathFrom":"external","prefix":"192.168.0.0","prefixLen":24,"network":"192.168.0.0\/24","med":0,"metric":0,"weight":32768,"peerId":"(unspec)","aspath":"200 200 200","path":"200 200 200","origin":"incomplete","nexthops":[{"ip":"0.0.0.0","afi":"ipv4","used":true}]}] } } ``` Signed-off-by: Donatas Abraitis --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5a7f7664aa..15caedb85b 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9433,7 +9433,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, vty_out(vty, ",\"%s\": ", buf2); } vty_out(vty, "%s", - json_object_to_json_string(json_paths)); + json_object_to_json_string_ext( + json_paths, JSON_C_TO_STRING_PRETTY)); json_object_free(json_paths); json_paths = NULL; first = 0;