Skip to content

Commit

Permalink
bgpd: Show the real prefix for show bgp detail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ton31337 committed Dec 20, 2022
1 parent 4f4728b commit 9a1aae2
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
}
Expand Down

0 comments on commit 9a1aae2

Please sign in to comment.