From: Lakshman Krishnamoorthy Date: Sat, 11 May 2019 16:33:10 +0000 (-0700) Subject: bgpd: evpn json cli bug fix X-Git-Tag: base_7.2~349^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0ac811af6074f6815514d231ff71ad5a0fb23611;p=matthieu%2Ffrr.git bgpd: evpn json cli bug fix Bug: If there are 2 different prefixes under an rd, the output of "show bgp l2vpn evpn json" would print only one of the prefixes. RCA: prefix info was added to the json_object once per rd. Hence, prefix and rd were added just once, as the loop iterated over all the prefixes and paths. This is related to my earlier commit that went in via PR 4283: https://github.com/FRRouting/frr/pull/4283 Signed-off-by: Lakshman Krishnamoorthy --- diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 1bd153639b..4296604c4a 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1048,7 +1048,20 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, rd_header = 1; 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)) { + if (use_json) { + json_array = json_object_new_array(); + json_prefix_info = json_object_new_object(); + + json_object_string_add(json_prefix_info, + "prefix", bgp_evpn_route2str( + (struct prefix_evpn *)&rm->p, buf, + BUFSIZ)); + + json_object_int_add(json_prefix_info, + "prefixLen", rm->p.prefixlen); + } + for (pi = bgp_node_get_bgp_path_info(rm); pi; pi = pi->next) { total_count++; @@ -1121,10 +1134,6 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, if (use_json) { json_nroute = json_object_new_object(); - json_prefix_info = - json_object_new_object(); - json_array = - json_object_new_array(); if (type == RD_TYPE_AS || type == RD_TYPE_AS4) sprintf(rd_str, "%u:%d", @@ -1140,18 +1149,6 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, "rd", rd_str); - json_object_string_add( - json_prefix_info, - "prefix", - bgp_evpn_route2str( - (struct prefix_evpn *) - &rm->p, buf, BUFSIZ)); - - json_object_int_add( - json_prefix_info, - "prefixLen", - rm->p.prefixlen); - } else { vty_out(vty, "Route Distinguisher: "); @@ -1174,6 +1171,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } rd_header = 0; } + if (option == SHOW_DISPLAY_TAGS) route_vty_out_tag(vty, &rm->p, pi, 0, SAFI_EVPN, @@ -1186,14 +1184,16 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, SAFI_EVPN, json_array); output_count++; } + if (use_json) { + json_object_object_add(json_prefix_info, + "paths", json_array); + json_object_object_add(json_nroute, buf, + json_prefix_info); + } + } - if (use_json) { - json_object_object_add(json_prefix_info, "paths", - json_array); - json_object_object_add(json_nroute, buf, - json_prefix_info); + if (use_json) json_object_object_add(json, rd_str, json_nroute); - } } if (use_json) {