]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix incorrect json output in bgp_show_table_rd()
authorLouis Scalbert <louis.scalbert@6wind.com>
Wed, 7 Jun 2023 13:15:30 +0000 (15:15 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 16 Jun 2023 12:18:25 +0000 (14:18 +0200)
'{}' 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 <louis.scalbert@6wind.com>
bgpd/bgp_route.c

index 5285a221e2735aaef4da25c996fe97a407799251..058f57177a9518085498586dcff2e8661b8f2cea 100644 (file)
@@ -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;