Skip to content

Commit

Permalink
bgpd: Show neighbor advertised paths including addpath
Browse files Browse the repository at this point in the history
Without the patch only the best path is displayed.

With the patch, display all paths including addpaths, but only for non-JSON
output to avoid breaking existing output.

E.g.:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *   172.16.16.254/32 192.168.2.4              0             0 65004 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
 *   192.168.2.0/24   192.168.2.4              0             0 65004 ?
```

Before it was:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
```

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Nov 13, 2024
1 parent 5456bc5 commit 98ca49e
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -14675,6 +14675,8 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
}

for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
struct bgp_path_info *bpi = NULL;

if (type == bgp_show_adj_route_received
|| type == bgp_show_adj_route_filtered) {
for (ain = dest->adj_in; ain; ain = ain->next) {
Expand Down Expand Up @@ -14816,16 +14818,27 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
json_net,
"%pFX",
rn_p);
} else
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);
}
}
(*output_count)++;
} else {
(*filtered_count)++;
Expand Down

0 comments on commit 98ca49e

Please sign in to comment.