summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-02-02 10:28:19 -0500
committerDonatas Abraitis <donatas@opensourcerouting.org>2023-02-06 12:48:10 +0200
commit2c512e1bc9ac7bee58da01fe7e12218aea75699c (patch)
treecabcc5de0bb3d4191afb1a727335f461551380a1 /lib/vty.c
parent7a758370a5a2b1215c9c8df368554fae5c302429 (diff)
lib, bgpd: Add ability to specify that some json output should not be pretty
Initial commit: 23b2a7ef524c9fe083b217c7f6ebaec0effc8f52 changed the json output of `show bgp <afi> <safi> json` to not have pretty print because when under a situation where there are a bunch of routes with a large scale ecmp show output was taking forever and this commit cut 2 minutes out of vtysh run time. Subusequent commit: f4ec52f7cc99f709756d9030623a20c98a086125 changed this back. When upgrading to latest version the long run time was noticed due to testing. Let's add back this functionality such that FRR can have reduced run times with vtysh when it's really needed. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 5fe8a7955b..9d8966064a 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -281,7 +281,8 @@ done:
return len;
}
-int vty_json(struct vty *vty, struct json_object *json)
+static int vty_json_helper(struct vty *vty, struct json_object *json,
+ uint32_t options)
{
const char *text;
@@ -296,6 +297,18 @@ int vty_json(struct vty *vty, struct json_object *json)
return CMD_SUCCESS;
}
+int vty_json(struct vty *vty, struct json_object *json)
+{
+ return vty_json_helper(vty, json,
+ JSON_C_TO_STRING_PRETTY |
+ JSON_C_TO_STRING_NOSLASHESCAPE);
+}
+
+int vty_json_no_pretty(struct vty *vty, struct json_object *json)
+{
+ return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
+}
+
/* Output current time to the vty. */
void vty_time_print(struct vty *vty, int cr)
{