summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 96a5ea9e3..0c4ae3044 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -357,6 +357,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
@@ -632,6 +634,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");
@@ -1613,8 +1617,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;
@@ -3342,6 +3354,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);