all: remove logical-router functionality

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2019-08-02 17:10:11 +03:00
parent daeca91f7c
commit c7975431e6
15 changed files with 7 additions and 300 deletions

View file

@ -55,7 +55,6 @@ digraph climodes {
CONFIG_NODE -> KEYCHAIN_KEY_NODE [ label="key (0-2147483647)" ];
KEYCHAIN_NODE -> KEYCHAIN_KEY_NODE [ label="key (0-2147483647)" ];
KEYCHAIN_KEY_NODE -> KEYCHAIN_NODE [ label="no key (0-2147483647)" ];
CONFIG_NODE -> LOGICALROUTER_NODE [ label="logical-router (1-65535) ns NAME" ];
CONFIG_NODE -> VRF_NODE [ label="vrf NAME" ];
CONFIG_NODE -> INTERFACE_NODE [ label="interface IFNAME vrf NAME" ];
INTERFACE_NODE -> LINK_PARAMS_NODE [ label="link-params" ];

View file

@ -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:

View file

@ -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. */

View file

@ -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;
}

View file

@ -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*/

View file

@ -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)
{

View file

@ -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);

View file

@ -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

View file

@ -55,7 +55,6 @@
#include "lib/libospf.h"
#include "lib/linklist.h"
#include "lib/log.h"
#include "lib/logicalrouter.h"
#include "lib/md5.h"
#include "lib/memory.h"
#include "lib/memory_vty.h"

View file

@ -96,18 +96,12 @@ sub scan_file {
elsif ($file =~ /lib\/if\.c$/) {
$protocol = "VTYSH_INTERFACE";
}
elsif ($file =~ /lib\/logicalrouter\.c$/) {
$protocol = "VTYSH_ALL";
}
elsif ($file =~ /lib\/filter\.c$/) {
$protocol = "VTYSH_ALL";
}
elsif ($file =~ /lib\/agentx\.c$/) {
$protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
}
elsif ($file =~ /lib\/ns\.c$/) {
$protocol = "VTYSH_ZEBRA";
}
elsif ($file =~ /lib\/nexthop_group\.c$/) {
$protocol = "VTYSH_PBRD | VTYSH_SHARPD";
}

View file

@ -1188,10 +1188,6 @@ static struct cmd_node pw_node = {
PW_NODE, "%s(config-pw)# ",
};
static struct cmd_node logicalrouter_node = {
LOGICALROUTER_NODE, "%s(config-logical-router)# ",
};
static struct cmd_node vrf_node = {
VRF_NODE, "%s(config-vrf)# ",
};
@ -1798,7 +1794,6 @@ static int vtysh_exit(struct vty *vty)
break;
case INTERFACE_NODE:
case PW_NODE:
case LOGICALROUTER_NODE:
case VRF_NODE:
case NH_GROUP_NODE:
case ZEBRA_NODE:
@ -2128,24 +2123,6 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_pseudowire, vtysh_pseudowire_cmd,
return CMD_SUCCESS;
}
DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_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")
{
vty->node = LOGICALROUTER_NODE;
return CMD_SUCCESS;
}
DEFSH(VTYSH_ZEBRA, vtysh_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")
DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
"nexthop-group NHGNAME",
"Nexthop Group configuration\n"
@ -2180,20 +2157,6 @@ DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_netns_cmd,
"Detach VRF from a Namespace\n"
"The file name in " NS_RUN_DIR ", or a full pathname\n")
DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter,
vtysh_exit_logicalrouter_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit(vty);
}
DEFUNSH(VTYSH_NS, vtysh_quit_logicalrouter,
vtysh_quit_logicalrouter_cmd, "quit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit_logicalrouter(self, vty, argc, argv);
}
DEFUNSH(VTYSH_VRF, vtysh_exit_vrf, vtysh_exit_vrf_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
@ -3609,7 +3572,6 @@ void vtysh_init_vty(void)
install_node(&interface_node, NULL);
install_node(&pw_node, NULL);
install_node(&link_params_node, NULL);
install_node(&logicalrouter_node, NULL);
install_node(&vrf_node, NULL);
install_node(&nh_group_node, NULL);
install_node(&rmap_node, NULL);
@ -3819,13 +3781,6 @@ void vtysh_init_vty(void)
install_element(PW_NODE, &vtysh_exit_interface_cmd);
install_element(PW_NODE, &vtysh_quit_interface_cmd);
install_element(LOGICALROUTER_NODE, &vtysh_end_all_cmd);
install_element(CONFIG_NODE, &vtysh_logicalrouter_cmd);
install_element(CONFIG_NODE, &vtysh_no_logicalrouter_cmd);
install_element(LOGICALROUTER_NODE, &vtysh_exit_logicalrouter_cmd);
install_element(LOGICALROUTER_NODE, &vtysh_quit_logicalrouter_cmd);
install_element(CONFIG_NODE, &vtysh_nexthop_group_cmd);
install_element(NH_GROUP_NODE, &vtysh_end_all_cmd);
install_element(NH_GROUP_NODE, &vtysh_exit_nexthop_group_cmd);

View file

@ -54,7 +54,6 @@ DECLARE_MGROUP(MVTYSH)
#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD|VTYSH_FABRICD|VTYSH_VRRPD
#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_SHARPD|VTYSH_FABRICD
#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD|VTYSH_VRRPD
#define VTYSH_NS VTYSH_ZEBRA
#define VTYSH_VRF VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_STATICD
#define VTYSH_KEYS VTYSH_RIPD|VTYSH_EIGRPD

View file

@ -263,7 +263,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
config_add_line(config->line, line);
} else if (config->index == RMAP_NODE
|| config->index == INTERFACE_NODE
|| config->index == LOGICALROUTER_NODE
|| config->index == VTY_NODE
|| config->index == VRF_NODE
|| config->index == NH_GROUP_NODE)
@ -278,8 +277,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(INTERFACE_NODE, line);
else if (strncmp(line, "pseudowire", strlen("pseudowire")) == 0)
config = config_get(PW_NODE, line);
else if (strncmp(line, "logical-router", strlen("logical-router")) == 0)
config = config_get(LOGICALROUTER_NODE, line);
else if (strncmp(line, "vrf", strlen("vrf")) == 0)
config = config_get(VRF_NODE, line);
else if (strncmp(line, "nexthop-group", strlen("nexthop-group"))

View file

@ -34,7 +34,6 @@
#include "privs.h"
#include "sigevent.h"
#include "vrf.h"
#include "logicalrouter.h"
#include "libfrr.h"
#include "routemap.h"
#include "frr_pthread.h"
@ -262,7 +261,6 @@ int main(int argc, char **argv)
graceful_restart = 0;
vrf_configure_backend(VRF_BACKEND_VRF_LITE);
logicalrouter_configure_backend(LOGICALROUTER_BACKEND_NETNS);
frr_preinit(&zebra_di, argc, argv);
@ -349,8 +347,6 @@ int main(int argc, char **argv)
break;
case 'n':
vrf_configure_backend(VRF_BACKEND_NETNS);
logicalrouter_configure_backend(
LOGICALROUTER_BACKEND_OFF);
break;
case OPTION_V6_RR_SEMANTICS:
v6_rr_semantics = true;

View file

@ -23,7 +23,6 @@
#include "lib/ns.h"
#include "lib/vrf.h"
#include "lib/logicalrouter.h"
#include "lib/prefix.h"
#include "lib/memory.h"
@ -45,7 +44,6 @@ DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space")
static struct zebra_ns *dzns;
static int logicalrouter_config_write(struct vty *vty);
static int zebra_ns_disable_internal(struct zebra_ns *zns, bool complete);
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
@ -188,8 +186,6 @@ int zebra_ns_init(const char *optional_default_name)
ns_id_external = ns_map_nsid_with_external(ns_id, true);
ns_init_management(ns_id_external, ns_id);
logicalrouter_init(logicalrouter_config_write);
/* Do any needed per-NS data structure allocation. */
dzns->if_table = route_table_init();
@ -215,21 +211,6 @@ int zebra_ns_init(const char *optional_default_name)
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)