Skip to content

Commit

Permalink
bgpd: Adopt show bgp detail-routes command for L3VPN outputs as well
Browse files Browse the repository at this point in the history
```
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>
  • Loading branch information
ton31337 committed Dec 20, 2022
1 parent 81dcd88 commit 27bb782
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
6 changes: 5 additions & 1 deletion bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
21 changes: 10 additions & 11 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -11705,21 +11706,19 @@ 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;
unsigned long total_cum = 0;
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);

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 27bb782

Please sign in to comment.