diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index dc6e0d33c2ce..8a0c6e10d609 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -766,7 +766,7 @@ static void bgp_evpn_show_routes_mac_ip_es(struct vty *vty, esi_t *esi, if (detail) route_vty_out_detail(vty, bgp, bd, bgp_dest_get_prefix(bd), pi, AFI_L2VPN, SAFI_EVPN, RPKI_NOT_BEING_USED, - json_path, NULL); + json_path, NULL, 0); else route_vty_out(vty, &bd->rn->p, pi, 0, SAFI_EVPN, json_path, false); @@ -893,7 +893,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, if (detail) route_vty_out_detail(vty, bgp, dest, &tmp_p, pi, AFI_L2VPN, SAFI_EVPN, RPKI_NOT_BEING_USED, json_path, - NULL); + NULL, 0); else route_vty_out(vty, &tmp_p, pi, 0, SAFI_EVPN, @@ -2569,7 +2569,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp, json_path = json_object_new_array(); route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi, safi, - RPKI_NOT_BEING_USED, json_path, NULL); + RPKI_NOT_BEING_USED, json_path, NULL, 0); if (json) json_object_array_add(json_paths, json_path); @@ -2697,7 +2697,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp, } route_vty_out_detail(vty, bgp, dest, (struct prefix *)&tmp_p, pi, afi, safi, - RPKI_NOT_BEING_USED, json_path, NULL); + RPKI_NOT_BEING_USED, json_path, NULL, 0); if (json) json_object_array_add(json_paths, json_path); @@ -2807,7 +2807,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, json_path = json_object_new_array(); route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi, safi, - RPKI_NOT_BEING_USED, json_path, NULL); + RPKI_NOT_BEING_USED, json_path, NULL, 0); if (json) json_object_array_add(json_paths, json_path); @@ -2919,7 +2919,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, json_path = json_object_new_array(); route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi, - safi, RPKI_NOT_BEING_USED, json_path, NULL); + safi, RPKI_NOT_BEING_USED, json_path, NULL, 0); if (json) json_object_array_add(json_paths, json_path); @@ -3055,7 +3055,7 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp, json_path = json_object_new_array(); route_vty_out_detail(vty, bgp, dest, p, pi, AFI_L2VPN, SAFI_EVPN, - RPKI_NOT_BEING_USED, json_path, NULL); + RPKI_NOT_BEING_USED, json_path, NULL, 0); if (json) json_object_array_add(json_paths, json_path); @@ -3227,7 +3227,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, AFI_L2VPN, SAFI_EVPN, - RPKI_NOT_BEING_USED, json_path, NULL); + RPKI_NOT_BEING_USED, json_path, NULL, + 0); } else route_vty_out(vty, p, pi, 0, SAFI_EVPN, json_path, false); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f27f0b97c089..b970b43891de 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10743,7 +10743,7 @@ static void route_vty_out_detail_es_info(struct vty *vty, void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, const struct prefix *p, struct bgp_path_info *path, afi_t afi, safi_t safi, enum rpki_states rpki_curr_state, json_object *json_paths, - struct attr *pattr) + struct attr *pattr, uint16_t show_opts) { char buf[INET6_ADDRSTRLEN]; char vni_buf[30] = {}; @@ -11764,6 +11764,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, llgr_remaining); } + /* Display internal data if asked */ + if (CHECK_FLAG(show_opts, BGP_SHOW_OPT_INTERNAL_DATA)) { + if (!json_paths) { + vty_out(vty, " net: %p, path: %p, pathext: %p, attr: %p\n", path->net, + path, path->extra, attr); + vty_out(vty, " flags net: 0x%u, path: 0x%u, attr: 0x%" PRIu64 "\n", + path->net->flags, path->flags, attr->flag); + } + } + /* Output some debug about internal state of the dest flags */ if (json_paths) { if (CHECK_FLAG(bn->flags, BGP_NODE_PROCESS_SCHEDULED)) @@ -12195,7 +12205,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa route_vty_out_detail(vty, bgp, dest, dest_p, pi, family2afi(dest_p->family), safi, - rpki_curr_state, json_paths, NULL); + rpki_curr_state, json_paths, NULL, + show_flags); } else { route_vty_out(vty, dest_p, pi, display, safi, json_paths, wide); @@ -12713,7 +12724,8 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, static void bgp_show_path_info(const struct prefix_rd *pfx_rd, struct bgp_dest *bgp_node, struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, json_object *json, enum bgp_path_type pathtype, int *display, - enum rpki_states rpki_target_state, struct attr *attr) + enum rpki_states rpki_target_state, struct attr *attr, + uint16_t show_opts) { struct bgp_path_info *pi; int header = 1; @@ -12757,7 +12769,8 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd, struct bgp_dest * && (CHECK_FLAG(pi->flags, BGP_PATH_MULTIPATH) || CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)))) route_vty_out_detail(vty, bgp, bgp_node, bgp_dest_get_prefix(bgp_node), pi, - afi, safi, rpki_curr_state, json_paths, attr); + afi, safi, rpki_curr_state, json_paths, attr, + show_opts); } if (json && json_paths) { @@ -12794,12 +12807,11 @@ const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest, } /* Display specified route of BGP table. */ -static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, - struct bgp_table *rib, const char *ip_str, - afi_t afi, safi_t safi, - enum rpki_states rpki_target_state, - struct prefix_rd *prd, int prefix_check, - enum bgp_path_type pathtype, bool use_json) +static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, struct bgp_table *rib, + const char *ip_str, afi_t afi, safi_t safi, + enum rpki_states rpki_target_state, struct prefix_rd *prd, + int prefix_check, enum bgp_path_type pathtype, bool use_json, + uint16_t show_opts) { int ret; int display = 0; @@ -12844,8 +12856,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, continue; } - bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi, - json, pathtype, &display, rpki_target_state, NULL); + bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi, json, + pathtype, &display, rpki_target_state, NULL, show_opts); bgp_dest_unlock_node(rm); } @@ -12904,8 +12916,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, rm = longest_pfx; bgp_dest_lock_node(rm); - bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi, - json, pathtype, &display, rpki_target_state, NULL); + bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi, json, + pathtype, &display, rpki_target_state, NULL, show_opts); bgp_dest_unlock_node(rm); } @@ -12932,7 +12944,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, if (!prefix_check || dest_p->prefixlen == match.prefixlen) { bgp_show_path_info(NULL, dest, vty, bgp, afi, safi, json, pathtype, - &display, rpki_target_state, NULL); + &display, rpki_target_state, NULL, show_opts); } bgp_dest_unlock_node(dest); @@ -12952,10 +12964,10 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, } /* Display specified route of Main RIB */ -static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, - afi_t afi, safi_t safi, struct prefix_rd *prd, - int prefix_check, enum bgp_path_type pathtype, - enum rpki_states rpki_target_state, bool use_json) +static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, afi_t afi, + safi_t safi, struct prefix_rd *prd, int prefix_check, + enum bgp_path_type pathtype, enum rpki_states rpki_target_state, + bool use_json, uint16_t show_opts) { if (!bgp) { bgp = bgp_get_default(); @@ -12972,9 +12984,9 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, if (safi == SAFI_LABELED_UNICAST) safi = SAFI_UNICAST; - return bgp_show_route_in_table(vty, bgp, bgp->rib[afi][safi], ip_str, - afi, safi, rpki_target_state, prd, - prefix_check, pathtype, use_json); + return bgp_show_route_in_table(vty, bgp, bgp->rib[afi][safi], ip_str, afi, safi, + rpki_target_state, prd, prefix_check, pathtype, use_json, + show_opts); } static int bgp_show_lcommunity(struct vty *vty, struct bgp *bgp, int argc, @@ -13336,7 +13348,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, |A.B.C.D/M longer-prefixes\ |X:X::X:X/M longer-prefixes\ |"BGP_SELF_ORIG_CMD_STR"\ - |detail-routes$detail_routes\ + |detail-routes$detail_routes [internal$internal]\ ] [json$uj [detail$detail_json] | wide$wide]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR BGP_SAFI_WITH_LABEL_HELP_STR @@ -13387,6 +13399,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, "Display route and more specific routes\n" BGP_SELF_ORIG_HELP_STR "Display detailed version of all routes\n" + "Display detailed version of all routes including internal data\n" JSON_STR "Display detailed version of JSON output\n" "Increase table width for longer prefixes\n") @@ -13415,6 +13428,9 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, if (detail_routes) SET_FLAG(show_flags, BGP_SHOW_OPT_ROUTES_DETAIL); + if (internal) + SET_FLAG(show_flags, BGP_SHOW_OPT_INTERNAL_DATA); + /* [ [all]] */ if (all) { SET_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL); @@ -13703,7 +13719,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, DEFUN (show_ip_bgp_route, show_ip_bgp_route_cmd, - "show [ip] bgp [ VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [] [rpki ] [json]", + "show [ip] bgp [ VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [internal] [] [rpki ] [json]", SHOW_STR IP_STR BGP_STR @@ -13714,6 +13730,7 @@ DEFUN (show_ip_bgp_route, "IPv4 prefix\n" "Network in the BGP routing table to display\n" "IPv6 prefix\n" + "Display internal data additionally\n" "Display only the bestpath\n" "Display only multipaths\n" "Display only paths that match the specified rpki state\n" @@ -13730,6 +13747,7 @@ DEFUN (show_ip_bgp_route, struct bgp *bgp = NULL; enum bgp_path_type path_type; bool uj = use_json(argc, argv); + uint16_t show_opts = 0; int idx = 0; @@ -13767,6 +13785,10 @@ DEFUN (show_ip_bgp_route, prefix = argv[idx]->arg; + /* Display internal data also */ + if (argv_find(argv, argc, "internal", &idx)) + SET_FLAG(show_opts, BGP_SHOW_OPT_INTERNAL_DATA); + /* [] */ if (argv_find(argv, argc, "bestpath", &idx)) path_type = BGP_PATH_SHOW_BESTPATH; @@ -13775,8 +13797,8 @@ DEFUN (show_ip_bgp_route, else path_type = BGP_PATH_SHOW_ALL; - return bgp_show_route(vty, bgp, prefix, afi, safi, NULL, prefix_check, - path_type, RPKI_NOT_BEING_USED, uj); + return bgp_show_route(vty, bgp, prefix, afi, safi, NULL, prefix_check, path_type, + RPKI_NOT_BEING_USED, uj, show_opts); } DEFUN (show_ip_bgp_regexp, @@ -14634,9 +14656,8 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix, return CMD_WARNING; } - return bgp_show_route(vty, bgp, network, AFI_IP, SAFI_MPLS_VPN, NULL, 0, - BGP_PATH_SHOW_ALL, RPKI_NOT_BEING_USED, - use_json(argc, argv)); + return bgp_show_route(vty, bgp, network, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_SHOW_ALL, + RPKI_NOT_BEING_USED, use_json(argc, argv), 0); } #endif /* KEEP_OLD_VPN_COMMANDS */ @@ -14668,9 +14689,8 @@ DEFUN (show_bgp_l2vpn_evpn_route_prefix, vty_out(vty, "Unable to figure out Network\n"); return CMD_WARNING; } - return bgp_show_route(vty, NULL, network, AFI_L2VPN, SAFI_EVPN, NULL, - prefix_check, BGP_PATH_SHOW_ALL, - RPKI_NOT_BEING_USED, use_json(argc, argv)); + return bgp_show_route(vty, NULL, network, AFI_L2VPN, SAFI_EVPN, NULL, prefix_check, + BGP_PATH_SHOW_ALL, RPKI_NOT_BEING_USED, use_json(argc, argv), 0); } static void show_adj_route_header(struct vty *vty, struct peer *peer, @@ -14826,8 +14846,9 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, 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, NULL); + bgp_show_path_info(NULL /* prefix_rd */, dest, vty, bgp, afi, safi, + json_net, BGP_PATH_SHOW_ALL, &display, + RPKI_NOT_BEING_USED, NULL, show_flags); if (use_json) json_object_object_addf(json_ar, json_net, "%pFX", rn_p); @@ -14963,7 +14984,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, pass_in = dest; bgp_show_path_info(NULL, pass_in, vty, bgp, afi, safi, json_net, BGP_PATH_SHOW_ALL, &display, - RPKI_NOT_BEING_USED, NULL); + RPKI_NOT_BEING_USED, NULL, show_flags); if (use_json) json_object_object_addf( json_ar, json_net, @@ -15015,7 +15036,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, bgp_show_path_info(NULL, dest, vty, bgp, afi, safi, json_net, BGP_PATH_SHOW_ALL, &display, RPKI_NOT_BEING_USED, - adj->attr); + adj->attr, show_flags); if (use_json) json_object_object_addf(json_ar, json_net, "%pFX", rn_p); @@ -15061,9 +15082,10 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, 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_BESTPATH, - &display, RPKI_NOT_BEING_USED, NULL); + bgp_show_path_info(NULL /* prefix_rd */, dest, vty, bgp, + afi, safi, json_net, + BGP_PATH_SHOW_BESTPATH, &display, + RPKI_NOT_BEING_USED, NULL, show_flags); if (use_json) json_object_object_addf( json_ar, json_net, @@ -15705,10 +15727,9 @@ DEFUN (show_bgp_afi_vpn_rd_route, } if (!strcmp(argv[5]->arg, "all")) - return bgp_show_route(vty, NULL, argv[6]->arg, afi, - SAFI_MPLS_VPN, NULL, 0, BGP_PATH_SHOW_ALL, - RPKI_NOT_BEING_USED, - use_json(argc, argv)); + return bgp_show_route(vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, NULL, 0, + BGP_PATH_SHOW_ALL, RPKI_NOT_BEING_USED, use_json(argc, argv), + 0); ret = str2prefix_rd(argv[5]->arg, &prd); if (!ret) { @@ -15716,9 +15737,8 @@ DEFUN (show_bgp_afi_vpn_rd_route, return CMD_WARNING; } - return bgp_show_route(vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, - 0, BGP_PATH_SHOW_ALL, RPKI_NOT_BEING_USED, - use_json(argc, argv)); + return bgp_show_route(vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, 0, + BGP_PATH_SHOW_ALL, RPKI_NOT_BEING_USED, use_json(argc, argv), 0); } static struct bgp_distance *bgp_distance_new(void) diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 7f4a3b918cde..51f977cddeb8 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -752,6 +752,7 @@ DECLARE_HOOK(bgp_route_update, #define BGP_SHOW_OPT_JSON_DETAIL (1 << 7) #define BGP_SHOW_OPT_TERSE (1 << 8) #define BGP_SHOW_OPT_ROUTES_DETAIL (1 << 9) +#define BGP_SHOW_OPT_INTERNAL_DATA (1 << 10) /* Prototypes. */ extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi, @@ -968,7 +969,7 @@ extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, const struct prefix *p, struct bgp_path_info *path, afi_t afi, safi_t safi, enum rpki_states, json_object *json_paths, - struct attr *attr); + struct attr *attr, uint16_t show_opts); extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_table *table, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index d07bb6503555..3bf21a6ef5b9 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -2932,7 +2932,7 @@ BGP Extended Communities in Route Map ``CO:COLOR`` This is a format to define colors value. ``CO`` part is always 00 (default), - it can be used to support the requirements of Color-Only steering when using + it can be used to support the requirements of Color-Only steering when using a Null Endpoint in the SR-TE Policy as specified in Section 8.8 of [RFC9256]. The below shows in detail what the different combinations of ``CO`` bits can match on to for the purpose of determining what type of SR-TE Policy Tunnel @@ -4630,7 +4630,7 @@ incoming/outgoing directions. If ``json`` option is specified, output is displayed in JSON format. -.. clicmd:: show [ip] bgp [afi] [safi] [all] detail-routes +.. clicmd:: show [ip] bgp [afi] [safi] [all] detail-routes [internal] Display the detailed version of all routes. The same format as using ``show [ip] bgp [afi] [safi] PREFIX``, but for the whole BGP table. @@ -4638,6 +4638,9 @@ incoming/outgoing directions. If ``all`` option is specified, ``ip`` keyword is ignored and, routes displayed for all AFIs and SAFIs. + ``internal`` option is used to display internal data additionally. JSON + output is not supported with this option. + If ``afi`` is specified, with ``all`` option, routes will be displayed for each SAFI in the selected AFI.