]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra, vtysh: configure an interface in non-default VRF
authorFeng Lu <lu.feng@6wind.com>
Fri, 22 May 2015 09:40:00 +0000 (11:40 +0200)
committerVipin Kumar <vipin@cumulusnetworks.com>
Fri, 30 Oct 2015 01:08:53 +0000 (18:08 -0700)
Introduce a new command "interface IFNAME vrf N" to configure an
interface in the non-default VRF.

Till now, only zebra uses this command. Other daemons will install
the command when they support multiple VRFs.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Conflicts:
zebra/interface.c

lib/if.c
lib/if.h
vtysh/extract.pl.in
vtysh/vtysh.c
zebra/interface.c

index 634c79ac4c6011e1d7c2d3671a2f119a3e84db99..b192d48e208f10ae0eb0f3efb80f8149df653cf5 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -712,6 +712,9 @@ DEFUN (interface,
       return CMD_WARNING;
     }
 
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
 #ifdef SUNOS_5
   ifp = if_sunwzebra_get (argv[0], sl, vrf_id);
 #else
@@ -724,6 +727,13 @@ DEFUN (interface,
   return CMD_SUCCESS;
 }
 
+ALIAS (interface,
+       interface_vrf_cmd,
+       "interface IFNAME " VRF_CMD_STR,
+       "Select an interface to configure\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN_NOSH (no_interface,
            no_interface_cmd,
            "no interface IFNAME",
@@ -735,6 +745,9 @@ DEFUN_NOSH (no_interface,
   struct interface *ifp;
   vrf_id_t vrf_id = VRF_DEFAULT;
 
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
   ifp = if_lookup_by_name_vrf (argv[0], vrf_id);
 
   if (ifp == NULL)
@@ -755,6 +768,14 @@ DEFUN_NOSH (no_interface,
   return CMD_SUCCESS;
 }
 
+ALIAS (no_interface,
+       no_interface_vrf_cmd,
+       "no interface IFNAME " VRF_CMD_STR,
+       NO_STR
+       "Delete a pseudo interface's configuration\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
+
 /* For debug purpose. */
 DEFUN (show_address,
        show_address_cmd,
index 57a2a959da6d709d3e501f208ab47fca89f62df0..05803d01adca2e1913d2224cd4d2bf6d02f444dc 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -370,6 +370,8 @@ extern struct cmd_element interface_desc_cmd;
 extern struct cmd_element no_interface_desc_cmd;
 extern struct cmd_element interface_cmd;
 extern struct cmd_element no_interface_cmd;
+extern struct cmd_element interface_vrf_cmd;
+extern struct cmd_element no_interface_vrf_cmd;
 extern struct cmd_element interface_pseudo_cmd;
 extern struct cmd_element no_interface_pseudo_cmd;
 extern struct cmd_element show_address_cmd;
index 2249b4092a59535724f76c567ce97e7b5c481453..56e711592518cadb92e9dccfafab13ed4fa507ce 100755 (executable)
@@ -31,6 +31,7 @@ print <<EOF;
 EOF
 
 $ignore{'"interface IFNAME"'} = "ignore";
+$ignore{'"interface IFNAME " "vrf <0-65535>"'} = "ignore";
 $ignore{'"ip vrf NAME"'} = "ignore";
 $ignore{'"router rip"'} = "ignore";
 $ignore{'"router ripng"'} = "ignore";
index 54e3e4f6c6a5ba938daa064455752e3b468cfbd0..58014c2e0d1af26a5516124195ac6cd7d92bd8c1 100644 (file)
@@ -39,6 +39,7 @@
 #include "vtysh/vtysh.h"
 #include "log.h"
 #include "bgpd/bgp_vty.h"
+#include "vrf.h"
 
 /* Struct VTY. */
 struct vty *vty;
@@ -1498,6 +1499,14 @@ DEFUNSH (VTYSH_INTERFACE,
   return CMD_SUCCESS;
 }
 
+ALIAS_SH (VTYSH_ZEBRA,
+        vtysh_interface,
+        vtysh_interface_vrf_cmd,
+        "interface IFNAME " VRF_CMD_STR,
+        "Select an interface to configure\n"
+        "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,
        vtysh_no_interface_cmd,
@@ -1506,6 +1515,14 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
        "Delete a pseudo interface's configuration\n"
        "Interface's name\n")
 
+DEFSH (VTYSH_ZEBRA,
+       vtysh_no_interface_vrf_cmd,
+       "no interface IFNAME " VRF_CMD_STR,
+       NO_STR
+       "Delete a pseudo interface's configuration\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
+
 /* TODO Implement interface description commands in ripngd, ospf6d
  * and isisd. */
 DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
@@ -2823,6 +2840,8 @@ vtysh_init_vty (void)
   install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
   install_element (CONFIG_NODE, &vtysh_interface_cmd);
   install_element (CONFIG_NODE, &vtysh_no_interface_cmd);
+  install_element (CONFIG_NODE, &vtysh_interface_vrf_cmd);
+  install_element (CONFIG_NODE, &vtysh_no_interface_vrf_cmd);
   install_element (ENABLE_NODE, &vtysh_show_running_config_cmd);
   install_element (ENABLE_NODE, &vtysh_show_running_config_daemon_cmd);
   install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd);
index d7dbb241d19901bca4a610bdb8d2e29556467a96..763f826d812f058fd5e6483f2791a999e9dd3afc 100644 (file)
@@ -32,6 +32,7 @@
 #include "connected.h"
 #include "log.h"
 #include "zclient.h"
+#include "vrf.h"
 
 #include "zebra/interface.h"
 #include "zebra/rtadv.h"
@@ -1033,6 +1034,13 @@ DEFUN_NOSH (zebra_interface,
   return ret;
 }
 
+ALIAS (zebra_interface,
+       zebra_interface_vrf_cmd,
+       "interface IFNAME " VRF_CMD_STR,
+       "Select an interface to configure\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
+
 struct cmd_node interface_node =
 {
   INTERFACE_NODE,
@@ -1689,10 +1697,12 @@ if_config_write (struct vty *vty)
 {
   struct listnode *node;
   struct interface *ifp;
+  vrf_iter_t iter;
 
   zebra_ptm_write (vty);
 
-  for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+  for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
     {
       struct zebra_if *if_data;
       struct listnode *addrnode;
@@ -1700,9 +1710,12 @@ if_config_write (struct vty *vty)
       struct prefix *p;
 
       if_data = ifp->info;
-      
-      vty_out (vty, "interface %s%s", ifp->name,
-              VTY_NEWLINE);
+
+      if (ifp->vrf_id == VRF_DEFAULT)
+        vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
+      else
+        vty_out (vty, "interface %s vrf %u%s", ifp->name, ifp->vrf_id,
+                 VTY_NEWLINE);
 
       if (if_data)
        {
@@ -1776,7 +1789,9 @@ zebra_if_init (void)
   install_element (ENABLE_NODE, &show_interface_cmd);
   install_element (ENABLE_NODE, &show_interface_desc_cmd);
   install_element (CONFIG_NODE, &zebra_interface_cmd);
+  install_element (CONFIG_NODE, &zebra_interface_vrf_cmd);
   install_element (CONFIG_NODE, &no_interface_cmd);
+  install_element (CONFIG_NODE, &no_interface_vrf_cmd);
   install_default (INTERFACE_NODE);
   install_element (INTERFACE_NODE, &interface_desc_cmd);
   install_element (INTERFACE_NODE, &no_interface_desc_cmd);