]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_evpn_vty.c
Merge pull request #10356 from opensourcerouting/pim6-adjust-20220117
[mirror_frr.git] / bgpd / bgp_evpn_vty.c
index 89ed9551ce9ecca57a8f363b373cd8a04665440f..caf0444850bbc407828ea093017a67e244103cde 100644 (file)
@@ -1246,17 +1246,23 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
                                if (type == bgp_show_type_lcommunity_exact) {
                                        struct lcommunity *lcom = output_arg;
 
-                                       if (!pi->attr->lcommunity ||
-                                               !lcommunity_cmp(
-                                               pi->attr->lcommunity, lcom))
+                                       if (!bgp_attr_get_lcommunity(
+                                                   pi->attr) ||
+                                           !lcommunity_cmp(
+                                                   bgp_attr_get_lcommunity(
+                                                           pi->attr),
+                                                   lcom))
                                                continue;
                                }
                                if (type == bgp_show_type_lcommunity) {
                                        struct lcommunity *lcom = output_arg;
 
-                                       if (!pi->attr->lcommunity ||
-                                               !lcommunity_match(
-                                               pi->attr->lcommunity, lcom))
+                                       if (!bgp_attr_get_lcommunity(
+                                                   pi->attr) ||
+                                           !lcommunity_match(
+                                                   bgp_attr_get_lcommunity(
+                                                           pi->attr),
+                                                   lcom))
                                                continue;
                                }
                                if (type == bgp_show_type_community) {
@@ -1345,10 +1351,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 +1376,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 +4395,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 +4674,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 +4735,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 +4818,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 +4859,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 +4926,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 +4993,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 +5048,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 +5108,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 +5141,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 +5174,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 +5207,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 +5240,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 +5823,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;
 }