]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add show bgp link-state link-state commands
authorLouis Scalbert <louis.scalbert@6wind.com>
Tue, 17 Jan 2023 16:02:07 +0000 (17:02 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Mon, 18 Sep 2023 13:06:13 +0000 (15:06 +0200)
Add the "show bgp link-state link-state" following commands:

> r3# show bgp link-state link-state ?
>  <cr>
>  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 <louis.scalbert@6wind.com>
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgp_vty.h

index 5364853d4b7f62c9db861087b34e12caf09c0f7b..5b9a36121e702a3ce4b1e67e8de588be3f82c32f 100644 (file)
@@ -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 [<view|vrf> 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 [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [rpki <valid|invalid|notfound>] [json]",
@@ -13063,13 +13119,13 @@ DEFUN (show_ip_bgp_route,
 
 DEFUN (show_ip_bgp_regexp,
        show_ip_bgp_regexp_cmd,
-       "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] regexp REGEX [json]",
+       "show [ip] bgp [<view|vrf> 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 [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR " [" BGP_SAFI_WITH_LABEL_CMD_STR "]] [all$all] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map RMAP_NAME$route_map] [<A.B.C.D/M|X:X::X:X/M>$prefix | detail$detail] [json$uj | wide$wide]",
+      "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_WITH_LS_CMD_STR " [" BGP_SAFI_WITH_LABEL_LS_CMD_STR "]] [all$all] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map RMAP_NAME$route_map] [<A.B.C.D/M|X:X::X:X/M>$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 <A.B.C.D|X:X::X:X|WORD> */
        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);
index 03d734d62c90c0ac8ae461b2e2d57c5b4f6b29f6..2249393c16cd5c3c1958d410f16a0cf38439caa2 100644 (file)
@@ -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 [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
-      " [" BGP_SAFI_WITH_LABEL_CMD_STR
+      "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_WITH_LS_CMD_STR
+      " [" BGP_SAFI_WITH_LABEL_LS_CMD_STR
       "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <ASNUM|internal|external>>] [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"
index a105b6de3fa9fef3a0f7792dbdf21c34e00e9cce..955752f85a9376786e49e43bf9327100e826abcb 100644 (file)
@@ -17,6 +17,8 @@ struct bgp;
 #define BGP_AF_MODIFIER_STR "Address Family modifier\n"
 #define BGP_AFI_CMD_STR         "<ipv4|ipv6>"
 #define BGP_AFI_HELP_STR BGP_AF_STR BGP_AF_STR
+#define BGP_AFI_WITH_LS_CMD_STR "<ipv4|ipv6|link-state>"
+#define BGP_AFI_WITH_LS_HELP_STR BGP_AF_STR BGP_AF_STR BGP_AF_STR
 #define BGP_SAFI_CMD_STR        "<unicast|multicast|vpn>"
 #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                                         \
+       "<unicast|multicast|vpn|labeled-unicast|flowspec|link-state>"
+#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"