]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_cli.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / isisd / isis_cli.c
index d2733ebaff58424512da7720bdf2ea9ed284d212..3144b3c28ebafbe6720f16c2f917ee33ac46ace5 100644 (file)
@@ -32,7 +32,7 @@
 #include "yang.h"
 #include "lib/linklist.h"
 #include "isisd/isisd.h"
-#include "isisd/isis_cli.h"
+#include "isisd/isis_nb.h"
 #include "isisd/isis_misc.h"
 #include "isisd/isis_circuit.h"
 #include "isisd/isis_csm.h"
@@ -97,7 +97,8 @@ DEFPY(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag",
                        /* add callbacks to delete each of the circuits listed
                         */
                        const char *vrf_name =
-                               circuit->interface->vrf->name;
+                               vrf_lookup_by_id(circuit->interface->vrf_id)
+                                       ->name;
                        snprintf(
                                temp_xpath, XPATH_MAXLEN,
                                "/frr-interface:lib/interface[name='%s'][vrf='%s']/frr-isisd:isis",
@@ -187,14 +188,10 @@ DEFPY(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
        }
 
        /* check if the interface is a loopback and if so set it as passive */
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
-               if (ifp && if_is_loopback(ifp))
-                       nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
-                                             NB_OP_MODIFY, "true");
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+       if (ifp && if_is_loopback(ifp))
+               nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
+                                     NB_OP_MODIFY, "true");
 
        return nb_cli_apply_changes(vty, NULL);
 }
@@ -261,14 +258,10 @@ DEFPY(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
        }
 
        /* check if the interface is a loopback and if so set it as passive */
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
-               if (ifp && if_is_loopback(ifp))
-                       nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
-                                             NB_OP_MODIFY, "true");
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+       if (ifp && if_is_loopback(ifp))
+               nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
+                                     NB_OP_MODIFY, "true");
 
        return nb_cli_apply_changes(vty, NULL);
 }
@@ -331,6 +324,40 @@ void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
                yang_dnode_get_string(dnode, "../area-tag"));
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring
+ */
+DEFPY(isis_bfd,
+      isis_bfd_cmd,
+      "[no] isis bfd",
+      NO_STR
+      PROTO_HELP
+      "Enable BFD support\n")
+{
+       const struct lyd_node *dnode;
+
+       dnode = yang_dnode_get(vty->candidate_config->dnode,
+                              "%s/frr-isisd:isis", VTY_CURR_XPATH);
+       if (dnode == NULL) {
+               vty_out(vty, "ISIS is not enabled on this circuit\n");
+               return CMD_SUCCESS;
+       }
+
+       nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring",
+                             NB_OP_MODIFY, no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode,
+                                    bool show_defaults)
+{
+       if (!yang_dnode_get_bool(dnode, NULL))
+               vty_out(vty, " no");
+
+       vty_out(vty, " isis bfd\n");
+}
+
 /*
  * XPath: /frr-isisd:isis/instance/area-address
  */
@@ -375,26 +402,20 @@ DEFPY(no_is_type, no_is_type_cmd,
       "Act as both a station router and an area router\n"
       "Act as an area router only\n")
 {
-       const char *value;
-
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               struct isis_area *area;
-
-               area = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+       const char *value = NULL;
+       struct isis_area *area;
 
-               /*
-                * Put the is-type back to defaults:
-                * - level-1-2 on first area
-                * - level-1 for the rest
-                */
-               if (area && listgetdata(listhead(isis->area_list)) == area)
-                       value = "level-1-2";
-               else
-                       value = NULL;
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       area = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
 
+       /*
+        * Put the is-type back to defaults:
+        * - level-1-2 on first area
+        * - level-1 for the rest
+        */
+       if (area && listgetdata(listhead(isis->area_list)) == area)
+               value = "level-1-2";
+       else
+               value = NULL;
        nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY, value);
 
        return nb_cli_apply_changes(vty, NULL);
@@ -1782,45 +1803,52 @@ DEFPY(no_isis_circuit_type, no_isis_circuit_type_cmd,
       "Level-1-2 adjacencies are formed\n"
       "Level-2 only adjacencies are formed\n")
 {
-       const char *circ_type = NULL;
+       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.
         */
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               struct interface *ifp;
-               struct isis_circuit *circuit;
+       ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
+       if (!ifp)
+               goto def_val;
 
-               ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
-               if (!ifp)
-                       goto unlock;
+       circuit = circuit_scan_by_ifp(ifp);
+       if (!circuit)
+               goto def_val;
 
-               circuit = circuit_scan_by_ifp(ifp);
-               if (!circuit || circuit->state != C_STATE_UP)
-                       goto unlock;
+       if (circuit->state == C_STATE_UP)
+               is_type = circuit->area->is_type;
+       else
+               goto def_val;
 
-               switch (circuit->area->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;
-               }
+       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;
        }
-unlock:
-       pthread_rwlock_unlock(&running_config->lock);
-
        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,
@@ -1948,6 +1976,7 @@ void isis_cli_init(void)
        install_element(INTERFACE_NODE, &ip_router_isis_cmd);
        install_element(INTERFACE_NODE, &ip6_router_isis_cmd);
        install_element(INTERFACE_NODE, &no_ip_router_isis_cmd);
+       install_element(INTERFACE_NODE, &isis_bfd_cmd);
 
        install_element(ISIS_NODE, &net_cmd);