]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Print pretty json output for bgp_show_table()
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 17 Dec 2019 10:49:30 +0000 (12:49 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 17 Dec 2019 10:49:30 +0000 (12:49 +0200)
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 <donatas.abraitis@gmail.com>
bgpd/bgp_route.c

index 5a7f7664aa2341c92698b483774ead8319d069a5..15caedb85b8975015a4fdc9d4df511066a57fbc8 100644 (file)
@@ -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;