]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix json output in some situations 1462/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 17 Nov 2017 17:53:54 +0000 (12:53 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 17 Nov 2017 17:53:54 +0000 (12:53 -0500)
This commit fixes a bug where json output would display
',,,,,,,' because we were deciding to not display information
about some routes due to a selection criteria.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_route.c

index ba75da45912ac2ea79411913d5d13f8a1de2183e..a1c891fc662fed1e2b2634f70a3c9dc9e1e6ce8f 100644 (file)
@@ -8187,8 +8187,6 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                        continue;
 
                display = 0;
-               if (!first && use_json)
-                       vty_out(vty, ",");
                if (use_json)
                        json_paths = json_object_new_array();
                else
@@ -8384,7 +8382,11 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                inet_ntop(p->family, &p->u.prefix,
                                          buf, BUFSIZ),
                                p->prefixlen);
-                       vty_out(vty, "\"%s\": ", buf2);
+                       if (first)
+                               vty_out(vty, "\"%s\": ", buf2);
+                       else
+                               vty_out(vty, ",\"%s\": ", buf2);
+
                        vty_out(vty, "%s",
                                json_object_to_json_string_ext(json_paths, JSON_C_TO_STRING_PRETTY));
                        json_object_free(json_paths);