From: Louis Scalbert Date: Wed, 7 Jun 2023 13:15:30 +0000 (+0200) Subject: bgpd: fix incorrect json output in bgp_show_table_rd() X-Git-Tag: base_9.1~346^2~9 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a04d32b36649c0e14c76ec121d17a46d95db5697;p=matthieu%2Ffrr.git bgpd: fix incorrect json output in bgp_show_table_rd() '{}' extra output may present JSON output from bgp_show_table_rd() when no prefix are seen. > { > "vrfId": 0, > "vrfName": "default", > "tableVersion": 0, > "routerId": "1.1.1.1", > "defaultLocPrf": 100, > "localAS": 65500, > "routes": { "routeDistinguishers" : { "444:1" : { } } } } > {} Do not output '{}' when bgp_show_table() returns a valid JSON. Tested without rd in config, bgp_show_table() returns nothing and the JSON output is only '{}' Fixes: 0224b3296c ("bgpd: Print empty JSON `{}` if no entries under `show bgp ipv4 vpn json`") Signed-off-by: Louis Scalbert --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5285a221e2..058f57177a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -11783,7 +11783,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, "\nDisplayed %ld routes and %ld total paths\n", output_cum, total_cum); } else { - if (use_json && output_cum == 0) + if (use_json && output_cum == 0 && json_header_depth == 0) vty_out(vty, "{}\n"); } return CMD_SUCCESS;