]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: new cli-nodes for SRv6 manager (step2)
authorHiroki Shirokura <slank.dev@gmail.com>
Wed, 30 Sep 2020 03:59:19 +0000 (12:59 +0900)
committerMark Stapp <mjs@voltanet.io>
Wed, 2 Jun 2021 14:24:47 +0000 (10:24 -0400)
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>
lib/command.c
lib/command.h
vtysh/vtysh.c
vtysh/vtysh.h
vtysh/vtysh_config.c
zebra/main.c
zebra/subdir.am
zebra/zebra_srv6_vty.c [new file with mode: 0644]
zebra/zebra_srv6_vty.h [new file with mode: 0644]

index 7fb405bdfbb417086dd2802e56acd00e3ff2d588..805dd9abe237907febc21e888f5636b84616736d 100644 (file)
@@ -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;
index 51da4c52e63a18dde2832e99c73e73193405c796..846434066d4b78af0d7f07341d79e2636f8e39ae 100644 (file)
@@ -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 */
index 111c2dbc03db4d1e9f45ccc2df6538675619cb4a..e55a8cfb1a983ed46735973cbd0160306f0b7910 100644 (file)
@@ -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);
index 7c8d9315e1d1f25e80b5b6ddd2dc730fb33bf809..87f1f67443302879d53219372276a9f0412dbd77 100644 (file)
@@ -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,
index f92b0e920bb17fcd6420174e0dd99e9009a4fd05..6d80cf9d9693e57590d78f90255e7efb37049963 100644 (file)
@@ -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 {
index 3f75b222bac1fe15f5c4df0935b5b17be8c952da..259c70d0dfc757c5c1ec04ac4cf2ff1bf71b3684 100644 (file)
@@ -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); */
index 6fc8ef0df5b14117e0b44b2dc83b011145f788df..ca77502ba386b8655a3bcadd9f1b92c717fb0b73 100644 (file)
@@ -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 (file)
index 0000000..f8eff70
--- /dev/null
@@ -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 (file)
index 0000000..42d6aef
--- /dev/null
@@ -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 */