]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: don't use operational data in "no isis circuit-type"
authorIgor Ryzhov <iryzhov@nfware.com>
Mon, 26 Apr 2021 18:34:39 +0000 (21:34 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Thu, 29 Apr 2021 14:05:21 +0000 (17:05 +0300)
Use the config data instead.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
isisd/isis_cli.c

index 9f42a82a1a414bf7f89feba3c91f71455bdba12f..f29d6e3412ebdb7094e657e1f7f810f52f579bb5 100644 (file)
@@ -2503,50 +2503,41 @@ DEFPY_YANG(no_isis_circuit_type, no_isis_circuit_type_cmd,
       "Level-1-2 adjacencies are formed\n"
       "Level-2 only adjacencies are formed\n")
 {
-       struct interface *ifp;
-       struct isis_circuit *circuit;
-       int is_type;
-       const char *circ_type;
+       char inst_xpath[XPATH_MAXLEN];
+       struct lyd_node *if_dnode, *inst_dnode;
+       const char *vrf_name;
+       const char *tag;
+       const char *circ_type = NULL;
 
        /*
         * 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.
         */
-       ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
-       if (!ifp)
-               goto def_val;
+       if_dnode = yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
+       if (!if_dnode) {
+               vty_out(vty, "%% Failed to get iface dnode in candidate DB\n");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
 
-       circuit = circuit_scan_by_ifp(ifp);
-       if (!circuit)
-               goto def_val;
+       if (!yang_dnode_exists(if_dnode, "frr-isisd:isis/area-tag")) {
+               vty_out(vty, "%% ISIS is not configured on the interface\n");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
 
-       if (circuit->state == C_STATE_UP)
-               is_type = circuit->area->is_type;
-       else
-               goto def_val;
+       vrf_name = yang_dnode_get_string(if_dnode, "vrf");
+       tag = yang_dnode_get_string(if_dnode, "frr-isisd:isis/area-tag");
 
-       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);
+       snprintf(inst_xpath, XPATH_MAXLEN,
+                "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag,
+                vrf_name);
 
-       return nb_cli_apply_changes(vty, NULL);
+       inst_dnode = yang_dnode_get(vty->candidate_config->dnode, inst_xpath);
+       if (inst_dnode)
+               circ_type = yang_dnode_get_string(inst_dnode, "is-type");
 
-def_val:
        nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
-                             NB_OP_MODIFY, NULL);
+                             NB_OP_MODIFY, circ_type);
 
        return nb_cli_apply_changes(vty, NULL);
 }