Skip to content

Commit 9a1aae2

Browse files
committed
bgpd: Show the real prefix for show bgp detail
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>
1 parent 4f4728b commit 9a1aae2

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

bgpd/bgp_route.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11248,6 +11248,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
1124811248
bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
1124911249
bool wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE);
1125011250
bool all = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL);
11251+
bool detail = CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL);
1125111252

1125211253
if (output_cum && *output_cum != 0)
1125311254
header = false;
@@ -11281,8 +11282,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
1128111282
}
1128211283

1128311284
/* Check for 'json detail', where we need header output once per dest */
11284-
if (use_json && CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL) &&
11285-
type != bgp_show_type_dampend_paths &&
11285+
if (use_json && detail && type != bgp_show_type_dampend_paths &&
1128611286
type != bgp_show_type_damp_neighbor &&
1128711287
type != bgp_show_type_flap_statistics &&
1128811288
type != bgp_show_type_flap_neighbor)
@@ -11545,17 +11545,19 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
1154511545
vty_out(vty, "Default local pref %u, ",
1154611546
bgp->default_local_pref);
1154711547
vty_out(vty, "local AS %u\n", bgp->as);
11548-
vty_out(vty, BGP_SHOW_SCODE_HEADER);
11549-
vty_out(vty, BGP_SHOW_NCODE_HEADER);
11550-
vty_out(vty, BGP_SHOW_OCODE_HEADER);
11551-
vty_out(vty, BGP_SHOW_RPKI_HEADER);
11548+
if (!detail) {
11549+
vty_out(vty, BGP_SHOW_SCODE_HEADER);
11550+
vty_out(vty, BGP_SHOW_NCODE_HEADER);
11551+
vty_out(vty, BGP_SHOW_OCODE_HEADER);
11552+
vty_out(vty, BGP_SHOW_RPKI_HEADER);
11553+
}
1155211554
if (type == bgp_show_type_dampend_paths
1155311555
|| type == bgp_show_type_damp_neighbor)
1155411556
vty_out(vty, BGP_SHOW_DAMP_HEADER);
1155511557
else if (type == bgp_show_type_flap_statistics
1155611558
|| type == bgp_show_type_flap_neighbor)
1155711559
vty_out(vty, BGP_SHOW_FLAP_HEADER);
11558-
else
11560+
else if (!detail)
1155911561
vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE
1156011562
: BGP_SHOW_HEADER));
1156111563
header = false;
@@ -11598,16 +11600,29 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
1159811600
AFI_IP, safi, use_json,
1159911601
json_paths);
1160011602
else {
11601-
if (CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL))
11603+
if (detail) {
11604+
const struct prefix_rd *prd;
11605+
11606+
prd = bgp_rd_from_dest(dest, safi);
11607+
11608+
if (!use_json)
11609+
route_vty_out_detail_header(
11610+
vty, bgp, dest,
11611+
bgp_dest_get_prefix(
11612+
dest),
11613+
prd, table->afi, safi,
11614+
NULL);
11615+
1160211616
route_vty_out_detail(
1160311617
vty, bgp, dest,
1160411618
bgp_dest_get_prefix(dest), pi,
1160511619
family2afi(dest_p->family),
1160611620
safi, RPKI_NOT_BEING_USED,
1160711621
json_paths);
11608-
else
11622+
} else {
1160911623
route_vty_out(vty, dest_p, pi, display,
1161011624
safi, json_paths, wide);
11625+
}
1161111626
}
1161211627
display++;
1161311628
}

0 commit comments

Comments
 (0)