]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: fix missing VRF autocompletions 5064/head
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 24 Sep 2019 16:51:46 +0000 (19:51 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Thu, 26 Sep 2019 09:17:15 +0000 (12:17 +0300)
Current autocompletion works only for simple "vrf NAME" case.

This commit expands it also for the following cases:
- "nexthop-vrf NAME" in staticd
- usage of $varname in many daemons

All daemons are updated to use single varname "$vrf_name".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
bfdd/bfdd_vty.c
doc/user/bfd.rst
lib/if.c
lib/nexthop_group.c
lib/vrf.c
pbrd/pbr_vty.c
sharpd/sharp_vty.c
zebra/interface.c

index a211f34219af8ef8a99ef05b5b634b30b20b1675..0898ffd957f0787d2d13cf19b26bd11793a4175d 100644 (file)
@@ -516,7 +516,7 @@ DEFPY(bfd_show_peers, bfd_show_peers_cmd, "show bfd [vrf <NAME>] peers [json]",
 }
 
 DEFPY(bfd_show_peer, bfd_show_peer_cmd,
-      "show bfd [vrf <NAME$vrfname>] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]",
+      "show bfd [vrf <NAME$vrf_name>] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]",
       SHOW_STR
       "Bidirection Forwarding Detection\n"
       VRF_CMD_HELP_STR
@@ -528,7 +528,7 @@ DEFPY(bfd_show_peer, bfd_show_peer_cmd,
 
        /* Look up the BFD peer. */
        bs = _find_peer_or_error(vty, argc, argv, label, peer_str, local_str,
-                                ifname, vrfname);
+                                ifname, vrf_name);
        if (bs == NULL)
                return CMD_WARNING_CONFIG_FAILED;
 
@@ -543,7 +543,7 @@ DEFPY(bfd_show_peer, bfd_show_peer_cmd,
 }
 
 DEFPY(bfd_show_peer_counters, bfd_show_peer_counters_cmd,
-      "show bfd [vrf <NAME$vrfname>] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> counters [json]",
+      "show bfd [vrf <NAME$vrf_name>] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> counters [json]",
       SHOW_STR
       "Bidirection Forwarding Detection\n"
       VRF_CMD_HELP_STR
@@ -564,7 +564,7 @@ DEFPY(bfd_show_peer_counters, bfd_show_peer_counters_cmd,
 
        /* Look up the BFD peer. */
        bs = _find_peer_or_error(vty, argc, argv, label, peer_str, local_str,
-                                ifname, vrfname);
+                                ifname, vrf_name);
        if (bs == NULL)
                return CMD_WARNING_CONFIG_FAILED;
 
index 32ca5707d2451dcb2043ed234f7cc2599e35df44..525a31d4867e2cdc5341b0b98ec4fdc39bb5d50a 100644 (file)
@@ -79,8 +79,8 @@ BFDd Commands
 
    `vrf` selects which domain we want to use.
 
-.. index:: no peer <A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrfname}]
-.. clicmd:: no peer <A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrfname}]
+.. index:: no peer <A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrf_name}]
+.. clicmd:: no peer <A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrf_name}]
 
     Stops and removes the selected peer.
 
@@ -89,8 +89,8 @@ BFDd Commands
 
     Show all configured BFD peers information and current status.
 
-.. index:: show bfd [vrf NAME$vrfname] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]
-.. clicmd:: show bfd [vrf NAME$vrfname] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]
+.. index:: show bfd [vrf NAME$vrf_name] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]
+.. clicmd:: show bfd [vrf NAME$vrf_name] peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname}]> [json]
 
     Show status for a specific BFD peer.
 
index 5f92327562e490a18af3807a675b57acd4986f1b..c5d90c83ab08d026a3454b1f25e0adda77695300 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1199,7 +1199,7 @@ void if_link_params_free(struct interface *ifp)
  */
 DEFPY_NOSH (interface,
        interface_cmd,
-       "interface IFNAME [vrf NAME$vrfname]",
+       "interface IFNAME [vrf NAME$vrf_name]",
        "Select an interface to configure\n"
        "Interface's name\n"
        VRF_CMD_HELP_STR)
@@ -1209,8 +1209,8 @@ DEFPY_NOSH (interface,
        struct interface *ifp;
        int ret;
 
-       if (!vrfname)
-               vrfname = VRF_DEFAULT_NAME;
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
 
        /*
         * This command requires special handling to maintain backward
@@ -1219,7 +1219,7 @@ DEFPY_NOSH (interface,
         * interface is found, then a new one should be created on the default
         * VRF.
         */
-       VRF_GET_ID(vrf_id, vrfname, false);
+       VRF_GET_ID(vrf_id, vrf_name, false);
        ifp = if_lookup_by_name_all_vrf(ifname);
        if (ifp && ifp->vrf_id != vrf_id) {
                struct vrf *vrf;
@@ -1230,24 +1230,24 @@ DEFPY_NOSH (interface,
                 */
                if (vrf_id != VRF_DEFAULT) {
                        vty_out(vty, "%% interface %s not in %s vrf\n", ifname,
-                               vrfname);
+                               vrf_name);
                        return CMD_WARNING_CONFIG_FAILED;
                }
 
                /*
                 * Special case 2: a VRF name was *not* specified, and the found
                 * interface is associated to a VRF other than the default one.
-                * Update vrf_id and vrfname to account for that.
+                * Update vrf_id and vrf_name to account for that.
                 */
                vrf = vrf_lookup_by_id(ifp->vrf_id);
                assert(vrf);
                vrf_id = ifp->vrf_id;
-               vrfname = vrf->name;
+               vrf_name = vrf->name;
        }
 
        snprintf(xpath_list, sizeof(xpath_list),
                 "/frr-interface:lib/interface[name='%s'][vrf='%s']", ifname,
-                vrfname);
+                vrf_name);
 
        nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
        ret = nb_cli_apply_changes(vty, xpath_list);
@@ -1270,20 +1270,20 @@ DEFPY_NOSH (interface,
 
 DEFPY (no_interface,
        no_interface_cmd,
-       "no interface IFNAME [vrf NAME$vrfname]",
+       "no interface IFNAME [vrf NAME$vrf_name]",
        NO_STR
        "Delete a pseudo interface's configuration\n"
        "Interface's name\n"
        VRF_CMD_HELP_STR)
 {
-       if (!vrfname)
-               vrfname = VRF_DEFAULT_NAME;
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
 
        nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
 
        return nb_cli_apply_changes(
                vty, "/frr-interface:lib/interface[name='%s'][vrf='%s']",
-               ifname, vrfname);
+               ifname, vrf_name);
 }
 
 static void cli_show_interface(struct vty *vty, struct lyd_node *dnode,
index abe2096cecbd17e57bef2e8f325bae1e98fb9ce8..9564321d3822e3205d1905af5cdb605e0f4576f6 100644 (file)
@@ -475,7 +475,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
          <A.B.C.D|X:X::X:X>$addr [INTERFACE$intf]\
          |INTERFACE$intf\
        >\
-       [nexthop-vrf NAME$name]",
+       [nexthop-vrf NAME$vrf_name]",
       NO_STR
       "Specify one of the nexthops in this ECMP group\n"
       "v4 Address\n"
@@ -490,7 +490,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
        struct nexthop *nh;
        bool legal;
 
-       legal = nexthop_group_parse_nexthop(&nhop, addr, intf, name);
+       legal = nexthop_group_parse_nexthop(&nhop, addr, intf, vrf_name);
 
        if (nhop.type == NEXTHOP_TYPE_IPV6
            && IN6_IS_ADDR_LINKLOCAL(&nhop.gate.ipv6)) {
@@ -502,7 +502,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
        nh = nexthop_exists(&nhgc->nhg, &nhop);
 
        if (no) {
-               nexthop_group_unsave_nhop(nhgc, name, addr, intf);
+               nexthop_group_unsave_nhop(nhgc, vrf_name, addr, intf);
                if (nh) {
                        _nexthop_del(&nhgc->nhg, nh);
 
@@ -520,7 +520,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
                        _nexthop_add(&nhgc->nhg.nexthop, nh);
                }
 
-               nexthop_group_save_nhop(nhgc, name, addr, intf);
+               nexthop_group_save_nhop(nhgc, vrf_name, addr, intf);
 
                if (legal && nhg_hooks.add_nexthop)
                        nhg_hooks.add_nexthop(nhgc, nh);
index 575e96bae4540ca5fd024a3ee323185b461ca41f..b00f5be023396706eb3097a0fd69c8f1ed276c23 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -467,6 +467,14 @@ static const struct cmd_variable_handler vrf_var_handlers[] = {
                .varname = "vrf",
                .completions = vrf_autocomplete,
        },
+       {
+               .varname = "vrf_name",
+               .completions = vrf_autocomplete,
+       },
+       {
+               .varname = "nexthop_vrf",
+               .completions = vrf_autocomplete,
+       },
        {.completions = NULL},
 };
 
index 5e7addc9d2b0e10bde2cb014a677d3ecafd22d4c..a6e764bbb016ca33d4ae43782c53e1eabf29cd6d 100644 (file)
@@ -254,7 +254,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
          <A.B.C.D|X:X::X:X>$addr [INTERFACE$intf]\
          |INTERFACE$intf\
        >\
-        [nexthop-vrf NAME$name]",
+        [nexthop-vrf NAME$vrf_name]",
       NO_STR
       "Set for the PBR-MAP\n"
       "Specify one of the nexthops in this map\n"
@@ -276,13 +276,13 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       if (name)
-               vrf = vrf_lookup_by_name(name);
+       if (vrf_name)
+               vrf = vrf_lookup_by_name(vrf_name);
        else
                vrf = vrf_lookup_by_id(VRF_DEFAULT);
 
        if (!vrf) {
-               vty_out(vty, "Specified: %s is non-existent\n", name);
+               vty_out(vty, "Specified: %s is non-existent\n", vrf_name);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
index 60cfb2e486d88a5afd77b53a59581fadcccaa8fd..486ccf6bfeb9b58f4dd6346b8873edec410fd313 100644 (file)
@@ -39,7 +39,7 @@
 #endif
 
 DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
-      "sharp watch [vrf NAME$name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop>  [connected$connected]",
+      "sharp watch [vrf NAME$vrf_name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop>  [connected$connected]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
       "The vrf we would like to watch if non-default\n"
@@ -54,12 +54,12 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
        struct prefix p;
        bool type_import;
 
-       if (!name)
-               name = VRF_DEFAULT_NAME;
-       vrf = vrf_lookup_by_name(name);
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
+       vrf = vrf_lookup_by_name(vrf_name);
        if (!vrf) {
                vty_out(vty, "The vrf NAME specified: %s does not exist\n",
-                       name);
+                       vrf_name);
                return CMD_WARNING;
        }
 
@@ -83,7 +83,7 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
 }
 
 DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
-      "sharp watch [vrf NAME$name] <nexthop$n A.B.C.D$nhop|import$import A.B.C.D/M$inhop> [connected$connected]",
+      "sharp watch [vrf NAME$vrf_name] <nexthop$n A.B.C.D$nhop|import$import A.B.C.D/M$inhop> [connected$connected]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
       "The vrf we would like to watch if non-default\n"
@@ -98,12 +98,12 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
        struct prefix p;
        bool type_import;
 
-       if (!name)
-               name = VRF_DEFAULT_NAME;
-       vrf = vrf_lookup_by_name(name);
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
+       vrf = vrf_lookup_by_name(vrf_name);
        if (!vrf) {
                vty_out(vty, "The vrf NAME specified: %s does not exist\n",
-                       name);
+                       vrf_name);
                return CMD_WARNING;
        }
 
@@ -162,7 +162,7 @@ DEFPY (install_routes_data_dump,
 
 DEFPY (install_routes,
        install_routes_cmd,
-       "sharp install routes [vrf NAME$name] <A.B.C.D$start4|X:X::X:X$start6> <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NHGNAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
+       "sharp install routes [vrf NAME$vrf_name] <A.B.C.D$start4|X:X::X:X$start6> <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NHGNAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
        "Sharp routing Protocol\n"
        "install some routes\n"
        "Routes to install\n"
@@ -209,13 +209,13 @@ DEFPY (install_routes,
        }
        sg.r.orig_prefix = prefix;
 
-       if (!name)
-               name = VRF_DEFAULT_NAME;
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
 
-       vrf = vrf_lookup_by_name(name);
+       vrf = vrf_lookup_by_name(vrf_name);
        if (!vrf) {
                vty_out(vty, "The vrf NAME specified: %s does not exist\n",
-                       name);
+                       vrf_name);
                return CMD_WARNING;
        }
 
@@ -252,7 +252,7 @@ DEFPY (install_routes,
 }
 
 DEFPY(vrf_label, vrf_label_cmd,
-      "sharp label <ip$ipv4|ipv6$ipv6> vrf NAME$name label (0-100000)$label",
+      "sharp label <ip$ipv4|ipv6$ipv6> vrf NAME$vrf_name label (0-100000)$label",
       "Sharp Routing Protocol\n"
       "Give a vrf a label\n"
       "Pop and forward for IPv4\n"
@@ -264,10 +264,10 @@ DEFPY(vrf_label, vrf_label_cmd,
        struct vrf *vrf;
        afi_t afi = (ipv4) ? AFI_IP : AFI_IP6;
 
-       if (strcmp(name, "default") == 0)
+       if (strcmp(vrf_name, "default") == 0)
                vrf = vrf_lookup_by_id(VRF_DEFAULT);
        else
-               vrf = vrf_lookup_by_name(name);
+               vrf = vrf_lookup_by_name(vrf_name);
 
        if (!vrf) {
                vty_out(vty, "Unable to find vrf you silly head");
@@ -283,7 +283,7 @@ DEFPY(vrf_label, vrf_label_cmd,
 
 DEFPY (remove_routes,
        remove_routes_cmd,
-       "sharp remove routes [vrf NAME$name] <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance]",
+       "sharp remove routes [vrf NAME$vrf_name] <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp Routing Protocol\n"
        "Remove some routes\n"
        "Routes to remove\n"
@@ -314,10 +314,10 @@ DEFPY (remove_routes,
                prefix.u.prefix6 = start6;
        }
 
-       vrf = vrf_lookup_by_name(name ? name : VRF_DEFAULT_NAME);
+       vrf = vrf_lookup_by_name(vrf_name ? vrf_name : VRF_DEFAULT_NAME);
        if (!vrf) {
                vty_out(vty, "The vrf NAME specified: %s does not exist\n",
-                       name ? name : VRF_DEFAULT_NAME);
+                       vrf_name ? vrf_name : VRF_DEFAULT_NAME);
                return CMD_WARNING;
        }
 
index 6486c01430c39bc02c1c8e8538053903c4064558..f1527cdd508695279667d2084538830a16d05260 100644 (file)
@@ -1556,7 +1556,7 @@ struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1};
 #endif
 /* Show all interfaces to vty. */
 DEFPY(show_interface, show_interface_cmd,
-      "show interface [vrf NAME$name] [brief$brief]",
+      "show interface [vrf NAME$vrf_name] [brief$brief]",
       SHOW_STR
       "Interface status and configuration\n"
       VRF_CMD_HELP_STR
@@ -1568,8 +1568,8 @@ DEFPY(show_interface, show_interface_cmd,
 
        interface_update_stats();
 
-       if (name)
-               VRF_GET_ID(vrf_id, name, false);
+       if (vrf_name)
+               VRF_GET_ID(vrf_id, vrf_name, false);
 
        /* All interface print. */
        vrf = vrf_lookup_by_id(vrf_id);