diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-04-02 20:33:56 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-02 20:33:56 +0300 |
| commit | bdf62ec61b343adc007a93a66081d26d1483950a (patch) | |
| tree | fb8e91656e9397c2a90cdc287a67e4b87b029630 | |
| parent | 9ecc5f3603634995724335084d708fd87fa4fd21 (diff) | |
| parent | 8ed85db65cab700aaa80d0b01e977b1a40fd5d44 (diff) | |
Merge pull request #13182 from taspelund/add_bgp_json_comments
bgpd: add comments for 'json detail' show cmd code
| -rw-r--r-- | bgpd/bgp_route.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4813874748..a23bffd4ae 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -11603,9 +11603,28 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, vty_out(vty, ",\"%pFX\": ", dest_p); } + /* This is used for 'json detail' vty keywords. + * + * In plain 'json' the per-prefix header is encoded + * as a standalone dictionary in the first json_paths + * array element: + * "<prefix>": [{header}, {path-1}, {path-N}] + * (which is confusing and borderline broken) + * + * For 'json detail' this changes the value + * of each prefix-key to be a dictionary where each + * header item has its own key, and json_paths is + * tucked under the "paths" key: + * "<prefix>": { + * "<header-key-1>": <header-val-1>, + * "<header-key-N>": <header-val-N>, + * "paths": [{path-1}, {path-N}] + * } + */ if (json_detail_header && json_paths != NULL) { const struct prefix_rd *prd; + /* Start per-prefix dictionary */ vty_out(vty, "{\n"); prd = bgp_rd_from_dest(dest, safi); @@ -11630,6 +11649,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, */ vty_json_no_pretty(vty, json_paths); + /* End per-prefix dictionary */ if (json_detail_header_used) vty_out(vty, "} "); |
