mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 08:57:29 +00:00
*: fix missing VRF autocompletions
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>
This commit is contained in:
parent
7d7828cf25
commit
e429a2a0cc
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
24
lib/if.c
24
lib/if.c
@ -1196,7 +1196,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)
|
||||
@ -1206,8 +1206,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
|
||||
@ -1216,7 +1216,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;
|
||||
@ -1227,24 +1227,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);
|
||||
@ -1267,20 +1267,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,
|
||||
|
@ -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);
|
||||
|
@ -472,6 +472,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},
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user