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>
#include "privs.h"
#include "sigevent.h"
#include "vrf.h"
+#include "logicalrouter.h"
#include "libfrr.h"
#include "zebra/rib.h"
#endif
vrf_configure_backend(VRF_BACKEND_VRF_LITE);
+ logicalrouter_configure_backend(
+ LOGICALROUTER_BACKEND_NETNS);
frr_preinit(&zebra_di, argc, 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)
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;
#include "lib/ns.h"
#include "lib/vrf.h"
+#include "lib/logicalrouter.h"
#include "lib/prefix.h"
#include "lib/memory.h"
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)
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();
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);
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)
/* 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);
}
* 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>
extern void zebra_rtable_node_cleanup(struct route_table *table,
struct route_node *node);
-#endif
+#endif /* ZEBRA_VRF_H */