summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_evpn_vty.c5
-rw-r--r--bgpd/bgp_route.c99
2 files changed, 78 insertions, 26 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index 4296604c4a..8414ae5749 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -1554,14 +1554,15 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes,
DEFUN(show_ip_bgp_l2vpn_evpn_all_overlay,
show_ip_bgp_l2vpn_evpn_all_overlay_cmd,
- "show [ip] bgp l2vpn evpn all overlay",
+ "show [ip] bgp l2vpn evpn all overlay [json]",
SHOW_STR
IP_STR
BGP_STR
L2VPN_HELP_STR
EVPN_HELP_STR
"Display information about all EVPN NLRIs\n"
- "Display BGP Overlay Information for prefixes\n")
+ "Display BGP Overlay Information for prefixes\n"
+ JSON_STR)
{
return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_normal, NULL,
SHOW_DISPLAY_OVERLAY,
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 82a395d8e6..d5e12488d7 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -7525,21 +7525,26 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
json_object *json_paths)
{
struct attr *attr;
- char buf[BUFSIZ];
+ char buf[BUFSIZ] = {0};
json_object *json_path = NULL;
-
- if (json_paths)
- json_path = json_object_new_object();
+ json_object *json_nexthop = NULL;
+ json_object *json_overlay = NULL;
if (!path->extra)
return;
+ if (json_paths) {
+ json_path = json_object_new_object();
+ json_overlay = json_object_new_object();
+ json_nexthop = json_object_new_object();
+ }
+
/* short status lead text */
route_vty_short_status_out(vty, path, json_path);
/* print prefix and mask */
if (!display)
- route_vty_out_route(p, vty, NULL);
+ route_vty_out_route(p, vty, json_path);
else
vty_out(vty, "%*s", 17, " ");
@@ -7551,35 +7556,69 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
switch (af) {
case AF_INET:
- vty_out(vty, "%-16s",
- inet_ntop(af, &attr->mp_nexthop_global_in, buf,
- BUFSIZ));
+ inet_ntop(af, &attr->mp_nexthop_global_in, buf, BUFSIZ);
+ if (!json_path) {
+ vty_out(vty, "%-16s", buf);
+ } else {
+ json_object_string_add(json_nexthop, "ip", buf);
+
+ json_object_string_add(json_nexthop, "afi",
+ "ipv4");
+
+ json_object_object_add(json_path, "nexthop",
+ json_nexthop);
+ }
break;
case AF_INET6:
- vty_out(vty, "%s(%s)",
- inet_ntop(af, &attr->mp_nexthop_global, buf,
- BUFSIZ),
- inet_ntop(af, &attr->mp_nexthop_local, buf1,
- BUFSIZ));
+ inet_ntop(af, &attr->mp_nexthop_global, buf, BUFSIZ);
+ inet_ntop(af, &attr->mp_nexthop_local, buf1, BUFSIZ);
+ if (!json_path) {
+ vty_out(vty, "%s(%s)", buf, buf1);
+ } else {
+ json_object_string_add(json_nexthop,
+ "ipv6Global", buf);
+
+ json_object_string_add(json_nexthop,
+ "ipv6LinkLocal", buf1);
+
+ json_object_string_add(json_nexthop, "afi",
+ "ipv6");
+
+ json_object_object_add(json_path, "nexthop",
+ json_nexthop);
+ }
break;
default:
- vty_out(vty, "?");
+ if (!json_path) {
+ vty_out(vty, "?");
+ } else {
+ json_object_string_add(json_nexthop, "Error",
+ "Unsupported address-family");
+ }
}
char *str = esi2str(&(attr->evpn_overlay.eth_s_id));
- vty_out(vty, "%s", str);
+ if (!json_path)
+ vty_out(vty, "%s", str);
+ else
+ json_object_string_add(json_overlay, "esi", str);
+
XFREE(MTYPE_TMP, str);
if (is_evpn_prefix_ipaddr_v4((struct prefix_evpn *)p)) {
- vty_out(vty, "/%s",
- inet_ntoa(attr->evpn_overlay.gw_ip.ipv4));
+ inet_ntop(AF_INET, &(attr->evpn_overlay.gw_ip.ipv4),
+ buf, BUFSIZ);
} else if (is_evpn_prefix_ipaddr_v6((struct prefix_evpn *)p)) {
- vty_out(vty, "/%s",
- inet_ntop(AF_INET6,
- &(attr->evpn_overlay.gw_ip.ipv6), buf,
- BUFSIZ));
+ inet_ntop(AF_INET6, &(attr->evpn_overlay.gw_ip.ipv6),
+ buf, BUFSIZ);
}
+
+ if (!json_path)
+ vty_out(vty, "/%s", buf);
+ else
+ json_object_string_add(json_overlay, "gw", buf);
+
if (attr->ecommunity) {
char *mac = NULL;
struct ecommunity_val *routermac = ecommunity_lookup(
@@ -7588,13 +7627,25 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p,
if (routermac)
mac = ecom_mac2str((char *)routermac->val);
if (mac) {
- vty_out(vty, "/%s", (char *)mac);
+ if (!json_path) {
+ vty_out(vty, "/%s", (char *)mac);
+ } else {
+ json_object_string_add(json_overlay,
+ "rmac", mac);
+ }
XFREE(MTYPE_TMP, mac);
}
}
- vty_out(vty, "\n");
- }
+ if (!json_path) {
+ vty_out(vty, "\n");
+ } else {
+ json_object_object_add(json_path, "overlay",
+ json_overlay);
+
+ json_object_array_add(json_paths, json_path);
+ }
+ }
}
/* dampening route */