summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/dplane_fpm_nl.c3
-rw-r--r--zebra/interface.c42
-rw-r--r--zebra/main.c4
-rw-r--r--zebra/zebra_evpn_mh.c72
-rw-r--r--zebra/zebra_mpls.c8
-rw-r--r--zebra/zebra_pw.c4
-rw-r--r--zebra/zebra_router.c2
-rw-r--r--zebra/zebra_router.h1
-rw-r--r--zebra/zebra_srv6_vty.c4
-rw-r--r--zebra/zebra_vty.c30
-rw-r--r--zebra/zebra_vxlan.c160
11 files changed, 90 insertions, 240 deletions
diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c
index 2f39284fb0..3b02128c90 100644
--- a/zebra/dplane_fpm_nl.c
+++ b/zebra/dplane_fpm_nl.c
@@ -363,8 +363,7 @@ DEFUN(fpm_show_counters_json, fpm_show_counters_json_cmd,
json_object_int_add(jo, "user-configures",
gfnc->counters.user_configures);
json_object_int_add(jo, "user-disables", gfnc->counters.user_disables);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(jo, 0));
- json_object_free(jo);
+ vty_json(vty, jo);
return CMD_SUCCESS;
}
diff --git a/zebra/interface.c b/zebra/interface.c
index d300397b4e..8b5dbabb92 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1310,7 +1310,6 @@ static void connected_dump_vty(struct vty *vty, json_object *json,
{
struct prefix *p;
json_object *json_addr = NULL;
- char buf[PREFIX2STR_BUFFER];
/* Print interface address. */
p = connected->address;
@@ -1318,8 +1317,7 @@ static void connected_dump_vty(struct vty *vty, json_object *json,
if (json) {
json_addr = json_object_new_object();
json_object_array_add(json, json_addr);
- json_object_string_add(json_addr, "address",
- prefix2str(p, buf, sizeof(buf)));
+ json_object_string_addf(json_addr, "address", "%pFX", p);
} else {
vty_out(vty, " %s %pFX", prefix_family_str(p), p);
}
@@ -1327,10 +1325,8 @@ static void connected_dump_vty(struct vty *vty, json_object *json,
/* If there is destination address, print it. */
if (CONNECTED_PEER(connected) && connected->destination) {
if (json) {
- json_object_string_add(
- json_addr, "peer",
- prefix2str(connected->destination, buf,
- sizeof(buf)));
+ json_object_string_addf(json_addr, "peer", "%pFX",
+ connected->destination);
} else {
vty_out(vty, " peer %pFX", connected->destination);
}
@@ -2348,12 +2344,8 @@ DEFPY(show_interface, show_interface_cmd,
}
}
- if (json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -2395,12 +2387,8 @@ DEFPY (show_interface_vrf_all,
}
}
- if (json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -2448,12 +2436,8 @@ DEFPY (show_interface_name_vrf,
else
if_dump_vty(vty, ifp);
- if (json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -2513,12 +2497,8 @@ DEFPY (show_interface_name_vrf_all,
else
if_dump_vty(vty, ifp);
- if (json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
diff --git a/zebra/main.c b/zebra/main.c
index 275d9af5d2..2a8dc39771 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -443,8 +443,8 @@ int main(int argc, char **argv)
* we have to have route_read() called before.
*/
zrouter.startup_time = monotime(NULL);
- thread_add_timer(zrouter.master, rib_sweep_route,
- NULL, graceful_restart, NULL);
+ thread_add_timer(zrouter.master, rib_sweep_route, NULL,
+ graceful_restart, &zrouter.sweeper);
/* Needed for BSD routing socket. */
pid = getpid();
diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c
index 9b3ea220f7..af4629e41c 100644
--- a/zebra/zebra_evpn_mh.c
+++ b/zebra/zebra_evpn_mh.c
@@ -418,12 +418,8 @@ void zebra_evpn_es_evi_show(struct vty *vty, bool uj, int detail)
hash_iterate(zvrf->evpn_table, zebra_evpn_es_evi_show_one_evpn_hash_cb,
&wctx);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
void zebra_evpn_es_evi_show_vni(struct vty *vty, bool uj, vni_t vni, int detail)
@@ -446,12 +442,8 @@ void zebra_evpn_es_evi_show_vni(struct vty *vty, bool uj, vni_t vni, int detail)
vty_out(vty, "VNI %d doesn't exist\n", vni);
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
/* Initialize the ES tables maintained per-L2_VNI */
@@ -998,12 +990,8 @@ void zebra_evpn_acc_vl_show(struct vty *vty, bool uj)
hash_iterate(zmh_info->evpn_vlan_table, zebra_evpn_acc_vl_show_hash,
&wctx);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
void zebra_evpn_acc_vl_show_detail(struct vty *vty, bool uj)
@@ -1021,12 +1009,8 @@ void zebra_evpn_acc_vl_show_detail(struct vty *vty, bool uj)
hash_iterate(zmh_info->evpn_vlan_table, zebra_evpn_acc_vl_show_hash,
&wctx);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
void zebra_evpn_acc_vl_show_vid(struct vty *vty, bool uj, vlanid_t vid)
@@ -1045,12 +1029,8 @@ void zebra_evpn_acc_vl_show_vid(struct vty *vty, bool uj, vlanid_t vid)
vty_out(vty, "VLAN %u not present\n", vid);
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
}
/* Initialize VLAN member bitmap on an interface. Although VLAN membership
@@ -1363,12 +1343,8 @@ void zebra_evpn_l2_nh_show(struct vty *vty, bool uj)
hash_iterate(zmh_info->nh_ip_table, zebra_evpn_l2_nh_show_cb, &wctx);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
static struct zebra_evpn_l2_nh *zebra_evpn_l2_nh_find(struct in_addr vtep_ip)
@@ -3217,12 +3193,8 @@ void zebra_evpn_es_show(struct vty *vty, bool uj)
RB_FOREACH(es, zebra_es_rb_head, &zmh_info->es_rb_tree)
zebra_evpn_es_show_entry(vty, es, json_array);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
void zebra_evpn_es_show_detail(struct vty *vty, bool uj)
@@ -3243,12 +3215,8 @@ void zebra_evpn_es_show_detail(struct vty *vty, bool uj)
json_object_array_add(json_array, json);
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (uj)
+ vty_json(vty, json_array);
}
void zebra_evpn_es_show_esi(struct vty *vty, bool uj, esi_t *esi)
@@ -3271,12 +3239,8 @@ void zebra_evpn_es_show_esi(struct vty *vty, bool uj, esi_t *esi)
}
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
}
int zebra_evpn_mh_if_write(struct vty *vty, struct interface *ifp)
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 46f60a85c4..924a43049b 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -3725,9 +3725,7 @@ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf,
if (use_json) {
json = lsp_json(lsp);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else
lsp_print(vty, lsp);
}
@@ -3754,9 +3752,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
sizeof(buf)),
lsp_json(lsp));
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
struct ttable *tt;
diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c
index d5083d4cbe..57276974c3 100644
--- a/zebra/zebra_pw.c
+++ b/zebra/zebra_pw.c
@@ -783,9 +783,7 @@ static void vty_show_mpls_pseudowire_detail_json(struct vty *vty)
vty_show_mpls_pseudowire(pw, json_pws);
}
json_object_object_add(json, "pw", json_pws);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
DEFUN(show_pseudowires_detail, show_pseudowires_detail_cmd,
diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c
index a80c573855..92a3b9424b 100644
--- a/zebra/zebra_router.c
+++ b/zebra/zebra_router.c
@@ -232,6 +232,8 @@ void zebra_router_terminate(void)
{
struct zebra_router_table *zrt, *tmp;
+ THREAD_OFF(zrouter.sweeper);
+
RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp)
zebra_router_free_table(zrt);
diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h
index 408f9cbee5..dd788216c7 100644
--- a/zebra/zebra_router.h
+++ b/zebra/zebra_router.h
@@ -196,6 +196,7 @@ struct zebra_router {
* Time for when we sweep the rib from old routes
*/
time_t startup_time;
+ struct thread *sweeper;
/*
* The hash of nexthop groups associated with this router
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c
index cb1e6c4228..fe4641cd94 100644
--- a/zebra/zebra_srv6_vty.c
+++ b/zebra/zebra_srv6_vty.c
@@ -108,9 +108,7 @@ DEFUN (show_srv6_locator,
}
- vty_out(vty, "%s\n", json_object_to_json_string_ext(json,
- JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
vty_out(vty, "Locator:\n");
vty_out(vty, "Name ID Prefix Status\n");
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index a3faa3d3e2..9c57381165 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1127,11 +1127,7 @@ static void vty_show_ip_route_detail_json(struct vty *vty,
prefix2str(&rn->p, buf, sizeof(buf));
json_object_object_add(json, buf, json_prefix);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY
- | JSON_C_TO_STRING_NOSLASHESCAPE));
- json_object_free(json);
+ vty_json(vty, json);
}
static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
@@ -1241,14 +1237,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
}
}
- if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json,
- JSON_C_TO_STRING_PRETTY
- | JSON_C_TO_STRING_NOSLASHESCAPE));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf,
@@ -2480,10 +2470,7 @@ static void vty_show_ip_route_summary(struct vty *vty,
json_object_int_add(json_route_summary, "routesTotalFib",
fib_cnt[ZEBRA_ROUTE_TOTAL]);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_route_summary, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_route_summary);
+ vty_json(vty, json_route_summary);
} else {
vty_out(vty, "------\n");
vty_out(vty, "%-20s %-20d %-20d \n", "Totals",
@@ -2631,10 +2618,7 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,
json_object_int_add(json_route_summary, "prefixRoutesTotalFib",
fib_cnt[ZEBRA_ROUTE_TOTAL]);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_route_summary, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_route_summary);
+ vty_json(vty, json_route_summary);
} else {
vty_out(vty, "------\n");
vty_out(vty, "%-20s %-20d %-20d \n", "Totals",
@@ -3006,9 +2990,7 @@ DEFUN (show_vrf_vni,
if (uj) {
json_object_object_add(json, "vrfs", json_vrfs);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 84ab4a718d..5ef7c9acea 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -2315,11 +2315,8 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
zl3vni_print_rmac(zrmac, vty, json);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
@@ -2359,11 +2356,8 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
hash_iterate(zl3vni->rmac_table, zl3vni_print_rmac_hash, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json)
@@ -2387,11 +2381,8 @@ void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json)
void *))zl3vni_print_rmac_hash_all_vni,
args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
@@ -2432,11 +2423,8 @@ void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
zl3vni_print_nh(n, vty, json);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
@@ -2476,11 +2464,8 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
hash_iterate(zl3vni->nh_table, zl3vni_print_nh_hash, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json)
@@ -2504,11 +2489,8 @@ void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json)
void *))zl3vni_print_nh_hash_all_vni,
args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2542,11 +2524,8 @@ void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, bool use_json)
args[1] = json;
zl3vni_print(zl3vni, (void *)args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,
@@ -2633,11 +2612,8 @@ void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf,
json_object_int_add(json, "numArpNd", num_neigh);
hash_iterate(zevpn->neigh_table, zebra_evpn_print_neigh_hash, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2663,11 +2639,8 @@ void zebra_vxlan_print_neigh_all_vni(struct vty *vty, struct zebra_vrf *zvrf,
(void (*)(struct hash_bucket *,
void *))zevpn_print_neigh_hash_all_evpn,
args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2694,11 +2667,8 @@ void zebra_vxlan_print_neigh_all_vni_detail(struct vty *vty,
(void (*)(struct hash_bucket *,
void *))zevpn_print_neigh_hash_all_evpn_detail,
args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2735,11 +2705,8 @@ void zebra_vxlan_print_specific_neigh_vni(struct vty *vty,
zebra_evpn_print_neigh(n, vty, json);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2783,11 +2750,8 @@ void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf,
&wctx);
hash_iterate(zevpn->neigh_table, zebra_evpn_print_neigh_hash, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2849,11 +2813,8 @@ void zebra_vxlan_print_neigh_vni_dad(struct vty *vty,
hash_iterate(zevpn->neigh_table, zebra_evpn_print_dad_neigh_hash,
&wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2907,9 +2868,7 @@ void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf,
if (use_json) {
json_object_object_add(json, "macs", json_mac);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
}
@@ -2936,11 +2895,8 @@ void zebra_vxlan_print_macs_all_vni(struct vty *vty, struct zebra_vrf *zvrf,
wctx.print_dup = print_dup;
hash_iterate(zvrf->evpn_table, zevpn_print_mac_hash_all_evpn, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2968,11 +2924,8 @@ void zebra_vxlan_print_macs_all_vni_detail(struct vty *vty,
hash_iterate(zvrf->evpn_table, zevpn_print_mac_hash_all_evpn_detail,
&wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -2998,11 +2951,8 @@ void zebra_vxlan_print_macs_all_vni_vtep(struct vty *vty,
wctx.json = json;
hash_iterate(zvrf->evpn_table, zevpn_print_mac_hash_all_evpn, &wctx);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/*
@@ -3042,11 +2992,8 @@ void zebra_vxlan_print_specific_mac_vni(struct vty *vty, struct zebra_vrf *zvrf,
json = json_object_new_object();
zebra_evpn_print_mac(mac, vty, json);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
/* Print Duplicate MACs per VNI */
@@ -3100,9 +3047,7 @@ void zebra_vxlan_print_macs_vni_dad(struct vty *vty,
if (use_json) {
json_object_object_add(json, "macs", json_mac);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
}
@@ -3442,9 +3387,7 @@ void zebra_vxlan_print_macs_vni_vtep(struct vty *vty, struct zebra_vrf *zvrf,
json_object_int_add(json, "numMacs", wctx.count);
if (wctx.count)
json_object_object_add(json, "macs", json_mac);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
}
@@ -3493,11 +3436,8 @@ void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf, vni_t vni,
*/
if (json_array)
json_object_array_add(json_array, json);
- else {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ else
+ vty_json(vty, json);
}
}
@@ -3564,11 +3504,8 @@ void zebra_vxlan_print_evpn(struct vty *vty, bool uj)
zebra_evpn_mh_print(vty);
}
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
}
/*
@@ -3604,11 +3541,8 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
(void (*)(struct hash_bucket *, void *))zl3vni_print_hash,
args);
- if (use_json) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
}
void zebra_vxlan_dup_addr_detection(ZAPI_HANDLER_ARGS)
@@ -3693,12 +3627,8 @@ void zebra_vxlan_print_vnis_detail(struct vty *vty, struct zebra_vrf *zvrf,
void *))zl3vni_print_hash_detail,
&zes);
- if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json_array, JSON_C_TO_STRING_PRETTY));
- json_object_free(json_array);
- }
+ if (use_json)
+ vty_json(vty, json_array);
}
/*