Merge pull request #5011 from karamalla0406/evpn_cli_json

bgpd: Fixed 'show bgp l2vpn evpn json' to display all routes
This commit is contained in:
Russ White 2019-09-30 18:30:28 -04:00 committed by GitHub
commit 44cde8a39f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1012,6 +1012,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
int header = 1; int header = 1;
char rd_str[BUFSIZ]; char rd_str[BUFSIZ];
char buf[BUFSIZ]; char buf[BUFSIZ];
int no_display;
unsigned long output_count = 0; unsigned long output_count = 0;
unsigned long total_count = 0; unsigned long total_count = 0;
@ -1049,6 +1050,11 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
tbl_ver = table->version; tbl_ver = table->version;
for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) { for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) {
pi = bgp_node_get_bgp_path_info(rm);
if (pi == NULL)
continue;
no_display = 0;
if (use_json) { if (use_json) {
json_array = json_object_new_array(); json_array = json_object_new_array();
json_prefix_info = json_object_new_object(); json_prefix_info = json_object_new_object();
@ -1065,8 +1071,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
json_nroute = json_object_new_object(); json_nroute = json_object_new_object();
} }
for (pi = bgp_node_get_bgp_path_info(rm); pi; for (; pi; pi = pi->next) {
pi = pi->next) {
total_count++; total_count++;
if (type == bgp_show_type_neighbor) { if (type == bgp_show_type_neighbor) {
struct peer *peer = output_arg; struct peer *peer = output_arg;
@ -1101,16 +1106,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
vty_out(vty, vty_out(vty,
V4_HEADER_OVERLAY); V4_HEADER_OVERLAY);
else { else {
vty_out(vty, bgp_evpn_show_route_header(vty, bgp, tbl_ver, NULL);
"BGP table version is %" PRIu64 ", local router ID is %s\n",
tbl_ver,
inet_ntoa(
bgp->router_id));
vty_out(vty,
"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty,
"Origin codes: i - IGP, e - EGP, ? - incomplete\n\n");
vty_out(vty, V4_HEADER);
} }
} }
header = 0; header = 0;
@ -1172,18 +1168,23 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
} }
if (option == SHOW_DISPLAY_TAGS) if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag(vty, &rm->p, pi, 0, route_vty_out_tag(vty, &rm->p, pi,
SAFI_EVPN, no_display, SAFI_EVPN,
json_array); json_array);
else if (option == SHOW_DISPLAY_OVERLAY) else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay(vty, &rm->p, pi, route_vty_out_overlay(vty, &rm->p, pi,
0, json_array); no_display,
json_array);
else else
route_vty_out(vty, &rm->p, pi, 0, route_vty_out(vty, &rm->p, pi,
SAFI_EVPN, json_array); no_display, SAFI_EVPN,
output_count++; json_array);
no_display = 1;
} }
rd_header = 0;
if (no_display)
output_count++;
if (use_json) { if (use_json) {
json_object_object_add(json_prefix_info, json_object_object_add(json_prefix_info,
"paths", json_array); "paths", json_array);