]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: adapt the vrf and logical router initialisation
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 5 Feb 2018 15:30:21 +0000 (16:30 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 27 Feb 2018 10:11:24 +0000 (11:11 +0100)
The zebra daemon introduces the logical router initialisation.
Because right now, the usage of logical router and vrf NETNS is
exclusive, then the logical router and VRF are initialised accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/main.c
zebra/zebra_netns_notify.c
zebra/zebra_ns.c
zebra/zebra_vrf.c
zebra/zebra_vrf.h

index 9cad913f4bef95ccc066893f27fb538ecd662487..749d509a86b4cbe22300903f7996524586642d33 100644 (file)
@@ -34,6 +34,7 @@
 #include "privs.h"
 #include "sigevent.h"
 #include "vrf.h"
+#include "logicalrouter.h"
 #include "libfrr.h"
 
 #include "zebra/rib.h"
@@ -207,6 +208,8 @@ int main(int argc, char **argv)
 #endif
 
        vrf_configure_backend(VRF_BACKEND_VRF_LITE);
+       logicalrouter_configure_backend(
+                        LOGICALROUTER_BACKEND_NETNS);
 
        frr_preinit(&zebra_di, argc, argv);
 
@@ -285,6 +288,8 @@ int main(int argc, char **argv)
                        break;
                case 'n':
                        vrf_configure_backend(VRF_BACKEND_NETNS);
+                       logicalrouter_configure_backend(
+                                       LOGICALROUTER_BACKEND_OFF);
                        break;
 #endif /* HAVE_NETLINK */
 #if defined(HANDLE_ZAPI_FUZZING)
index 8940546f686164b9f7bdbf9bbbdeafb867aabd8b..b28998acf8186b3e3cb06baae7a29e5be8132acc 100644 (file)
@@ -84,7 +84,7 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
        ns_id = zebra_ns_id_get(netnspath);
        if (zserv_privs.change(ZPRIVS_LOWER))
                zlog_err("Can't lower privileges");
-       ret = ns_handler_create(NULL, vrf, netnspath, ns_id);
+       ret = vrf_netns_handler_create(NULL, vrf, netnspath, ns_id);
        if (ret != CMD_SUCCESS) {
                zlog_warn("NS notify : failed to create NS %s", netnspath);
                return;
index da5b22def25f05279832b67e14cab6b0d4f689ae..cb302985c8aa6e71128370342cbb6bee96795554 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "lib/ns.h"
 #include "lib/vrf.h"
+#include "lib/logicalrouter.h"
 #include "lib/prefix.h"
 #include "lib/memory.h"
 
@@ -59,6 +60,8 @@ zebra_ns_table_entry_compare(const struct zebra_ns_table *e1,
        return e1->tableid - e2->tableid;
 }
 
+static int logicalrouter_config_write(struct vty *vty);
+
 struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
 {
        if (ns_id == NS_DEFAULT)
@@ -241,9 +244,10 @@ int zebra_ns_init(void)
        ns_id = zebra_ns_id_get_default();
        if (zserv_privs.change(ZPRIVS_LOWER))
                zlog_err("Can't lower privileges");
-       ns_init_zebra(ns_id);
 
-       ns_init();
+       ns_init_management(ns_id);
+
+       logicalrouter_init(logicalrouter_config_write);
 
        /* Do any needed per-NS data structure allocation. */
        dzns->if_table = route_table_init();
@@ -253,7 +257,7 @@ int zebra_ns_init(void)
        zebra_vrf_init();
 
        /* Default NS is activated */
-       zebra_ns_enable(NS_DEFAULT, (void **)&dzns);
+       zebra_ns_enable(ns_id, (void **)&dzns);
 
        if (vrf_is_backend_netns()) {
                ns_add_hook(NS_NEW_HOOK, zebra_ns_new);
@@ -266,6 +270,21 @@ int zebra_ns_init(void)
        return 0;
 }
 
+static int logicalrouter_config_write(struct vty *vty)
+{
+       struct ns *ns;
+       int write = 0;
+
+       RB_FOREACH(ns, ns_head, &ns_tree) {
+               if (ns->ns_id == NS_DEFAULT || ns->name == NULL)
+                       continue;
+               vty_out(vty, "logical-router %u netns %s\n", ns->ns_id,
+                       ns->name);
+               write = 1;
+       }
+       return write;
+}
+
 int zebra_ns_config_write(struct vty *vty, struct ns *ns)
 {
        if (ns && ns->name != NULL)
index 874a9c74e72468f114a8a117ae8f305289c3398e..bb15fd04f34bd6aa97a9830900c93b9019503290 100644 (file)
@@ -581,8 +581,8 @@ static int vrf_config_write(struct vty *vty)
 /* Zebra VRF initialization. */
 void zebra_vrf_init(void)
 {
-       vrf_init(zebra_vrf_new, zebra_vrf_enable, zebra_vrf_disable,
-                zebra_vrf_delete);
+       vrf_init(zebra_vrf_new, zebra_vrf_enable,
+                zebra_vrf_disable, zebra_vrf_delete);
 
        vrf_cmd_init(vrf_config_write);
 }
index ae5a174116df41198fb94d2d194604c634ae26a1..4c12d7dee904bfa55878bf86636545a5c8efcb9f 100644 (file)
  * with this program; see the file COPYING; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#if !defined(__ZEBRA_RIB_H__)
-#define __ZEBRA_RIB_H__
+#if !defined(__ZEBRA_VRF_H__)
+#define __ZEBRA_VRF_H__
 
-#include <lib/ns.h>
 #include <zebra/zebra_ns.h>
 #include <zebra/zebra_pw.h>
 #include <lib/vxlan.h>
@@ -169,4 +168,4 @@ extern void zebra_vrf_init(void);
 
 extern void zebra_rtable_node_cleanup(struct route_table *table,
                                      struct route_node *node);
-#endif
+#endif /* ZEBRA_VRF_H */