Skip to content

Commit

Permalink
bgpd: Reduce the nesting level for show_adj_route()
Browse files Browse the repository at this point in the history
Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Nov 13, 2024
1 parent 98ca49e commit 6cd813e
Showing 1 changed file with 41 additions and 58 deletions.
99 changes: 41 additions & 58 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6cd813e

Please sign in to comment.