afi_t afi;
safi_t safi;
uint32_t prefix_cnt, path_cnt;
+ int first = true;
afi = AFI_L2VPN;
safi = SAFI_EVPN;
prefix_rd2str((struct prefix_rd *)rd_destp, rd_str,
sizeof(rd_str), bgp->asnotation);
- if (json)
+ if (json) {
+ if (first) {
+ vty_out(vty, "\"%s\":", rd_str);
+ first = false;
+ } else {
+ vty_out(vty, ",\"%s\":", rd_str);
+ }
json_rd = json_object_new_object();
+ }
rd_header = 1;
}
if (json) {
- if (add_rd_to_json)
- json_object_object_add(json, rd_str, json_rd);
- else {
+ if (add_rd_to_json) {
+ vty_json_no_pretty(vty, json_rd);
+ } else {
+ vty_out(vty, "{}");
json_object_free(json_rd);
- json_rd = NULL;
}
}
}
if (json) {
- json_object_int_add(json, "numPrefix", prefix_cnt);
- json_object_int_add(json, "numPaths", path_cnt);
+ vty_out(vty, ",\"numPrefix\":%u", prefix_cnt);
+ vty_out(vty, ",\"numPaths\":%u", path_cnt);
} else {
if (prefix_cnt == 0) {
vty_out(vty, "No EVPN prefixes %sexist\n",
{
json_object *json = NULL;
- if (use_json)
+ if (use_json) {
json = json_object_new_object();
+ vty_out(vty, "{\n");
+ }
evpn_show_all_routes(vty, bgp, type, json, detail, false);
- if (use_json)
- /*
- * We are using no_pretty here because under extremely high
- * settings (lots of routes with many different paths) this can
- * save several minutes of output when FRR is run on older cpu's
- * or more underperforming routers out there. So for route
- * scale, we need to use no_pretty json.
- */
- vty_json_no_pretty(vty, json);
+ if (use_json) {
+ vty_out(vty, "}\n");
+ json_object_free(json);
+ }
+
return CMD_SUCCESS;
}
if (!bgp)
return CMD_WARNING;
- if (uj)
+ if (uj) {
json = json_object_new_object();
+ vty_out(vty, "{\n");
+ }
if (bgp_evpn_cli_parse_type(&type, argv, argc) < 0)
return CMD_WARNING;
evpn_show_all_routes(vty, bgp, type, json, detail, self_orig);
- /*
- * This is an extremely expensive operation at scale
- * and as such we need to save as much time as is
- * possible.
- */
- if (uj)
- vty_json_no_pretty(vty, json);
+ if (uj) {
+ vty_out(vty, "}\n");
+ json_object_free(json);
+ }
return CMD_SUCCESS;
}
if (bgp_evpn_cli_parse_type(&type, argv, argc) < 0)
return CMD_WARNING;
- if (rd_all)
+ if (rd_all) {
+ if (uj)
+ vty_out(vty, "{\n");
+
evpn_show_all_routes(vty, bgp, type, json, 1, false);
- else
+
+ if (uj) {
+ vty_out(vty, "}\n");
+ json_object_free(json);
+ return CMD_SUCCESS;
+ }
+ } else {
evpn_show_route_rd(vty, bgp, &prd, type, json);
+ }
if (uj)
vty_json(vty, json);