]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: retrofit the 'isis circuit-type' command
authorEmanuele Di Pascale <emanuele@voltanet.io>
Thu, 15 Nov 2018 11:11:19 +0000 (12:11 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:24:46 +0000 (15:24 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_cli.c
isisd/isis_cli.h
isisd/isis_northbound.c
isisd/isis_vty_isisd.c

index 809e17d477af3f4ba68c486282c883451ff22cf3..1102005d8c702fd85570afc4bba975a31c259003 100644 (file)
@@ -1704,6 +1704,101 @@ void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, " isis topology ipv6-dstsrc\n");
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type
+ */
+DEFPY(isis_circuit_type, isis_circuit_type_cmd,
+      "isis circuit-type <level-1|level-1-2|level-2-only>$type",
+      "IS-IS routing protocol\n"
+      "Configure circuit type for interface\n"
+      "Level-1 only adjacencies are formed\n"
+      "Level-1-2 adjacencies are formed\n"
+      "Level-2 only adjacencies are formed\n")
+{
+       nb_cli_enqueue_change(
+               vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
+               strmatch(type, "level-2-only") ? "level-2" : type);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY(no_isis_circuit_type, no_isis_circuit_type_cmd,
+      "no isis circuit-type [level-1|level-1-2|level-2-only]",
+      NO_STR
+      "IS-IS routing protocol\n"
+      "Configure circuit type for interface\n"
+      "Level-1 only adjacencies are formed\n"
+      "Level-1-2 adjacencies are formed\n"
+      "Level-2 only adjacencies are formed\n")
+{
+       const struct lyd_node *dnode;
+       struct interface *ifp;
+       struct isis_circuit *circuit;
+       int is_type;
+       const char *circ_type;
+
+       /*
+        * Default value depends on whether the circuit is part of an area,
+        * and the is-type of the area if there is one. So we need to do this
+        * here.
+        */
+       dnode = yang_dnode_get(running_config->dnode, VTY_CURR_XPATH);
+       ifp = yang_dnode_get_entry(dnode, false);
+       if (!ifp)
+               goto def_val;
+
+       circuit = circuit_scan_by_ifp(ifp);
+       if (!circuit)
+               goto def_val;
+
+       if (circuit->state == C_STATE_UP)
+               is_type = circuit->area->is_type;
+       else
+               goto def_val;
+
+       switch (is_type) {
+       case IS_LEVEL_1:
+               circ_type = "level-1";
+               break;
+       case IS_LEVEL_2:
+               circ_type = "level-2";
+               break;
+       case IS_LEVEL_1_AND_2:
+               circ_type = "level-1-2";
+               break;
+       default:
+               return CMD_ERR_NO_MATCH;
+       }
+       nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
+                             NB_OP_MODIFY, circ_type);
+
+       return nb_cli_apply_changes(vty, NULL);
+
+def_val:
+       nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
+                             NB_OP_MODIFY, NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
+                               bool show_defaults)
+{
+       int level = yang_dnode_get_enum(dnode, NULL);
+
+       switch (level) {
+       case IS_LEVEL_1:
+               vty_out(vty, " isis circuit-type level-1\n");
+               break;
+       case IS_LEVEL_2:
+               vty_out(vty, " isis circuit-type level-2-only\n");
+               break;
+       case IS_LEVEL_1_AND_2:
+               vty_out(vty, " isis circuit-type level-1-2\n");
+               break;
+       }
+}
+
 void isis_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_isis_cmd);
@@ -1781,6 +1876,9 @@ void isis_cli_init(void)
        install_element(INTERFACE_NODE, &no_psnp_interval_cmd);
 
        install_element(INTERFACE_NODE, &circuit_topology_cmd);
+
+       install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
+       install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
 }
 
 #endif /* ifndef FABRICD */
index 6b529e71cb23da082d3736bd8cb4b810747334d9..6001f8bcaeaf496a2adae56bb2dfe552bd644d9c 100644 (file)
@@ -113,5 +113,7 @@ void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
                                   bool show_defaults);
 void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
                                     bool show_defaults);
+void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
+                               bool show_defaults);
 
 #endif /* ISISD_ISIS_CLI_H_ */
index 150b5755a5740cba0798d96e2c286fdf64f35fc5..562c77b9d0f60f893998b46009ea7adad796dd76 100644 (file)
@@ -2722,6 +2722,7 @@ const struct frr_yang_module_info frr_isisd_info = {
                {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/circuit-type",
                        .cbs.modify = lib_interface_isis_circuit_type_modify,
+                       .cbs.cli_show = cli_show_ip_isis_circ_type,
                },
                {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv4-routing",
index 198e72964ef11c9a515c2d71dae956c01084afe5..d114085f888019d532c4e6d60110721c4984062d 100644 (file)
@@ -43,66 +43,6 @@ static int level_for_arg(const char *arg)
                return IS_LEVEL_2;
 }
 
-DEFUN (isis_circuit_type,
-       isis_circuit_type_cmd,
-       "isis circuit-type <level-1|level-1-2|level-2-only>",
-       "IS-IS routing protocol\n"
-       "Configure circuit type for interface\n"
-       "Level-1 only adjacencies are formed\n"
-       "Level-1-2 adjacencies are formed\n"
-       "Level-2 only adjacencies are formed\n")
-{
-       int idx_level = 2;
-       int is_type;
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       is_type = string2circuit_t(argv[idx_level]->arg);
-       if (!is_type) {
-               vty_out(vty, "Unknown circuit-type \n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       if (circuit->state == C_STATE_UP
-           && circuit->area->is_type != IS_LEVEL_1_AND_2
-           && circuit->area->is_type != is_type) {
-               vty_out(vty, "Invalid circuit level for area %s.\n",
-                       circuit->area->area_tag);
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-       isis_circuit_is_type_set(circuit, is_type);
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_circuit_type,
-       no_isis_circuit_type_cmd,
-       "no isis circuit-type <level-1|level-1-2|level-2-only>",
-       NO_STR
-       "IS-IS routing protocol\n"
-       "Configure circuit type for interface\n"
-       "Level-1 only adjacencies are formed\n"
-       "Level-1-2 adjacencies are formed\n"
-       "Level-2 only adjacencies are formed\n")
-{
-       int is_type;
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       /*
-        * Set the circuits level to its default value
-        */
-       if (circuit->state == C_STATE_UP)
-               is_type = circuit->area->is_type;
-       else
-               is_type = IS_LEVEL_1_AND_2;
-       isis_circuit_is_type_set(circuit, is_type);
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (isis_network,
        isis_network_cmd,
        "isis network point-to-point",
@@ -221,9 +161,6 @@ DEFUN (no_isis_priority_level,
 
 void isis_vty_daemon_init(void)
 {
-       install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
-       install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
-
        install_element(INTERFACE_NODE, &isis_network_cmd);
        install_element(INTERFACE_NODE, &no_isis_network_cmd);