summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroki Shirokura <slank.dev@gmail.com>2020-09-30 12:59:19 +0900
committerMark Stapp <mjs@voltanet.io>2021-06-02 10:24:47 -0400
commit6c0a7c094111b11b7f8c298b71c60e08b82d8e15 (patch)
treea5f3fb78be05723b86b630d1153a64e14c06bf3d
parent0adde13a58a4556d930cb2e9611a801cf09d5fc4 (diff)
*: new cli-nodes for SRv6 manager (step2)
This commit is a part of #5853 that add new cmd-node for SRv6 configuration. This commit just add cmd-node and moving node cli only, acutual SRv6 config command isn't added. (that is added later commit. of this branch) new cli nodes: * SRv6 * SRv6-locators * SRv6-locator Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
-rw-r--r--lib/command.c9
-rw-r--r--lib/command.h3
-rw-r--r--vtysh/vtysh.c88
-rw-r--r--vtysh/vtysh.h1
-rw-r--r--vtysh/vtysh_config.c4
-rw-r--r--zebra/main.c2
-rw-r--r--zebra/subdir.am3
-rw-r--r--zebra/zebra_srv6_vty.c132
-rw-r--r--zebra/zebra_srv6_vty.h25
9 files changed, 266 insertions, 1 deletions
diff --git a/lib/command.c b/lib/command.c
index 7fb405bdfb..805dd9abe2 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -889,6 +889,15 @@ enum node_type node_parent(enum node_type node)
case PCEP_PCC_NODE:
ret = PCEP_NODE;
break;
+ case SRV6_NODE:
+ ret = SEGMENT_ROUTING_NODE;
+ break;
+ case SRV6_LOCS_NODE:
+ ret = SRV6_NODE;
+ break;
+ case SRV6_LOC_NODE:
+ ret = SRV6_LOCS_NODE;
+ break;
default:
ret = CONFIG_NODE;
break;
diff --git a/lib/command.h b/lib/command.h
index 51da4c52e6..846434066d 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -155,6 +155,9 @@ enum node_type {
PCEP_PCE_CONFIG_NODE, /* PCE shared configuration node */
PCEP_PCE_NODE, /* PCE configuration node */
PCEP_PCC_NODE, /* PCC configuration node */
+ SRV6_NODE, /* SRv6 node */
+ SRV6_LOCS_NODE, /* SRv6 locators node */
+ SRV6_LOC_NODE, /* SRv6 locator node */
VTY_NODE, /* Vty node. */
FPM_NODE, /* Dataplane FPM node. */
LINK_PARAMS_NODE, /* Link-parameters node */
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 111c2dbc03..e55a8cfb1a 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1349,6 +1349,27 @@ static struct cmd_node rmap_node = {
.prompt = "%s(config-route-map)# ",
};
+static struct cmd_node srv6_node = {
+ .name = "srv6",
+ .node = SRV6_NODE,
+ .parent_node = SEGMENT_ROUTING_NODE,
+ .prompt = "%s(config-srv6)# ",
+};
+
+static struct cmd_node srv6_locs_node = {
+ .name = "srv6-locators",
+ .node = SRV6_LOCS_NODE,
+ .parent_node = SRV6_NODE,
+ .prompt = "%s(config-srv6-locators)# ",
+};
+
+static struct cmd_node srv6_loc_node = {
+ .name = "srv6-locator",
+ .node = SRV6_LOC_NODE,
+ .parent_node = SRV6_LOCS_NODE,
+ .prompt = "%s(config-srv6-locator)# ",
+};
+
#ifdef HAVE_PBRD
static struct cmd_node pbr_map_node = {
.name = "pbr-map",
@@ -1659,6 +1680,31 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_end_all, vtysh_end_all_cmd, "end",
return vtysh_end();
}
+DEFUNSH(VTYSH_SR, srv6, srv6_cmd,
+ "srv6",
+ "Segment-Routing SRv6 configration\n")
+{
+ vty->node = SRV6_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUNSH(VTYSH_SR, srv6_locators, srv6_locators_cmd,
+ "locators",
+ "Segment-Routing SRv6 locators configration\n")
+{
+ vty->node = SRV6_LOCS_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUNSH(VTYSH_SR, srv6_locator, srv6_locator_cmd,
+ "locator WORD",
+ "Segment Routing SRv6 locator\n"
+ "Specify locator-name\n")
+{
+ vty->node = SRV6_LOC_NODE;
+ return CMD_SUCCESS;
+}
+
#ifdef HAVE_BGPD
DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd,
"router bgp [(1-4294967295) [<view|vrf> WORD]]",
@@ -2084,7 +2130,7 @@ DEFUNSH(VTYSH_FABRICD, router_openfabric, router_openfabric_cmd, "router openfab
#endif /* HAVE_FABRICD */
#if defined(HAVE_PATHD)
-DEFUNSH(VTYSH_PATHD, segment_routing, segment_routing_cmd,
+DEFUNSH(VTYSH_SR, segment_routing, segment_routing_cmd,
"segment-routing",
"Configure segment routing\n")
{
@@ -2366,6 +2412,30 @@ DEFUNSH(VTYSH_VRF, exit_vrf_config, exit_vrf_config_cmd, "exit-vrf",
return CMD_SUCCESS;
}
+DEFUNSH(VTYSH_SR, exit_srv6_config, exit_srv6_config_cmd, "exit",
+ "Exit from SRv6 configuration mode\n")
+{
+ if (vty->node == SRV6_NODE)
+ vty->node = SEGMENT_ROUTING_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUNSH(VTYSH_SR, exit_srv6_locs_config, exit_srv6_locs_config_cmd, "exit",
+ "Exit from SRv6-locator configuration mode\n")
+{
+ if (vty->node == SRV6_LOCS_NODE)
+ vty->node = SRV6_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUNSH(VTYSH_SR, exit_srv6_loc_config, exit_srv6_loc_config_cmd, "exit",
+ "Exit from SRv6-locators configuration mode\n")
+{
+ if (vty->node == SRV6_LOC_NODE)
+ vty->node = SRV6_LOCS_NODE;
+ return CMD_SUCCESS;
+}
+
#ifdef HAVE_RIPD
DEFUNSH(VTYSH_RIPD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit",
"Exit current mode and down to previous mode\n")
@@ -4431,6 +4501,22 @@ void vtysh_init_vty(void)
install_element(CONFIG_NODE, &vtysh_end_all_cmd);
install_element(ENABLE_NODE, &vtysh_end_all_cmd);
+ /* SRv6 Data-plane */
+ install_node(&srv6_node);
+ install_element(SEGMENT_ROUTING_NODE, &srv6_cmd);
+ install_element(SRV6_NODE, &srv6_locators_cmd);
+ install_element(SRV6_NODE, &exit_srv6_config_cmd);
+ install_element(SRV6_NODE, &vtysh_end_all_cmd);
+
+ install_node(&srv6_locs_node);
+ install_element(SRV6_LOCS_NODE, &srv6_locator_cmd);
+ install_element(SRV6_LOCS_NODE, &exit_srv6_locs_config_cmd);
+ install_element(SRV6_LOCS_NODE, &vtysh_end_all_cmd);
+
+ install_node(&srv6_loc_node);
+ install_element(SRV6_LOC_NODE, &exit_srv6_loc_config_cmd);
+ install_element(SRV6_LOC_NODE, &vtysh_end_all_cmd);
+
install_element(ENABLE_NODE, &vtysh_show_running_config_cmd);
install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd);
install_element(ENABLE_NODE, &vtysh_copy_to_running_cmd);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 7c8d9315e1..87f1f67443 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -60,6 +60,7 @@ DECLARE_MGROUP(MVTYSH);
#define VTYSH_KEYS VTYSH_RIPD|VTYSH_EIGRPD
/* Daemons who can process nexthop-group configs */
#define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD
+#define VTYSH_SR VTYSH_ZEBRA|VTYSH_PATHD
enum vtysh_write_integrated {
WRITE_INTEGRATED_UNSPECIFIED,
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index f92b0e920b..6d80cf9d96 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -430,6 +430,10 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(PROTOCOL_NODE, line);
else if (strncmp(line, "mpls", strlen("mpls")) == 0)
config = config_get(MPLS_NODE, line);
+ else if (strncmp(line, "segment-routing",
+ strlen("segment-routing"))
+ == 0)
+ config = config_get(SEGMENT_ROUTING_NODE, line);
else if (strncmp(line, "bfd", strlen("bfd")) == 0)
config = config_get(BFD_NODE, line);
else {
diff --git a/zebra/main.c b/zebra/main.c
index 3f75b222ba..259c70d0df 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -57,6 +57,7 @@
#include "zebra/zebra_nb.h"
#include "zebra/zebra_opaque.h"
#include "zebra/zebra_srte.h"
+#include "zebra/zebra_srv6_vty.h"
#define ZEBRA_PTM_SUPPORT
@@ -418,6 +419,7 @@ int main(int argc, char **argv)
zebra_pbr_init();
zebra_opaque_init();
zebra_srte_init();
+ zebra_srv6_vty_init();
/* For debug purpose. */
/* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */
diff --git a/zebra/subdir.am b/zebra/subdir.am
index 6fc8ef0df5..ca77502ba3 100644
--- a/zebra/subdir.am
+++ b/zebra/subdir.am
@@ -13,6 +13,7 @@ vtysh_scan += \
zebra/zebra_mlag_vty.c \
zebra/zebra_evpn_mh.c \
zebra/zebra_mpls_vty.c \
+ zebra/zebra_srv6_vty.c \
zebra/zebra_ptm.c \
zebra/zebra_pw.c \
zebra/zebra_routemap.c \
@@ -92,6 +93,7 @@ zebra_zebra_SOURCES = \
zebra/zebra_mpls_openbsd.c \
zebra/zebra_mpls_null.c \
zebra/zebra_mpls_vty.c \
+ zebra/zebra_srv6_vty.c \
zebra/zebra_mroute.c \
zebra/zebra_nb.c \
zebra/zebra_nb_config.c \
@@ -161,6 +163,7 @@ noinst_HEADERS += \
zebra/zebra_mlag.h \
zebra/zebra_mlag_vty.h \
zebra/zebra_mpls.h \
+ zebra/zebra_srv6_vty.h \
zebra/zebra_mroute.h \
zebra/zebra_nb.h \
zebra/zebra_netns_id.h \
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c
new file mode 100644
index 0000000000..f8eff70c2d
--- /dev/null
+++ b/zebra/zebra_srv6_vty.c
@@ -0,0 +1,132 @@
+/*
+ * Zebra SRv6 VTY functions
+ * Copyright (C) 2020 Hiroki Shirokura, LINE Corporation
+ *
+ * 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 "memory.h"
+#include "if.h"
+#include "prefix.h"
+#include "command.h"
+#include "table.h"
+#include "rib.h"
+#include "nexthop.h"
+#include "vrf.h"
+#include "srv6.h"
+#include "lib/json.h"
+
+#include "zebra/zserv.h"
+#include "zebra/zebra_vrf.h"
+#include "zebra/zebra_srv6_vty.h"
+#include "zebra/zebra_rnh.h"
+#include "zebra/redistribute.h"
+#include "zebra/zebra_routemap.h"
+#include "zebra/zebra_dplane.h"
+
+static int zebra_sr_config(struct vty *vty);
+
+static struct cmd_node sr_node = {
+ .name = "sr",
+ .node = SEGMENT_ROUTING_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-sr)# ",
+ .config_write = zebra_sr_config,
+};
+
+static struct cmd_node srv6_node = {
+ .name = "srv6",
+ .node = SRV6_NODE,
+ .parent_node = SEGMENT_ROUTING_NODE,
+ .prompt = "%s(config-srv6)# ",
+
+};
+
+static struct cmd_node srv6_locs_node = {
+ .name = "srv6-locators",
+ .node = SRV6_LOCS_NODE,
+ .parent_node = SRV6_NODE,
+ .prompt = "%s(config-srv6-locators)# ",
+};
+
+static struct cmd_node srv6_loc_node = {
+ .name = "srv6-locator",
+ .node = SRV6_LOC_NODE,
+ .parent_node = SRV6_LOCS_NODE,
+ .prompt = "%s(config-srv6-locator)# "
+};
+
+DEFUN_NOSH (segment_routing,
+ segment_routing_cmd,
+ "segment-routing",
+ "Segment Routing\n")
+{
+ vty->node = SEGMENT_ROUTING_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN_NOSH (srv6,
+ srv6_cmd,
+ "srv6",
+ "Segment Routing SRv6\n")
+{
+ vty->node = SRV6_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN_NOSH (srv6_locators,
+ srv6_locators_cmd,
+ "locators",
+ "Segment Routing SRv6 locators\n")
+{
+ vty->node = SRV6_LOCS_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN_NOSH (srv6_locator,
+ srv6_locator_cmd,
+ "locator WORD",
+ "Segment Routing SRv6 locator\n"
+ "Specify locator-name\n")
+{
+ vty->node = SRV6_LOC_NODE;
+ return CMD_SUCCESS;
+}
+
+static int zebra_sr_config(struct vty *vty)
+{
+ return 0;
+}
+
+void zebra_srv6_vty_init(void)
+{
+ /* Install nodes and its default commands */
+ install_node(&sr_node);
+ install_node(&srv6_node);
+ install_node(&srv6_locs_node);
+ install_node(&srv6_loc_node);
+ install_default(SEGMENT_ROUTING_NODE);
+ install_default(SRV6_NODE);
+ install_default(SRV6_LOCS_NODE);
+ install_default(SRV6_LOC_NODE);
+
+ /* Command for change node */
+ install_element(CONFIG_NODE, &segment_routing_cmd);
+ install_element(SEGMENT_ROUTING_NODE, &srv6_cmd);
+ install_element(SRV6_NODE, &srv6_locators_cmd);
+ install_element(SRV6_LOCS_NODE, &srv6_locator_cmd);
+}
diff --git a/zebra/zebra_srv6_vty.h b/zebra/zebra_srv6_vty.h
new file mode 100644
index 0000000000..42d6aefa9a
--- /dev/null
+++ b/zebra/zebra_srv6_vty.h
@@ -0,0 +1,25 @@
+/*
+ * Zebra SRv6 VTY functions
+ * Copyright (C) 2020 Hiroki Shirokura, LINE Corporation
+ *
+ * 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_SRV6_VTY_H
+#define _ZEBRA_SRV6_VTY_H
+
+extern void zebra_srv6_vty_init(void);
+
+#endif /* _ZEBRA_SRV6_VTY_H */