]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: retrofit the mpls-te commands
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 10:50:29 +0000 (11:50 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:23:49 +0000 (15:23 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_cli.c
isisd/isis_cli.h
isisd/isis_northbound.c
isisd/isis_te.c

index d2c88eda542bc00d66aeb5ece36f664d3aef5130..fd309e6244acd27eeb8bd79be323e59fc1be69c4 100644 (file)
@@ -899,6 +899,69 @@ void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, " purge-originator\n");
 }
 
+/*
+ * XPath: /frr-isisd:isis/mpls-te
+ */
+DEFPY(isis_mpls_te_on, isis_mpls_te_on_cmd, "mpls-te on",
+      MPLS_TE_STR "Enable the MPLS-TE functionality\n")
+{
+       nb_cli_enqueue_change(vty, "/frr-isisd:isis/mpls-te", NB_OP_CREATE,
+                             NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY(no_isis_mpls_te_on, no_isis_mpls_te_on_cmd, "no mpls-te [on]",
+      NO_STR
+      "Disable the MPLS-TE functionality\n"
+      "Enable the MPLS-TE functionality\n")
+{
+       nb_cli_enqueue_change(vty, "/frr-isisd:isis/mpls-te", NB_OP_DELETE,
+                             NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode,
+                          bool show_defaults)
+{
+       vty_out(vty, "  mpls-te on\n");
+}
+
+/*
+ * XPath: /frr-isisd:isis/mpls-te/router-address
+ */
+DEFPY(isis_mpls_te_router_addr, isis_mpls_te_router_addr_cmd,
+      "mpls-te router-address A.B.C.D",
+      MPLS_TE_STR
+      "Stable IP address of the advertising router\n"
+      "MPLS-TE router address in IPv4 address format\n")
+{
+       nb_cli_enqueue_change(vty, "/frr-isisd:isis/mpls-te/router-address",
+                             NB_OP_MODIFY, router_address_str);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
+                                      bool show_defaults)
+{
+       vty_out(vty, "  mpls-te router-address %s\n",
+               yang_dnode_get_string(dnode, NULL));
+}
+
+DEFPY(isis_mpls_te_inter_as, isis_mpls_te_inter_as_cmd,
+      "[no] mpls-te inter-as [level-1|level-1-2|level-2-only]",
+      NO_STR MPLS_TE_STR
+      "Configure MPLS-TE Inter-AS support\n"
+      "AREA native mode self originate INTER-AS LSP with L1 only flooding scope\n"
+      "AREA native mode self originate INTER-AS LSP with L1 and L2 flooding scope\n"
+      "AS native mode self originate INTER-AS LSP with L2 only flooding scope\n")
+{
+       vty_out(vty, "MPLS-TE Inter-AS is not yet supported.");
+       return CMD_SUCCESS;
+}
+
 void isis_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_isis_cmd);
@@ -940,6 +1003,11 @@ void isis_cli_init(void)
        install_element(ISIS_NODE, &no_spf_delay_ietf_cmd);
 
        install_element(ISIS_NODE, &area_purge_originator_cmd);
+
+       install_element(ISIS_NODE, &isis_mpls_te_on_cmd);
+       install_element(ISIS_NODE, &no_isis_mpls_te_on_cmd);
+       install_element(ISIS_NODE, &isis_mpls_te_router_addr_cmd);
+       install_element(ISIS_NODE, &isis_mpls_te_inter_as_cmd);
 }
 
 #endif /* ifndef FABRICD */
index 1b2e89c5dbcb3d5bf74a020eb34b0ed862c4c75e..d28302a71d87a4795529cbff216884fab203a9e1 100644 (file)
@@ -57,5 +57,9 @@ void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode,
                                    bool show_defaults);
 void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode,
                                bool show_defaults);
+void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode,
+                          bool show_defaults);
+void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
+                                      bool show_defaults);
 
 #endif /* ISISD_ISIS_CLI_H_ */
index f55a0ccf34605febcbc7adfddc109b3af604e34b..43e2639b1bf2b90e15a116f6addce4c09f9ed229 100644 (file)
@@ -1353,14 +1353,66 @@ static int isis_mpls_te_create(enum nb_event event,
                               const struct lyd_node *dnode,
                               union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       struct listnode *node;
+       struct isis_circuit *circuit;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       isisMplsTE.status = enable;
+
+       /*
+        * Following code is intended to handle two cases;
+        *
+        * 1) MPLS-TE was disabled at startup time, but now become enabled.
+        * In this case, we must enable MPLS-TE Circuit regarding interface
+        * MPLS_TE flag
+        * 2) MPLS-TE was once enabled then disabled, and now enabled again.
+        */
+       for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) {
+               if (circuit->mtc == NULL || IS_FLOOD_AS(circuit->mtc->type))
+                       continue;
+
+               if ((circuit->mtc->status == disable)
+                   && HAS_LINK_PARAMS(circuit->interface))
+                       circuit->mtc->status = enable;
+               else
+                       continue;
+
+               /* Reoriginate STD_TE & GMPLS circuits */
+               if (circuit->area)
+                       lsp_regenerate_schedule(circuit->area, circuit->is_type,
+                                               0);
+       }
+
        return NB_OK;
 }
 
 static int isis_mpls_te_delete(enum nb_event event,
                               const struct lyd_node *dnode)
 {
-       /* TODO: implement me. */
+       struct listnode *node;
+       struct isis_circuit *circuit;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       isisMplsTE.status = disable;
+
+       /* Flush LSP if circuit engage */
+       for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) {
+               if (circuit->mtc == NULL || (circuit->mtc->status == disable))
+                       continue;
+
+               /* disable MPLS_TE Circuit */
+               circuit->mtc->status = disable;
+
+               /* Re-originate circuit without STD_TE & GMPLS parameters */
+               if (circuit->area)
+                       lsp_regenerate_schedule(circuit->area, circuit->is_type,
+                                               0);
+       }
+
        return NB_OK;
 }
 
@@ -1371,14 +1423,50 @@ static int isis_mpls_te_router_address_modify(enum nb_event event,
                                              const struct lyd_node *dnode,
                                              union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       struct in_addr value;
+       struct listnode *node;
+       struct isis_area *area;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       yang_dnode_get_ipv4(&value, dnode, NULL);
+       isisMplsTE.router_id.s_addr = value.s_addr;
+       /* only proceed if MPLS-TE is enabled */
+       if (isisMplsTE.status == disable)
+               return NB_OK;
+
+       /* Update main Router ID in isis global structure */
+       isis->router_id = value.s_addr;
+       /* And re-schedule LSP update */
+       for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
+               if (listcount(area->area_addrs) > 0)
+                       lsp_regenerate_schedule(area, area->is_type, 0);
+
        return NB_OK;
 }
 
 static int isis_mpls_te_router_address_delete(enum nb_event event,
                                              const struct lyd_node *dnode)
 {
-       /* TODO: implement me. */
+       struct listnode *node;
+       struct isis_area *area;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       isisMplsTE.router_id.s_addr = INADDR_ANY;
+       /* only proceed if MPLS-TE is enabled */
+       if (isisMplsTE.status == disable)
+               return NB_OK;
+
+       /* Update main Router ID in isis global structure */
+       isis->router_id = 0;
+       /* And re-schedule LSP update */
+       for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
+               if (listcount(area->area_addrs) > 0)
+                       lsp_regenerate_schedule(area, area->is_type, 0);
+
        return NB_OK;
 }
 
@@ -2249,11 +2337,13 @@ const struct frr_yang_module_info frr_isisd_info = {
                        .xpath = "/frr-isisd:isis/mpls-te",
                        .cbs.create = isis_mpls_te_create,
                        .cbs.delete = isis_mpls_te_delete,
+                       .cbs.cli_show = cli_show_isis_mpls_te,
                },
                {
                        .xpath = "/frr-isisd:isis/mpls-te/router-address",
                        .cbs.modify = isis_mpls_te_router_address_modify,
                        .cbs.delete = isis_mpls_te_router_address_delete,
+                       .cbs.cli_show = cli_show_isis_mpls_te_router_addr,
                },
                {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis",
index 08b905c65032fd89ca22169329ac76cc45151d62..a69c95cadf8ce9073661cf07e5f00a68e39fa7bf 100644 (file)
@@ -1087,141 +1087,6 @@ static struct mpls_te_circuit *lookup_mpls_params_by_ifp(struct interface *ifp)
        return circuit->mtc;
 }
 
-DEFUN (isis_mpls_te_on,
-       isis_mpls_te_on_cmd,
-       "mpls-te on",
-       MPLS_TE_STR
-       "Enable MPLS-TE functionality\n")
-{
-       struct listnode *node;
-       struct isis_circuit *circuit;
-
-       if (IS_MPLS_TE(isisMplsTE))
-               return CMD_SUCCESS;
-
-       if (IS_DEBUG_ISIS(DEBUG_TE))
-               zlog_debug("ISIS MPLS-TE: OFF -> ON");
-
-       isisMplsTE.status = enable;
-
-       /*
-        * Following code is intended to handle two cases;
-        *
-        * 1) MPLS-TE was disabled at startup time, but now become enabled.
-        * In this case, we must enable MPLS-TE Circuit regarding interface
-        * MPLS_TE flag
-        * 2) MPLS-TE was once enabled then disabled, and now enabled again.
-        */
-       for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) {
-               if (circuit->mtc == NULL || IS_FLOOD_AS(circuit->mtc->type))
-                       continue;
-
-               if ((circuit->mtc->status == disable)
-                   && HAS_LINK_PARAMS(circuit->interface))
-                       circuit->mtc->status = enable;
-               else
-                       continue;
-
-               /* Reoriginate STD_TE & GMPLS circuits */
-               if (circuit->area)
-                       lsp_regenerate_schedule(circuit->area, circuit->is_type,
-                                               0);
-       }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_mpls_te_on,
-       no_isis_mpls_te_on_cmd,
-       "no mpls-te",
-       NO_STR
-       "Disable the MPLS-TE functionality\n")
-{
-       struct listnode *node;
-       struct isis_circuit *circuit;
-
-       if (isisMplsTE.status == disable)
-               return CMD_SUCCESS;
-
-       if (IS_DEBUG_ISIS(DEBUG_TE))
-               zlog_debug("ISIS MPLS-TE: ON -> OFF");
-
-       isisMplsTE.status = disable;
-
-       /* Flush LSP if circuit engage */
-       for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) {
-               if (circuit->mtc == NULL || (circuit->mtc->status == disable))
-                       continue;
-
-               /* disable MPLS_TE Circuit */
-               circuit->mtc->status = disable;
-
-               /* Re-originate circuit without STD_TE & GMPLS parameters */
-               if (circuit->area)
-                       lsp_regenerate_schedule(circuit->area, circuit->is_type,
-                                               0);
-       }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (isis_mpls_te_router_addr,
-       isis_mpls_te_router_addr_cmd,
-       "mpls-te router-address A.B.C.D",
-       MPLS_TE_STR
-       "Stable IP address of the advertising router\n"
-       "MPLS-TE router address in IPv4 address format\n")
-{
-       int idx_ipv4 = 2;
-       struct in_addr value;
-       struct listnode *node;
-       struct isis_area *area;
-
-       if (!inet_aton(argv[idx_ipv4]->arg, &value)) {
-               vty_out(vty, "Please specify Router-Addr by A.B.C.D\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       isisMplsTE.router_id.s_addr = value.s_addr;
-
-       if (isisMplsTE.status == disable)
-               return CMD_SUCCESS;
-
-       /* Update main Router ID in isis global structure */
-       isis->router_id = value.s_addr;
-       /* And re-schedule LSP update */
-       for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
-               if (listcount(area->area_addrs) > 0)
-                       lsp_regenerate_schedule(area, area->is_type, 0);
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (isis_mpls_te_inter_as,
-       isis_mpls_te_inter_as_cmd,
-       "mpls-te inter-as <level-1|level-1-2|level-2-only>",
-       MPLS_TE_STR
-       "Configure MPLS-TE Inter-AS support\n"
-       "AREA native mode self originate INTER-AS LSP with L1 only flooding scope)\n"
-       "AREA native mode self originate INTER-AS LSP with L1 and L2 flooding scope)\n"
-       "AS native mode self originate INTER-AS LSP with L2 only flooding scope\n")
-{
-       vty_out(vty, "Not yet supported\n");
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_mpls_te_inter_as,
-       no_isis_mpls_te_inter_as_cmd,
-       "no mpls-te inter-as",
-       NO_STR
-       "Disable the MPLS-TE functionality\n"
-       "Disable MPLS-TE Inter-AS support\n")
-{
-
-       vty_out(vty, "Not yet supported\n");
-       return CMD_SUCCESS;
-}
-
 DEFUN (show_isis_mpls_te_router,
        show_isis_mpls_te_router_cmd,
        "show " PROTO_NAME " mpls-te router",
@@ -1363,12 +1228,6 @@ void isis_mpls_te_init(void)
        /* Register new VTY commands */
        install_element(VIEW_NODE, &show_isis_mpls_te_router_cmd);
        install_element(VIEW_NODE, &show_isis_mpls_te_interface_cmd);
-
-       install_element(ROUTER_NODE, &isis_mpls_te_on_cmd);
-       install_element(ROUTER_NODE, &no_isis_mpls_te_on_cmd);
-       install_element(ROUTER_NODE, &isis_mpls_te_router_addr_cmd);
-       install_element(ROUTER_NODE, &isis_mpls_te_inter_as_cmd);
-       install_element(ROUTER_NODE, &no_isis_mpls_te_inter_as_cmd);
 #endif
 
        return;