diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 2 | ||||
-rw-r--r-- | lib/command.h | 1 | ||||
-rw-r--r-- | lib/logicalrouter.c | 158 | ||||
-rw-r--r-- | lib/logicalrouter.h | 49 | ||||
-rw-r--r-- | lib/netns_other.c | 2 | ||||
-rw-r--r-- | lib/ns.h | 12 | ||||
-rw-r--r-- | lib/subdir.am | 3 |
7 files changed, 7 insertions, 220 deletions
diff --git a/lib/command.c b/lib/command.c index c8fbf2272..9049fb9eb 100644 --- a/lib/command.c +++ b/lib/command.c @@ -89,7 +89,6 @@ const char *node_names[] = { "aaa", // AAA_NODE, "keychain", // KEYCHAIN_NODE, "keychain key", // KEYCHAIN_KEY_NODE, - "logical-router", // LOGICALROUTER_NODE, "static ip", // IP_NODE, "vrf", // VRF_NODE, "interface", // INTERFACE_NODE, @@ -1456,7 +1455,6 @@ void cmd_exit(struct vty *vty) break; case INTERFACE_NODE: case PW_NODE: - case LOGICALROUTER_NODE: case VRF_NODE: case NH_GROUP_NODE: case ZEBRA_NODE: diff --git a/lib/command.h b/lib/command.h index 08d6128af..8dc35a0fd 100644 --- a/lib/command.h +++ b/lib/command.h @@ -98,7 +98,6 @@ enum node_type { AAA_NODE, /* AAA node. */ KEYCHAIN_NODE, /* Key-chain node. */ KEYCHAIN_KEY_NODE, /* Key-chain key node. */ - LOGICALROUTER_NODE, /* Logical-Router node. */ IP_NODE, /* Static ip route node. */ VRF_NODE, /* VRF mode node. */ INTERFACE_NODE, /* Interface mode node. */ diff --git a/lib/logicalrouter.c b/lib/logicalrouter.c deleted file mode 100644 index da69ae531..000000000 --- a/lib/logicalrouter.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Logical Router functions. - * Copyright (C) 2018 6WIND S.A. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * 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 - */ - -#include <zebra.h> - -#include "ns.h" -#include "log.h" -#include "memory.h" - -#include "command.h" -#include "vty.h" -#include "logicalrouter.h" - -/* Comment that useless define to avoid compilation error - * in order to use it, one could provide the kind of NETNS to NS backend - * so that the allocation will match the logical router - * DEFINE_MTYPE_STATIC(LIB, LOGICALROUTER, "LogicalRouter Context") - */ -DEFINE_MTYPE_STATIC(LIB, LOGICALROUTER_NAME, "Logical Router Name") - -/* Logical Router node has no interface. */ -static struct cmd_node logicalrouter_node = {LOGICALROUTER_NODE, "", 1}; - -static int logicalrouter_backend; - -/* Get a NS. If not found, create one. */ -static struct ns *logicalrouter_get(ns_id_t ns_id) -{ - struct ns *ns; - - ns = ns_lookup(ns_id); - if (ns) - return (ns); - ns = ns_get_created(ns, NULL, ns_id); - return ns; -} - -static int logicalrouter_is_backend_netns(void) -{ - return (logicalrouter_backend == LOGICALROUTER_BACKEND_NETNS); -} - - -DEFUN_NOSH (logicalrouter, - logicalrouter_cmd, - "logical-router (1-65535) ns NAME", - "Enable a logical-router\n" - "Specify the logical-router indentifier\n" - "The Name Space\n" - "The file name in " NS_RUN_DIR ", or a full pathname\n") -{ - int idx_number = 1; - int idx_name = 3; - ns_id_t ns_id; - struct ns *ns = NULL; - char *pathname = ns_netns_pathname(vty, argv[idx_name]->arg); - - if (!pathname) - return CMD_WARNING_CONFIG_FAILED; - - ns_id = strtoul(argv[idx_number]->arg, NULL, 10); - ns = logicalrouter_get(ns_id); - - if (ns->name && strcmp(ns->name, pathname) != 0) { - vty_out(vty, "NS %u is already configured with NETNS %s\n", - ns->ns_id, ns->name); - return CMD_WARNING; - } - - if (!ns->name) - ns->name = XSTRDUP(MTYPE_LOGICALROUTER_NAME, pathname); - - if (!ns_enable(ns, NULL)) { - vty_out(vty, "Can not associate NS %u with NETNS %s\n", - ns->ns_id, ns->name); - return CMD_WARNING_CONFIG_FAILED; - } - - return CMD_SUCCESS; -} - -DEFUN (no_logicalrouter, - no_logicalrouter_cmd, - "no logical-router (1-65535) ns NAME", - NO_STR - "Enable a Logical-Router\n" - "Specify the Logical-Router identifier\n" - "The Name Space\n" - "The file name in " NS_RUN_DIR ", or a full pathname\n") -{ - int idx_number = 2; - int idx_name = 4; - ns_id_t ns_id; - struct ns *ns = NULL; - char *pathname = ns_netns_pathname(vty, argv[idx_name]->arg); - - if (!pathname) - return CMD_WARNING_CONFIG_FAILED; - - ns_id = strtoul(argv[idx_number]->arg, NULL, 10); - ns = ns_lookup(ns_id); - - if (!ns) { - vty_out(vty, "NS %u is not found\n", ns_id); - return CMD_SUCCESS; - } - - if (ns->name && strcmp(ns->name, pathname) != 0) { - vty_out(vty, "Incorrect NETNS file name\n"); - return CMD_WARNING_CONFIG_FAILED; - } - - ns_disable(ns); - - if (ns->name) { - XFREE(MTYPE_LOGICALROUTER_NAME, ns->name); - ns->name = NULL; - } - - return CMD_SUCCESS; -} - -/* Initialize NS module. */ -void logicalrouter_init(int (*writefunc)(struct vty *vty)) -{ - if (ns_have_netns() && logicalrouter_is_backend_netns()) { - /* Install LogicalRouter commands. */ - install_node(&logicalrouter_node, writefunc); - install_element(CONFIG_NODE, &logicalrouter_cmd); - install_element(CONFIG_NODE, &no_logicalrouter_cmd); - } -} - -void logicalrouter_terminate(void) -{ - ns_terminate(); -} - -void logicalrouter_configure_backend(int backend_netns) -{ - logicalrouter_backend = backend_netns; -} diff --git a/lib/logicalrouter.h b/lib/logicalrouter.h deleted file mode 100644 index d18832ef7..000000000 --- a/lib/logicalrouter.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Logical Router related header. - * Copyright (C) 2018 6WIND S.A. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * 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 - */ - -#ifndef _ZEBRA_LOGICAL_ROUTER_H -#define _ZEBRA_LOGICAL_ROUTER_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Logical Router Backend defines */ -#define LOGICALROUTER_BACKEND_OFF 0 -#define LOGICALROUTER_BACKEND_NETNS 1 - -/* - * Logical Router initializer/destructor - */ -extern void logicalrouter_init(int (*writefunc)(struct vty *vty)); -extern void logicalrouter_terminate(void); - -/* used to configure backend for logical router - * Currently, the whole NETNS feature is exclusively shared - * between logical router and VRF backend NETNS - * However, when logical router feature will be available, - * one can think of having exclusivity only per NETNS - */ -extern void logicalrouter_configure_backend(int backend_netns); - -#ifdef __cplusplus -} -#endif - -#endif /*_ZEBRA_LOGICAL_ROUTER_H*/ diff --git a/lib/netns_other.c b/lib/netns_other.c index 4c7be05fa..b0aae4f8d 100644 --- a/lib/netns_other.c +++ b/lib/netns_other.c @@ -82,7 +82,7 @@ const char *ns_get_name(struct ns *ns) } /* only called from vrf ( when removing netns from vrf) - * or at VRF or logical router termination + * or at VRF termination */ void ns_delete(struct ns *ns) { @@ -41,7 +41,7 @@ typedef uint32_t ns_id_t; #ifdef HAVE_NETNS #define NS_DEFAULT_NAME "/proc/self/ns/net" #else /* !HAVE_NETNS */ -#define NS_DEFAULT_NAME "Default-logical-router" +#define NS_DEFAULT_NAME "default-netns" #endif /* HAVE_NETNS */ struct ns { @@ -82,10 +82,10 @@ extern struct ns_head ns_tree; * NS hooks */ -#define NS_NEW_HOOK 0 /* a new logical-router is just created */ -#define NS_DELETE_HOOK 1 /* a logical-router is to be deleted */ -#define NS_ENABLE_HOOK 2 /* a logical-router is ready to use */ -#define NS_DISABLE_HOOK 3 /* a logical-router is to be unusable */ +#define NS_NEW_HOOK 0 /* a new netns is just created */ +#define NS_DELETE_HOOK 1 /* a netns is to be deleted */ +#define NS_ENABLE_HOOK 2 /* a netns is ready to use */ +#define NS_DISABLE_HOOK 3 /* a netns is to be unusable */ /* * Add a specific hook ns module. @@ -128,7 +128,7 @@ extern void ns_walk_func(int (*func)(struct ns *)); extern const char *ns_get_name(struct ns *ns); /* only called from vrf ( when removing netns from vrf) - * or at VRF or logical router termination + * or at VRF termination */ extern void ns_delete(struct ns *ns); diff --git a/lib/subdir.am b/lib/subdir.am index aa8962202..f4fe369a9 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -95,7 +95,6 @@ lib_libfrr_la_SOURCES = \ lib/yang_translator.c \ lib/yang_wrappers.c \ lib/zclient.c \ - lib/logicalrouter.c \ lib/printf/printf-pos.c \ lib/printf/vfprintf.c \ lib/printf/glue.c \ @@ -113,7 +112,6 @@ vtysh_scan += \ $(top_srcdir)/lib/if.c \ $(top_srcdir)/lib/if_rmap.c \ $(top_srcdir)/lib/keychain.c \ - $(top_srcdir)/lib/logicalrouter.c \ $(top_srcdir)/lib/nexthop_group.c \ $(top_srcdir)/lib/plist.c \ $(top_srcdir)/lib/routemap.c \ @@ -241,7 +239,6 @@ pkginclude_HEADERS += \ lib/zassert.h \ lib/zclient.h \ lib/zebra.h \ - lib/logicalrouter.h \ lib/pbr.h \ # end |