]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Add VRF sub-mode
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 2 Feb 2016 12:34:29 +0000 (04:34 -0800)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 2 Feb 2016 12:34:29 +0000 (04:34 -0800)
Add the VRF submode to vtysh.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
vtysh/extract.pl.in
vtysh/vtysh.c
vtysh/vtysh.h
vtysh/vtysh_config.c

index da0e4563e1165f80bde89de405a67bbd6b2d31af..cee63190beb4ecb0334656a6d12eb63f8cec08e4 100755 (executable)
@@ -32,6 +32,8 @@ EOF
 
 $ignore{'"interface IFNAME"'} = "ignore";
 $ignore{'"interface IFNAME " "vrf <0-65535>"'} = "ignore";
+$ignore{'"interface IFNAME " "vrf NAME"'} = "ignore";
+$ignore{'"vrf NAME"'} = "ignore";
 $ignore{'"ip vrf NAME"'} = "ignore";
 $ignore{'"router rip"'} = "ignore";
 $ignore{'"router ripng"'} = "ignore";
@@ -41,7 +43,7 @@ $ignore{'"router ospf6"'} = "ignore";
 $ignore{'"router babel"'} = "ignore";
 $ignore{'"router bgp"'} = "ignore";
 $ignore{'"router bgp " "<1-4294967295>"'} = "ignore";
-$ignore{'"router bgp " "<1-4294967295>" " view WORD"'} = "ignore";
+$ignore{'"router bgp " "<1-4294967295>" " (view|vrf) WORD"'} = "ignore";
 $ignore{'"router isis WORD"'} = "ignore";
 $ignore{'"router zebra"'} = "ignore";
 $ignore{'"address-family ipv4"'} = "ignore";
index 5786c68c9bdb18fb2bcf022f440645dc4a8f3ee9..d0c7104945644276bb31319b39a99c1bd84cdd50 100644 (file)
@@ -922,6 +922,12 @@ static struct cmd_node interface_node =
   "%s(config-if)# ",
 };
 
+static struct cmd_node vrf_node =
+{
+  VRF_NODE,
+  "%s(config-vrf)# ",
+};
+
 static struct cmd_node rmap_node =
 {
   RMAP_NODE,
@@ -1051,12 +1057,12 @@ ALIAS_SH (VTYSH_BGPD,
 ALIAS_SH (VTYSH_BGPD,
          router_bgp,
          router_bgp_view_cmd,
-         "router bgp " CMD_AS_RANGE " view WORD",
+         "router bgp " CMD_AS_RANGE " (view|vrf) WORD",
          ROUTER_STR
          BGP_STR
          AS_STR
-         "BGP view\n"
-         "view name\n")
+         "BGP view\nBGP VRF\n"
+         "View/VRF name\n")
 
 DEFUNSH (VTYSH_BGPD,
         address_family_vpnv4,
@@ -1308,6 +1314,7 @@ vtysh_exit (struct vty *vty)
       vty->node = ENABLE_NODE;
       break;
     case INTERFACE_NODE:
+    case VRF_NODE:
     case ZEBRA_NODE:
     case BGP_NODE:
     case RIP_NODE:
@@ -1511,8 +1518,8 @@ ALIAS_SH (VTYSH_ZEBRA,
         vtysh_interface_vrf_cmd,
         "interface IFNAME " VRF_CMD_STR,
         "Select an interface to configure\n"
-        "Interface's name\n"
-        VRF_CMD_HELP_STR)
+         "Interface's name\n"
+         VRF_CMD_HELP_STR)
 
 /* TODO Implement "no interface command in isisd. */
 DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
@@ -1530,6 +1537,38 @@ DEFSH (VTYSH_ZEBRA,
        "Interface's name\n"
        VRF_CMD_HELP_STR)
 
+DEFUNSH (VTYSH_VRF,
+        vtysh_vrf,
+        vtysh_vrf_cmd,
+        "vrf NAME",
+        "Select a VRF to configure\n"
+        "VRF's name\n")
+{
+  vty->node = VRF_NODE;
+  return CMD_SUCCESS;
+}
+
+DEFSH (VTYSH_ZEBRA,
+       vtysh_no_vrf_cmd,
+       "no vrf NAME",
+       NO_STR
+       "Delete a pseudo vrf's configuration\n"
+       "VRF's name\n")
+
+DEFUNSH (VTYSH_VRF,
+        vtysh_exit_vrf,
+        vtysh_exit_vrf_cmd,
+        "exit",
+        "Exit current mode and down to previous mode\n")
+{
+  return vtysh_exit (vty);
+}
+
+ALIAS (vtysh_exit_vrf,
+       vtysh_quit_vrf_cmd,
+       "quit",
+       "Exit current mode and down to previous mode\n")
+
 /* TODO Implement interface description commands in ripngd, ospf6d
  * and isisd. */
 DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
@@ -2703,6 +2742,7 @@ vtysh_init_vty (void)
   install_node (&bgp_node, NULL);
   install_node (&rip_node, NULL);
   install_node (&interface_node, NULL);
+  install_node (&vrf_node, NULL);
   install_node (&rmap_node, NULL);
   install_node (&zebra_node, NULL);
   install_node (&bgp_vpnv4_node, NULL);
@@ -2729,6 +2769,7 @@ vtysh_init_vty (void)
   vtysh_install_default (BGP_NODE);
   vtysh_install_default (RIP_NODE);
   vtysh_install_default (INTERFACE_NODE);
+  vtysh_install_default (VRF_NODE);
   vtysh_install_default (RMAP_NODE);
   vtysh_install_default (ZEBRA_NODE);
   vtysh_install_default (BGP_VPNV4_NODE);
@@ -2812,6 +2853,11 @@ vtysh_init_vty (void)
   install_element (INTERFACE_NODE, &vtysh_end_all_cmd);
   install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd);
   install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd);
+
+  install_element (VRF_NODE, &vtysh_end_all_cmd);
+  install_element (VRF_NODE, &vtysh_exit_vrf_cmd);
+  install_element (VRF_NODE, &vtysh_quit_vrf_cmd);
+
   install_element (CONFIG_NODE, &router_rip_cmd);
 #ifdef HAVE_IPV6
   install_element (CONFIG_NODE, &router_ripng_cmd);
@@ -2856,6 +2902,9 @@ vtysh_init_vty (void)
   install_element (ENABLE_NODE, &vtysh_write_file_cmd);
   install_element (ENABLE_NODE, &vtysh_write_cmd);
 
+  install_element (CONFIG_NODE, &vtysh_vrf_cmd);
+  install_element (CONFIG_NODE, &vtysh_no_vrf_cmd);
+
   /* "write terminal" command. */
   install_element (ENABLE_NODE, &vtysh_write_terminal_cmd);
   install_element (ENABLE_NODE, &vtysh_write_terminal_daemon_cmd);
index 36128eed03f243403c050c3b0820ee37b0de1222..6126afab7a4fa182a0549897274b46e0b3b14c7a 100644 (file)
@@ -33,6 +33,7 @@
 #define VTYSH_ALL        VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_BABELD
 #define VTYSH_RMAP       VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_BABELD
 #define VTYSH_INTERFACE          VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_BABELD
+#define VTYSH_VRF        VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_BABELD //Pending: see if all other components are to be added.
 
 /* vtysh local configuration file. */
 #define VTYSH_DEFAULT_CONFIG "vtysh.conf"
index d8a568f7697833e2d70fa1d8f63f1c97553b06dc..2fe08f10dcc6ef629a3ee32048d41d4ce42fb901 100644 (file)
@@ -184,20 +184,9 @@ vtysh_config_parse_line (const char *line)
       /* Store line to current configuration. */
       if (config)
        {
-         if (strncmp (line, " address-family vpnv4",
-             strlen (" address-family vpnv4")) == 0)
-           config = config_get (BGP_VPNV4_NODE, line);
-         else if (strncmp (line, " address-family ipv4 multicast",
-                  strlen (" address-family ipv4 multicast")) == 0)
-           config = config_get (BGP_IPV4M_NODE, line);
-         else if (strncmp (line, " address-family ipv4", strlen (" address-family ipv4")) == 0 ||
-                  strncmp (line, " address-family ipv4 unicast", strlen (" address-family ipv4 unicast")) == 0)
-           config = config_get (BGP_IPV4_NODE, line);
-         else if (strncmp (line, " address-family ipv6", strlen (" address-family ipv6")) == 0 ||
-                  strncmp (line, " address-family ipv6 unicast", strlen (" address-family ipv6 unicast")) == 0)
-           config = config_get (BGP_IPV6_NODE, line);
-         else if (config->index == RMAP_NODE ||
+         if (config->index == RMAP_NODE ||
                   config->index == INTERFACE_NODE ||
+                  config->index == VRF_NODE ||
                   config->index == VTY_NODE)
            config_add_line_uniq (config->line, line);
          else
@@ -209,6 +198,8 @@ vtysh_config_parse_line (const char *line)
     default:
       if (strncmp (line, "interface", strlen ("interface")) == 0)
        config = config_get (INTERFACE_NODE, line);
+      else if (strncmp (line, "vrf", strlen ("vrf")) == 0)
+       config = config_get (VRF_NODE, line);
       else if (strncmp (line, "router-id", strlen ("router-id")) == 0)
        config = config_get (ZEBRA_NODE, line);
       else if (strncmp (line, "router rip", strlen ("router rip")) == 0)