]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface link-detect command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 17 Jan 2024 12:58:03 +0000 (14:58 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Sun, 28 Jan 2024 21:28:39 +0000 (23:28 +0200)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
yang/frr-zebra.yang
zebra/interface.c
zebra/zebra_nb.c
zebra/zebra_nb.h
zebra/zebra_nb_config.c

index 1168f05f4031582db52af2db3cbf9c0ddd08b635..c9486643367f1f18f9511f11dd08d0b4c25019ef 100644 (file)
@@ -1972,6 +1972,7 @@ module frr-zebra {
 
       leaf link-detect {
         type boolean;
+        default "true";
         description
           "Link-detection for the interface.";
       }
index 541803eb9f5edcafc057b53db9975fd5a0a787dd..219dff083bafa4d9c9cf26e40c462f47b4cc7236 100644 (file)
@@ -3801,28 +3801,16 @@ int if_linkdetect(struct interface *ifp, bool detect)
        return 0;
 }
 
-DEFUN(linkdetect, linkdetect_cmd, "link-detect",
+DEFPY_YANG (linkdetect,
+      linkdetect_cmd,
+      "[no] link-detect",
+      NO_STR
       "Enable link detection on interface\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-
-       if_linkdetect(ifp, true);
-
-       return CMD_SUCCESS;
-}
-
-
-DEFUN (no_linkdetect,
-       no_linkdetect_cmd,
-       "no link-detect",
-       NO_STR
-       "Disable link detection on interface\n")
-{
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-
-       if_linkdetect(ifp, false);
-
-       return CMD_SUCCESS;
+       nb_cli_enqueue_change(vty, "./frr-zebra:zebra/link-detect",
+                             NB_OP_CREATE, no ? "false" : "true");
+       
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 int if_shutdown(struct interface *ifp)
@@ -5569,7 +5557,6 @@ void zebra_if_init(void)
        install_element(INTERFACE_NODE, &no_multicast_cmd);
        install_element(INTERFACE_NODE, &mpls_cmd);
        install_element(INTERFACE_NODE, &linkdetect_cmd);
-       install_element(INTERFACE_NODE, &no_linkdetect_cmd);
        install_element(INTERFACE_NODE, &shutdown_if_cmd);
        install_element(INTERFACE_NODE, &no_shutdown_if_cmd);
        install_element(INTERFACE_NODE, &bandwidth_if_cmd);
index 7cdcaedd7e30d486590f7109ddf4722148877620..de94480d1b71511d9dda35da47d954bd0df98089 100644 (file)
@@ -321,7 +321,6 @@ const struct frr_yang_module_info frr_zebra_info = {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/link-detect",
                        .cbs = {
                                .modify = lib_interface_zebra_link_detect_modify,
-                               .destroy = lib_interface_zebra_link_detect_destroy,
                        }
                },
                {
index 6762ebd3140823c3448505476f0b82759d6222a1..c781675287db4b6f7bae914a34f3eaf9ca2cda24 100644 (file)
@@ -91,7 +91,6 @@ int lib_interface_zebra_ip_addrs_ip4_peer_destroy(
 int lib_interface_zebra_multicast_modify(struct nb_cb_modify_args *args);
 int lib_interface_zebra_multicast_destroy(struct nb_cb_destroy_args *args);
 int lib_interface_zebra_link_detect_modify(struct nb_cb_modify_args *args);
-int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args *args);
 int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args);
 int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args *args);
 int lib_interface_zebra_bandwidth_modify(struct nb_cb_modify_args *args);
index c51250e76fb22292798cb8b492b8d85df23ce662..b148363032b07312213e81bc0293de7c7be6c925 100644 (file)
@@ -1039,23 +1039,7 @@ int lib_interface_zebra_link_detect_modify(struct nb_cb_modify_args *args)
        bool link_detect;
 
        ifp = nb_running_get_entry(args->dnode, NULL, true);
-       link_detect = yang_dnode_get_bool(args->dnode, "link-detect");
-
-       if_linkdetect(ifp, link_detect);
-
-       return NB_OK;
-}
-
-int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args *args)
-{
-       if (args->event != NB_EV_APPLY)
-               return NB_OK;
-
-       struct interface *ifp;
-       bool link_detect;
-
-       ifp = nb_running_get_entry(args->dnode, NULL, true);
-       link_detect = yang_dnode_get_bool(args->dnode, "link-detect");
+       link_detect = yang_dnode_get_bool(args->dnode, NULL);
 
        if_linkdetect(ifp, link_detect);