]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Adopt `show bgp detail-routes` command for L3VPN outputs as well 12515/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 20 Dec 2022 11:01:52 +0000 (13:01 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 20 Dec 2022 11:13:34 +0000 (13:13 +0200)
```
unet> sh pe2 vtysh -c 'sh ip bgp ipv4 vpn detail-routes'
BGP table version is 4, local router ID is 10.10.10.20, vrf id 0
Default local pref 100, local AS 65001
Route Distinguisher: 192.168.2.2:2
BGP routing table entry for 192.168.2.2:2:10.0.0.0/24, version 1
not allocated
Paths: (1 available, best #1)
  Not advertised to any peer
  65000
    192.168.2.1 from 0.0.0.0 (10.10.10.20) vrf RED(4) announce-nh-self
      Origin incomplete, metric 0, localpref 50, valid, sourced, local, best (First path received)
      Extended Community: RT:192.168.2.2:2
      Originator: 10.10.10.20
      Remote label: 2222
      Last update: Tue Dec 20 13:01:20 2022
BGP routing table entry for 192.168.2.2:2:172.16.255.1/32, version 2
not allocated
Paths: (1 available, best #1)
  Not advertised to any peer
  65000
    192.168.2.1 from 0.0.0.0 (10.10.10.20) vrf RED(4) announce-nh-self
      Origin incomplete, localpref 50, valid, sourced, local, best (First path received)
      Extended Community: RT:192.168.2.2:2
      Originator: 10.10.10.20
      Remote label: 2222
      Last update: Tue Dec 20 13:01:20 2022
BGP routing table entry for 192.168.2.2:2:192.168.1.0/24, version 3
not allocated
Paths: (1 available, best #1)
  Not advertised to any peer
  65000
    192.168.2.1 from 0.0.0.0 (10.10.10.20) vrf RED(4) announce-nh-self
      Origin incomplete, localpref 50, valid, sourced, local, best (First path received)
      Extended Community: RT:192.168.2.2:2
      Originator: 10.10.10.20
      Remote label: 2222
      Last update: Tue Dec 20 13:01:20 2022
BGP routing table entry for 192.168.2.2:2:192.168.2.0/24, version 4
not allocated
Paths: (1 available, best #1)
  Not advertised to any peer
  65000
    192.168.2.1 from 0.0.0.0 (10.10.10.20) vrf RED(4) announce-nh-self
      Origin incomplete, metric 0, localpref 50, valid, sourced, local, best (First path received)
      Extended Community: RT:192.168.2.2:2
      Originator: 10.10.10.20
      Remote label: 2222
      Last update: Tue Dec 20 13:01:20 2022

Displayed  4 routes and 4 total paths
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_mplsvpn.c
bgpd/bgp_route.c
bgpd/bgp_route.h

index 0270695c2f1b974502229ca079d4cc748bf9e10d..c92d678eff846cde48f81d57120cab0479b0b2c6 100644 (file)
@@ -2821,6 +2821,10 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
 {
        struct bgp *bgp;
        struct bgp_table *table;
+       uint16_t show_flags = 0;
+
+       if (use_json)
+               SET_FLAG(show_flags, BGP_SHOW_OPT_JSON);
 
        bgp = bgp_get_default();
        if (bgp == NULL) {
@@ -2832,7 +2836,7 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
        }
        table = bgp->rib[afi][SAFI_MPLS_VPN];
        return bgp_show_table_rd(vty, bgp, SAFI_MPLS_VPN, table, prd, type,
-                                output_arg, use_json);
+                                output_arg, show_flags);
 }
 
 DEFUN (show_bgp_ip_vpn_all_rd,
index 8f6a1ff223d7c7db3e0c211380ce0a194a8929bd..e4f1a31fa695837acd49f2c1510b4ca10c9c6394 100644 (file)
@@ -11601,10 +11601,12 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                                   AFI_IP, safi, use_json,
                                                   json_paths);
                        else {
-                               if (detail_routes) {
-                                       const struct prefix_rd *prd;
+                               if (detail_routes || detail_json) {
+                                       const struct prefix_rd *prd = NULL;
 
-                                       prd = bgp_rd_from_dest(dest, safi);
+                                       if (dest->pdest)
+                                               prd = bgp_rd_from_dest(
+                                                       dest->pdest, safi);
 
                                        if (!use_json)
                                                route_vty_out_detail_header(
@@ -11615,8 +11617,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                                        NULL);
 
                                        route_vty_out_detail(
-                                               vty, bgp, dest,
-                                               bgp_dest_get_prefix(dest), pi,
+                                               vty, bgp, dest, dest_p, pi,
                                                family2afi(dest_p->family),
                                                safi, RPKI_NOT_BEING_USED,
                                                json_paths);
@@ -11705,7 +11706,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
 
 int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
                      struct bgp_table *table, struct prefix_rd *prd_match,
-                     enum bgp_show_type type, void *output_arg, bool use_json)
+                     enum bgp_show_type type, void *output_arg,
+                     uint16_t show_flags)
 {
        struct bgp_dest *dest, *next;
        unsigned long output_cum = 0;
@@ -11713,13 +11715,10 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
        unsigned long json_header_depth = 0;
        struct bgp_table *itable;
        bool show_msg;
-       uint16_t show_flags = 0;
+       bool use_json = !!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
 
        show_msg = (!use_json && type == bgp_show_type_normal);
 
-       if (use_json)
-               SET_FLAG(show_flags, BGP_SHOW_OPT_JSON);
-
        for (dest = bgp_table_top(table); dest; dest = next) {
                const struct prefix *dest_p = bgp_dest_get_prefix(dest);
 
@@ -11785,7 +11784,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
        /* use MPLS and ENCAP specific shows until they are merged */
        if (safi == SAFI_MPLS_VPN) {
                return bgp_show_table_rd(vty, bgp, safi, table, NULL, type,
-                                        output_arg, use_json);
+                                        output_arg, show_flags);
        }
 
        if (safi == SAFI_FLOWSPEC && type == bgp_show_type_detail) {
index 63dd69f805924aca5add4a50387e560c18b33f2e..152a8a0a7250e4b73459db2b07d8da903331546b 100644 (file)
@@ -866,7 +866,7 @@ extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
 extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
                             struct bgp_table *table, struct prefix_rd *prd,
                             enum bgp_show_type type, void *output_arg,
-                            bool use_json);
+                            uint16_t show_flags);
 extern void bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi);
 extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
                                       uint8_t type, uint8_t stype,