diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5290cb74bf21..af8738882fc1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -14781,68 +14781,51 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, peer, rn_p, &attr, afi, safi, rmap_name); - if (ret != RMAP_DENY) { - if ((safi == SAFI_MPLS_VPN) - || (safi == SAFI_ENCAP) - || (safi == SAFI_EVPN)) { - if (use_json) - json_object_string_add( - json_ar, - "rd", - rd_str); - else if (show_rd - && rd_str) { - vty_out(vty, - "Route Distinguisher: %s\n", - rd_str); - show_rd = false; - } + if (ret == RMAP_DENY) { + (*filtered_count)++; + bgp_attr_flush(&attr); + continue; + } + + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || + (safi == SAFI_EVPN)) { + if (use_json) + json_object_string_add(json_ar, "rd", + rd_str); + else if (show_rd && rd_str) { + vty_out(vty, "Route Distinguisher: %s\n", + rd_str); + show_rd = false; } - if (detail) { - if (use_json) - json_net = - json_object_new_object(); - bgp_show_path_info( - NULL /* prefix_rd - */ - , - dest, vty, bgp, - afi, safi, - json_net, - BGP_PATH_SHOW_ALL, - &display, - RPKI_NOT_BEING_USED); - if (use_json) - json_object_object_addf( - json_ar, - json_net, - "%pFX", - rn_p); + } + if (detail) { + if (use_json) + json_net = json_object_new_object(); + bgp_show_path_info(NULL, dest, vty, bgp, afi, safi, + json_net, BGP_PATH_SHOW_ALL, + &display, RPKI_NOT_BEING_USED); + if (use_json) + json_object_object_addf(json_ar, json_net, + "%pFX", rn_p); + } else { + /* For JSON output use route_vty_out_tmp() instead + * of route_vty_out(). + * route_vty_out() is path-aware, while + * route_vty_out_tmp() prints only the best path. + * This is for backward compatibility. + */ + if (use_json) { + route_vty_out_tmp(vty, bgp, dest, rn_p, + &attr, safi, + use_json, json_ar, wide); } else { - /* For JSON output use route_vty_out_tmp() instead - * of route_vty_out(). - * route_vty_out() is path-aware, while - * route_vty_out_tmp() prints only the best path. - * This is for backward compatibility. - */ - if (use_json) { - route_vty_out_tmp(vty, bgp, dest, - rn_p, &attr, safi, - use_json, json_ar, - wide); - } else { - for (bpi = bgp_dest_get_bgp_path_info( - dest); - bpi; bpi = bpi->next) - route_vty_out(vty, rn_p, - bpi, 0, safi, - NULL, wide); - } + for (bpi = bgp_dest_get_bgp_path_info(dest); + bpi; bpi = bpi->next) + route_vty_out(vty, rn_p, bpi, 0, + safi, NULL, wide); } - (*output_count)++; - } else { - (*filtered_count)++; } + (*output_count)++; bgp_attr_flush(&attr); }