]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Show neighbor advertised paths including addpath
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 13 Nov 2024 09:47:33 +0000 (11:47 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 13 Nov 2024 11:32:28 +0000 (13:32 +0200)
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 <donatas@opensourcerouting.org>
bgpd/bgp_route.c

index 988be7f4de4c2c4d7b6d155f74d07396d5658372..5290cb74bf2182f2fed692e569b68c5d8f7d5e59 100644 (file)
@@ -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) {
@@ -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)++;