diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-17 14:58:03 +0200 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-28 23:28:39 +0200 |
| commit | df296d54aeb1ccb94ddbf9524a6643aef3783dfc (patch) | |
| tree | 25b4c0b350cb804cbd705c0627acf06898f463e6 | |
| parent | efa18c6c6ff84a71c70435d901421599500af5d2 (diff) | |
zebra: convert interface link-detect command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| -rw-r--r-- | yang/frr-zebra.yang | 1 | ||||
| -rw-r--r-- | zebra/interface.c | 29 | ||||
| -rw-r--r-- | zebra/zebra_nb.c | 1 | ||||
| -rw-r--r-- | zebra/zebra_nb.h | 1 | ||||
| -rw-r--r-- | zebra/zebra_nb_config.c | 18 |
5 files changed, 10 insertions, 40 deletions
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 1168f05f40..c948664336 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -1972,6 +1972,7 @@ module frr-zebra { leaf link-detect { type boolean; + default "true"; description "Link-detection for the interface."; } diff --git a/zebra/interface.c b/zebra/interface.c index 541803eb9f..219dff083b 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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); diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 7cdcaedd7e..de94480d1b 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -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, } }, { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 6762ebd314..c781675287 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -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); diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index c51250e76f..b148363032 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -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); |
