diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5beec2457..a2792b9b7 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -14013,7 +14013,8 @@ static void show_adj_route_header(struct vty *vty, struct peer *peer, struct bgp_table *table, int *header1, int *header2, json_object *json, json_object *json_scode, - json_object *json_ocode, bool wide) + json_object *json_ocode, bool wide, + bool detail) { uint64_t version = table ? table->version : 0; @@ -14047,15 +14048,17 @@ static void show_adj_route_header(struct vty *vty, struct peer *peer, vty_out(vty, "local AS %u\n", peer->change_local_as ? peer->change_local_as : peer->local_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); + } } *header1 = 0; } if (*header2) { - if (!json) + if (!json && !detail) vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE : BGP_SHOW_HEADER)); *header2 = 0; @@ -14079,12 +14082,15 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, struct update_subgroup *subgrp; struct peer_af *paf; bool route_filtered; + bool detail = CHECK_FLAG(show_flags, BGP_SHOW_OPT_ROUTES_DETAIL); bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); bool wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); bool show_rd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_EVPN)) ? true : false; + int display = 0; + json_object *json_net = NULL; bgp = peer->bgp; @@ -14125,10 +14131,12 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, vty_out(vty, "local AS %u\n", peer->change_local_as ? peer->change_local_as : peer->local_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); + } vty_out(vty, "Originating default network %s\n\n", (afi == AFI_IP) ? "0.0.0.0/0" : "::/0"); @@ -14146,7 +14154,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, show_adj_route_header(vty, peer, table, header1, header2, json, json_scode, - json_ocode, wide); + json_ocode, wide, detail); if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) @@ -14190,8 +14198,23 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, && (route_filtered || ret == RMAP_DENY)) (*filtered_count)++; - route_vty_out_tmp(vty, dest, rn_p, &attr, safi, - use_json, json_ar, wide); + if (detail) { + if (use_json) + json_net = + json_object_new_object(); + bgp_show_path_info( + NULL /* prefix_rd */, dest, vty, + bgp, afi, safi, json_net, + BGP_PATH_SHOW_ALL, &display, + RPKI_NOT_BEING_USED); + if (use_json) + json_object_object_addf( + json_ar, json_net, + "%pFX", rn_p); + } else + route_vty_out_tmp(vty, dest, rn_p, + &attr, safi, use_json, + json_ar, wide); bgp_attr_flush(&attr); (*output_count)++; } @@ -14201,10 +14224,10 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, if (paf->peer != peer || !adj->attr) continue; - show_adj_route_header(vty, peer, table, - header1, header2, - json, json_scode, - json_ocode, wide); + show_adj_route_header( + vty, peer, table, header1, + header2, json, json_scode, + json_ocode, wide, detail); const struct prefix *rn_p = bgp_dest_get_prefix(dest); @@ -14231,10 +14254,32 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, show_rd = false; } } - route_vty_out_tmp( - vty, dest, rn_p, &attr, - safi, use_json, json_ar, - wide); + if (detail) { + if (use_json) + json_net = + json_object_new_object(); + bgp_show_path_info( + NULL /* prefix_rd + */ + , + dest, vty, bgp, + afi, safi, + json_net, + BGP_PATH_SHOW_ALL, + &display, + RPKI_NOT_BEING_USED); + if (use_json) + json_object_object_addf( + json_ar, + json_net, + "%pFX", + rn_p); + } else + route_vty_out_tmp( + vty, dest, rn_p, + &attr, safi, + use_json, + json_ar, wide); (*output_count)++; } else { (*filtered_count)++; @@ -14247,7 +14292,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, show_adj_route_header(vty, peer, table, header1, header2, json, json_scode, - json_ocode, wide); + json_ocode, wide, detail); for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) { @@ -14499,27 +14544,28 @@ DEFPY (show_ip_bgp_instance_neighbor_bestpath_route, show_flags); } -DEFPY (show_ip_bgp_instance_neighbor_advertised_route, - show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show [ip] bgp [ VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] neighbors [route-map RMAP_NAME$route_map] [json$uj | wide$wide]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - BGP_AFI_HELP_STR - BGP_SAFI_WITH_LABEL_HELP_STR - "Display the entries for all address families\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on BGP configured interface\n" - "Display the routes advertised to a BGP neighbor\n" - "Display the received routes from neighbor\n" - "Display the filtered routes received from neighbor\n" - "Route-map to modify the attributes\n" - "Name of the route map\n" - JSON_STR - "Increase table width for longer prefixes\n") +DEFPY(show_ip_bgp_instance_neighbor_advertised_route, + show_ip_bgp_instance_neighbor_advertised_route_cmd, + "show [ip] bgp [ VIEWVRFNAME] [" BGP_AFI_CMD_STR " [" BGP_SAFI_WITH_LABEL_CMD_STR "]] [all$all] neighbors [route-map RMAP_NAME$route_map] [detail$detail] [json$uj | wide$wide]", + SHOW_STR + IP_STR + BGP_STR + BGP_INSTANCE_HELP_STR + BGP_AFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR + "Display the entries for all address families\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "Neighbor to display information about\n" + "Neighbor on BGP configured interface\n" + "Display the routes advertised to a BGP neighbor\n" + "Display the received routes from neighbor\n" + "Display the filtered routes received from neighbor\n" + "Route-map to modify the attributes\n" + "Name of the route map\n" + "Display detailed version of routes\n" + JSON_STR + "Increase table width for longer prefixes\n") { afi_t afi = AFI_IP6; safi_t safi = SAFI_UNICAST; @@ -14533,6 +14579,9 @@ DEFPY (show_ip_bgp_instance_neighbor_advertised_route, struct listnode *node; struct bgp *abgp; + if (detail) + SET_FLAG(show_flags, BGP_SHOW_OPT_ROUTES_DETAIL); + if (uj) { argc--; SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 0c51ce2d2..1b17d8e00 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -4199,7 +4199,7 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`. The ``terse`` option can be used in combination with the remote-as, neighbor, failed and established filters, and with the ``wide`` option as well. -.. clicmd:: show bgp [afi] [safi] [neighbor [PEER] [routes|advertised-routes|received-routes] [json] +.. clicmd:: show bgp [afi] [safi] [neighbor [PEER] [routes|advertised-routes|received-routes] [detail] [json] This command shows information on a specific BGP peer of the relevant afi and safi selected. @@ -4214,6 +4214,13 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`. The ``received-routes`` keyword displays all routes belonging to this address-family (prior to inbound policy) that were received by this peer. + If ``detail`` option is specified, the detailed version of all routes + will be displayed. The same format as ``show [ip] bgp [afi] [safi] PREFIX`` + will be used, but for the whole table of received, advertised or filtered + prefixes. + + If ``json`` option is specified, output is displayed in JSON format. + .. clicmd:: show bgp [ VIEWVRFNAME] [afi] [safi] neighbors PEER received prefix-filter [json] Display Address Prefix ORFs received from this peer. @@ -4306,7 +4313,7 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`. If the ``json`` option is specified, output is displayed in JSON format. -.. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [json|wide] +.. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [detail] [json|wide] Display the routes advertised to a BGP neighbor or received routes from neighbor or filtered routes received from neighbor based on the @@ -4323,6 +4330,11 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`. if afi is specified, with ``all`` option, routes will be displayed for each SAFI in the selcted AFI + If ``detail`` option is specified, the detailed version of all routes + will be displayed. The same format as ``show [ip] bgp [afi] [safi] PREFIX`` + will be used, but for the whole table of received, advertised or filtered + prefixes. + If ``json`` option is specified, output is displayed in JSON format. .. clicmd:: show [ip] bgp [afi] [safi] [all] detail-routes