]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Show the real prefix for `show bgp detail`
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 13 Dec 2022 20:30:15 +0000 (22:30 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 20 Dec 2022 10:19:37 +0000 (12:19 +0200)
Absolutely not possible to read the output and even distinguish the prefix
we are looking for.

Before:

```
donatas-pc# show ip bgp detail
BGP table version is 12, local router ID is 192.168.10.17, vrf id 0
Default local pref 100, local AS 65002
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
  65001
    2a02:4780:abc::2 from 2a02:4780:abc::2 (200.200.200.202)
    (fe80::a00:27ff:fe5e:d19e) (used)
      Origin incomplete, metric 0, valid, external, multipath
      Last update: Tue Dec 13 22:53:16 2022
  65001
    192.168.10.124 from 192.168.10.124 (200.200.200.202)
      Origin incomplete, metric 0, valid, external, otc 65001, multipath, best (Neighbor IP)
      Last update: Tue Dec 13 22:53:16 2022
  65001
    2a02:4780:abc::2 from 2a02:4780:abc::2 (200.200.200.202)
    (fe80::a00:27ff:fe5e:d19e) (used)
      Origin IGP, metric 0, valid, external, multipath
      Last update: Tue Dec 13 22:53:16 2022
  65001
    192.168.10.124 from 192.168.10.124 (200.200.200.202)
      Origin IGP, metric 0, valid, external, otc 65001, multipath, best (Neighbor IP)
      Last update: Tue Dec 13 22:53:16 2022
```

After:

```
donatas-pc# show ip bgp detail
BGP table version is 12, local router ID is 192.168.10.17, vrf id 0
Default local pref 100, local AS 65002
BGP routing table entry for 10.0.2.0/24, version 1
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  2a02:4780:abc::2
  65001
    2a02:4780:abc::2 from 2a02:4780:abc::2 (200.200.200.202)
    (fe80::a00:27ff:fe5e:d19e) (used)
      Origin incomplete, metric 0, valid, external, multipath
      Last update: Tue Dec 13 22:47:16 2022
BGP routing table entry for 10.0.2.0/24, version 1
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  2a02:4780:abc::2
  65001
    192.168.10.124 from 192.168.10.124 (200.200.200.202)
      Origin incomplete, metric 0, valid, external, otc 65001, multipath, best (Neighbor IP)
      Last update: Tue Dec 13 22:47:16 2022
BGP routing table entry for 10.10.100.0/24, version 2
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  2a02:4780:abc::2
  65001
    2a02:4780:abc::2 from 2a02:4780:abc::2 (200.200.200.202)
    (fe80::a00:27ff:fe5e:d19e) (used)
      Origin IGP, metric 0, valid, external, multipath
      Last update: Tue Dec 13 22:47:16 2022
```

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

index 95493c11f850234005a6ec5051dadda9b9e2ff3e..e300543a37237c931741ca701857fc57a7882ea7 100644 (file)
@@ -11248,6 +11248,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
        bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
        bool wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE);
        bool all = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL);
+       bool detail = CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL);
 
        if (output_cum && *output_cum != 0)
                header = false;
@@ -11281,8 +11282,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
        }
 
        /* Check for 'json detail', where we need header output once per dest */
-       if (use_json && CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL) &&
-           type != bgp_show_type_dampend_paths &&
+       if (use_json && detail && type != bgp_show_type_dampend_paths &&
            type != bgp_show_type_damp_neighbor &&
            type != bgp_show_type_flap_statistics &&
            type != bgp_show_type_flap_neighbor)
@@ -11545,17 +11545,19 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                vty_out(vty, "Default local pref %u, ",
                                        bgp->default_local_pref);
                                vty_out(vty, "local AS %u\n", bgp->as);
-                               vty_out(vty, BGP_SHOW_SCODE_HEADER);
-                               vty_out(vty, BGP_SHOW_NCODE_HEADER);
-                               vty_out(vty, BGP_SHOW_OCODE_HEADER);
-                               vty_out(vty, BGP_SHOW_RPKI_HEADER);
+                               if (!detail) {
+                                       vty_out(vty, BGP_SHOW_SCODE_HEADER);
+                                       vty_out(vty, BGP_SHOW_NCODE_HEADER);
+                                       vty_out(vty, BGP_SHOW_OCODE_HEADER);
+                                       vty_out(vty, BGP_SHOW_RPKI_HEADER);
+                               }
                                if (type == bgp_show_type_dampend_paths
                                    || type == bgp_show_type_damp_neighbor)
                                        vty_out(vty, BGP_SHOW_DAMP_HEADER);
                                else if (type == bgp_show_type_flap_statistics
                                         || type == bgp_show_type_flap_neighbor)
                                        vty_out(vty, BGP_SHOW_FLAP_HEADER);
-                               else
+                               else if (!detail)
                                        vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE
                                                           : BGP_SHOW_HEADER));
                                header = false;
@@ -11598,16 +11600,29 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
                                                   AFI_IP, safi, use_json,
                                                   json_paths);
                        else {
-                               if (CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL))
+                               if (detail) {
+                                       const struct prefix_rd *prd;
+
+                                       prd = bgp_rd_from_dest(dest, safi);
+
+                                       if (!use_json)
+                                               route_vty_out_detail_header(
+                                                       vty, bgp, dest,
+                                                       bgp_dest_get_prefix(
+                                                               dest),
+                                                       prd, table->afi, safi,
+                                                       NULL);
+
                                        route_vty_out_detail(
                                                vty, bgp, dest,
                                                bgp_dest_get_prefix(dest), pi,
                                                family2afi(dest_p->family),
                                                safi, RPKI_NOT_BEING_USED,
                                                json_paths);
-                               else
+                               } else {
                                        route_vty_out(vty, dest_p, pi, display,
                                                      safi, json_paths, wide);
+                               }
                        }
                        display++;
                }