summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-04-05 02:51:02 +0200
committerGitHub <noreply@github.com>2018-04-05 02:51:02 +0200
commitd2fe1ab8133f7bee99dd50eafe2051d1689b168a (patch)
tree213bf598397c6f7305c82d465564899008aed8d3
parentMerge pull request #1979 from LabNConsulting/working/master/bgp-nht-labels (diff)
parentlib, vtysh: vrf walkup bugfix (diff)
downloadfrr-d2fe1ab8133f7bee99dd50eafe2051d1689b168a.tar.xz
frr-d2fe1ab8133f7bee99dd50eafe2051d1689b168a.zip
Merge pull request #1998 from qlyoung/fix-vrf-keyword-walkup
lib, vtysh: vrf walkup bugfix
-rw-r--r--lib/vrf.c12
-rw-r--r--vtysh/vtysh.c16
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index 02ac160ab..1ed96cd0a 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -642,6 +642,17 @@ int vrf_is_mapped_on_netns(vrf_id_t vrf_id)
}
/* vrf CLI commands */
+DEFUN_NOSH(vrf_exit,
+ vrf_exit_cmd,
+ "exit-vrf",
+ "Exit current mode and down to previous mode\n")
+{
+ /* We have to set vrf context to default vrf */
+ VTY_PUSH_CONTEXT(VRF_NODE, vrf_get(VRF_DEFAULT, VRF_DEFAULT_NAME));
+ vty->node = CONFIG_NODE;
+ return CMD_SUCCESS;
+}
+
DEFUN_NOSH (vrf,
vrf_cmd,
"vrf NAME",
@@ -799,6 +810,7 @@ void vrf_cmd_init(int (*writefunc)(struct vty *vty),
install_element(CONFIG_NODE, &no_vrf_cmd);
install_node(&vrf_node, writefunc);
install_default(VRF_NODE);
+ install_element(VRF_NODE, &vrf_exit_cmd);
if (vrf_is_backend_netns() && ns_have_netns()) {
/* Install NS commands. */
vrf_daemon_privs = daemon_privs;
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index d0751bc1c..14c7c2fed 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -366,6 +366,8 @@ static int vtysh_execute_func(const char *line, int pager)
|| saved_node == BGP_VNC_L2_GROUP_NODE)
&& (tried == 1)) {
vtysh_execute("exit-vnc");
+ } else if (saved_node == VRF_NODE && (tried == 1)) {
+ vtysh_execute("exit-vrf");
} else if ((saved_node == KEYCHAIN_KEY_NODE
|| saved_node == LDP_PSEUDOWIRE_NODE
|| saved_node == LDP_IPV4_IFACE_NODE
@@ -643,6 +645,8 @@ int vtysh_mark_file(const char *filename)
} else if ((prev_node == BGP_EVPN_VNI_NODE)
&& (tried == 1)) {
fprintf(outputfile, "exit-vni\n");
+ } else if (prev_node == VRF_NODE) {
+ fprintf(outputfile, "exit-vrf\n");
} else if ((prev_node == KEYCHAIN_KEY_NODE)
&& (tried == 1)) {
fprintf(outputfile, "exit\n");
@@ -1653,8 +1657,16 @@ DEFUNSH(VTYSH_BGPD, exit_vnc_config, exit_vnc_config_cmd, "exit-vnc",
return CMD_SUCCESS;
}
+DEFUNSH(VTYSH_PIMD|VTYSH_ZEBRA, exit_vrf_config, exit_vrf_config_cmd, "exit-vrf",
+ "Exit from VRF configuration mode\n")
+{
+ if (vty->node == VRF_NODE)
+ vty->node = CONFIG_NODE;
+ return CMD_SUCCESS;
+}
+
DEFUNSH(VTYSH_BGPD, exit_vrf_policy, exit_vrf_policy_cmd, "exit-vrf-policy",
- "Exit from VRF configuration mode\n")
+ "Exit from VRF policy configuration mode\n")
{
if (vty->node == BGP_VRF_POLICY_NODE)
vty->node = BGP_NODE;
@@ -3394,6 +3406,8 @@ void vtysh_init_vty(void)
install_element(ENABLE_NODE, &vtysh_show_running_config_cmd);
install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd);
+ install_element(VRF_NODE, &exit_vrf_config_cmd);
+
install_element(CONFIG_NODE, &vtysh_vrf_cmd);
install_element(CONFIG_NODE, &vtysh_no_vrf_cmd);