From: Louis Scalbert Date: Tue, 17 Jan 2023 16:02:07 +0000 (+0100) Subject: bgpd: add show bgp link-state link-state commands X-Git-Tag: base_9.1~37^2~7 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f11f67033fe20f0b4aeb6c885949abb060324749;p=mirror%2Ffrr.git bgpd: add show bgp link-state link-state commands Add the "show bgp link-state link-state" following commands: > r3# show bgp link-state link-state ? > > all Display the entries for all address families > detail-routes Display detailed version of all routes > json JavaScript Object Notation > neighbors Detailed information on TCP and BGP neighbor connections > regexp Display routes matching the AS path regular expression > summary Summary of BGP neighbor status > version Display prefixes with matching version numbers > wide Increase table width for longer prefixes Signed-off-by: Louis Scalbert --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5364853d4b..5b9a36121e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -12983,6 +12983,62 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, return CMD_SUCCESS; } +/* BGP route print out function */ +DEFPY (show_ip_bgp_link_state, show_ip_bgp_link_state_cmd, + "show [ip] bgp [ VIEWVRFNAME] link-state link-state\ + [all$all]\ + [version (1-4294967295)\ + |detail-routes$detail_routes\ + ] [json$uj [detail$detail_json] | wide$wide]", + SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR + BGP_AF_STR + BGP_AF_MODIFIER_STR + "Display the entries for all address families\n" + "Display prefixes with matching version numbers\n" + "Version number and above\n" + "Display detailed version of all routes\n" + JSON_STR + "Display detailed version of JSON output\n" + "Increase table width for longer prefixes\n") +{ + afi_t afi = AFI_LINKSTATE; + safi_t safi = SAFI_LINKSTATE; + enum bgp_show_type sh_type = bgp_show_type_normal; + void *output_arg = NULL; + struct bgp *bgp = NULL; + int idx = 0; + uint16_t show_flags = 0; + enum rpki_states rpki_target_state = RPKI_NOT_BEING_USED; + + if (uj) { + argc--; + SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); + } + + if (detail_json) + SET_FLAG(show_flags, BGP_SHOW_OPT_JSON_DETAIL); + + if (detail_routes) + SET_FLAG(show_flags, BGP_SHOW_OPT_ROUTES_DETAIL); + + if (wide) + SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); + + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + + /* Display prefixes with matching version numbers */ + if (argv_find(argv, argc, "version", &idx)) { + sh_type = bgp_show_type_prefix_version; + output_arg = argv[idx + 1]->arg; + } + + return bgp_show(vty, bgp, afi, safi, sh_type, output_arg, show_flags, + rpki_target_state); +} + 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]", @@ -13063,13 +13119,13 @@ DEFUN (show_ip_bgp_route, DEFUN (show_ip_bgp_regexp, show_ip_bgp_regexp_cmd, - "show [ip] bgp [ VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] regexp REGEX [json]", + "show [ip] bgp [ VIEWVRFNAME] ["BGP_AFI_WITH_LS_CMD_STR" ["BGP_SAFI_WITH_LABEL_LS_CMD_STR"]] regexp REGEX [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - BGP_AFI_HELP_STR - BGP_SAFI_WITH_LABEL_HELP_STR + BGP_AFI_WITH_LS_HELP_STR + BGP_SAFI_WITH_LABEL_LS_HELP_STR "Display routes matching the AS path regular expression\n" "A regular-expression (1234567890_^|[,{}() ]$*+.?-\\) to match the BGP AS paths\n" JSON_STR) @@ -14610,13 +14666,13 @@ DEFPY (show_ip_bgp_instance_neighbor_bestpath_route, 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] [$prefix | detail$detail] [json$uj | wide$wide]", + "show [ip] bgp [ VIEWVRFNAME] [" BGP_AFI_WITH_LS_CMD_STR " [" BGP_SAFI_WITH_LABEL_LS_CMD_STR "]] [all$all] neighbors [route-map RMAP_NAME$route_map] [$prefix | 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 + BGP_AFI_WITH_LS_HELP_STR + BGP_SAFI_WITH_LABEL_LS_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" @@ -14670,6 +14726,12 @@ DEFPY(show_ip_bgp_instance_neighbor_advertised_route, if (!idx) return CMD_WARNING; + if (afi == AFI_LINKSTATE && prefix_str) { + vty_out(vty, + "The prefix option cannot be selected with AFI Link-State\n"); + return CMD_WARNING; + } + /* neighbors */ argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; @@ -15892,6 +15954,7 @@ void bgp_route_init(void) install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_statistics_cmd); install_element(VIEW_NODE, &show_ip_bgp_dampening_params_cmd); install_element(VIEW_NODE, &show_ip_bgp_cmd); + install_element(VIEW_NODE, &show_ip_bgp_link_state_cmd); install_element(VIEW_NODE, &show_ip_bgp_route_cmd); install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element(VIEW_NODE, &show_ip_bgp_statistics_all_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 03d734d62c..2249393c16 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -12374,11 +12374,11 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, /* `show [ip] bgp summary' commands. */ DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, - "show [ip] bgp [ VIEWVRFNAME] [" BGP_AFI_CMD_STR - " [" BGP_SAFI_WITH_LABEL_CMD_STR + "show [ip] bgp [ VIEWVRFNAME] [" BGP_AFI_WITH_LS_CMD_STR + " [" BGP_SAFI_WITH_LABEL_LS_CMD_STR "]] [all$all] summary [established|failed] [|remote-as >] [terse] [wide] [json$uj]", - SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_WITH_LABEL_HELP_STR + SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_WITH_LS_HELP_STR + BGP_SAFI_WITH_LABEL_LS_HELP_STR "Display the entries for all address families\n" "Summary of BGP neighbor status\n" "Show only sessions in Established state\n" diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index a105b6de3f..955752f85a 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -17,6 +17,8 @@ struct bgp; #define BGP_AF_MODIFIER_STR "Address Family modifier\n" #define BGP_AFI_CMD_STR "" #define BGP_AFI_HELP_STR BGP_AF_STR BGP_AF_STR +#define BGP_AFI_WITH_LS_CMD_STR "" +#define BGP_AFI_WITH_LS_HELP_STR BGP_AF_STR BGP_AF_STR BGP_AF_STR #define BGP_SAFI_CMD_STR "" #define BGP_SAFI_HELP_STR \ BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR @@ -28,6 +30,12 @@ struct bgp; BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR \ BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR +#define BGP_SAFI_WITH_LABEL_LS_CMD_STR \ + "" +#define BGP_SAFI_WITH_LABEL_LS_HELP_STR \ + BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR \ + BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR BGP_AF_MODIFIER_STR + #define BGP_SELF_ORIG_CMD_STR "self-originate" #define BGP_SELF_ORIG_HELP_STR "Display only self-originated routes\n"