diff options
Diffstat (limited to 'bgpd/bgp_evpn_vty.c')
| -rw-r--r-- | bgpd/bgp_evpn_vty.c | 117 |
1 files changed, 35 insertions, 82 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 89ed9551ce..f377c8352b 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1345,10 +1345,12 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, json_prefix_info = json_object_new_object(); - json_object_string_add( - json_prefix_info, "prefix", - prefix2str((struct prefix_evpn *)p, buf, - BUFSIZ)); + prefix2str((struct prefix_evpn *)p, buf, + BUFSIZ); + + json_object_string_addf( + json_prefix_info, "prefix", "%pFX", + (struct prefix_evpn *)p); json_object_int_add(json_prefix_info, "prefixLen", p->prefixlen); @@ -1368,9 +1370,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, if (use_json) { json_object_int_add(json, "numPrefix", output_count); json_object_int_add(json, "totalPrefix", total_count); - 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 { if (output_count == 0) vty_out(vty, "No prefixes displayed, %ld exist\n", @@ -4389,14 +4389,8 @@ DEFUN(show_bgp_l2vpn_evpn_vni, evpn_show_vni(vty, bgp_evpn, vni, json); } - if (uj) { - 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 (uj) + vty_json(vty, json); return CMD_SUCCESS; } @@ -4674,11 +4668,8 @@ DEFUN(show_bgp_l2vpn_evpn_route, evpn_show_all_routes(vty, bgp, type, json, detail); - 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); return CMD_SUCCESS; } @@ -4738,11 +4729,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd, else evpn_show_route_rd(vty, bgp, &prd, type, json); - 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); return CMD_SUCCESS; } @@ -4824,11 +4812,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd_macip, else evpn_show_route_rd_macip(vty, bgp, &prd, &mac, &ip, json); - 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); return CMD_SUCCESS; } @@ -4868,11 +4853,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_esi, evpn_show_routes_esi(vty, bgp, &esi, json); - 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); return CMD_SUCCESS; } @@ -4938,11 +4920,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd, evpn_show_routes_vni(vty, bgp, vni, type, vtep_ip, json); - 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); return CMD_SUCCESS; } @@ -5008,11 +4987,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_macip, evpn_show_route_vni_macip(vty, bgp, vni, &mac, &ip, json); - 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); return CMD_SUCCESS; } @@ -5066,11 +5042,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_multicast, evpn_show_route_vni_multicast(vty, bgp, vni, orig_ip, json); - 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); return CMD_SUCCESS; } @@ -5129,11 +5102,8 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_all, evpn_show_routes_vni_all(vty, bgp, vtep_ip, json, da); - 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); return CMD_SUCCESS; } @@ -5165,12 +5135,8 @@ DEFPY_HIDDEN( if (uj) json = json_object_new_object(); bgp_evpn_show_routes_mac_ip_evi_es(vty, esi_p, json, !!detail); - 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); return CMD_SUCCESS; } @@ -5202,12 +5168,8 @@ DEFPY_HIDDEN( if (uj) json = json_object_new_object(); bgp_evpn_show_routes_mac_ip_global_es(vty, esi_p, json, !!detail); - 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); return CMD_SUCCESS; } @@ -5239,11 +5201,8 @@ DEFUN(show_bgp_l2vpn_evpn_vrf_import_rt, evpn_show_vrf_import_rts(vty, bgp_evpn, json); - 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); return CMD_SUCCESS; } @@ -5275,11 +5234,8 @@ DEFUN(show_bgp_l2vpn_evpn_import_rt, evpn_show_import_rts(vty, bgp, json); - 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); return CMD_SUCCESS; } @@ -5861,11 +5817,8 @@ DEFUN (show_bgp_vrf_l3vni_info, prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN)); } - 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); return CMD_SUCCESS; } |
