]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, mgmtd: don't register NB config callbacks in mgmtd 15297/head
authorIgor Ryzhov <iryzhov@nfware.com>
Sun, 4 Feb 2024 19:52:47 +0000 (21:52 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Sun, 4 Feb 2024 20:25:57 +0000 (22:25 +0200)
mgmtd is supposed to only register CLI callbacks. If configuration
callbacks are registered, they are getting called on startup when mgmtd
reads config files, and they can use infrastructure that is not
initialized on mgmtd, or allocate some memory that is never freed.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/if.c
lib/if.h
lib/routing_nb.c
lib/routing_nb.h
lib/vrf.c
lib/vrf.h
mgmtd/mgmt_main.c

index 1328e21874a163386cb5410f51d19a3527daef9f..a344c2b8657e32530e8fafc61c997963d279ce6d 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1748,6 +1748,8 @@ lib_interface_state_phy_address_get_elem(struct nb_cb_get_elem_args *args)
 }
 
 /* clang-format off */
+
+/* cli_show callbacks are kept here for daemons not yet converted to mgmtd */
 const struct frr_yang_module_info frr_interface_info = {
        .name = "frr-interface",
        .nodes = {
@@ -1830,3 +1832,26 @@ const struct frr_yang_module_info frr_interface_info = {
                },
        }
 };
+
+const struct frr_yang_module_info frr_interface_cli_info = {
+       .name = "frr-interface",
+       .ignore_cfg_cbs = true,
+       .nodes = {
+               {
+                       .xpath = "/frr-interface:lib/interface",
+                       .cbs = {
+                               .cli_show = cli_show_interface,
+                               .cli_show_end = cli_show_interface_end,
+                       },
+               },
+               {
+                       .xpath = "/frr-interface:lib/interface/description",
+                       .cbs = {
+                               .cli_show = cli_show_interface_desc,
+                       },
+               },
+               {
+                       .xpath = NULL,
+               },
+       }
+};
index 548a91b9480d5b6ee166a93033bf401b7b0843d2..0dc56bd21098a7f12276b36850522d8fd13d08cc 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -636,6 +636,7 @@ extern void if_down_via_zapi(struct interface *ifp);
 extern void if_destroy_via_zapi(struct interface *ifp);
 
 extern const struct frr_yang_module_info frr_interface_info;
+extern const struct frr_yang_module_info frr_interface_cli_info;
 
 #ifdef __cplusplus
 }
index 3d837bcc11491ce1f072157614a6c01848309a31..33372d113a99cf2f2816ab944cabbee46119d1ad 100644 (file)
@@ -27,3 +27,13 @@ const struct frr_yang_module_info frr_routing_info = {
                },
        }
 };
+
+const struct frr_yang_module_info frr_routing_cli_info = {
+       .name = "frr-routing",
+       .ignore_cfg_cbs = true,
+       .nodes = {
+               {
+                       .xpath = NULL,
+               },
+       }
+};
index cc83d8469d2daec41cc346336f33ba347b0a41c9..e805e1cd0fe55a9b5892891ea3059a3122e2e22a 100644 (file)
@@ -6,6 +6,7 @@ extern "C" {
 #endif
 
 extern const struct frr_yang_module_info frr_routing_info;
+extern const struct frr_yang_module_info frr_routing_cli_info;
 
 /* Mandatory callbacks. */
 int routing_control_plane_protocols_control_plane_protocol_create(
index f8fa70bfe84ed1ae3f01ba54899709d4c7eddf43..9f4c5cdddc4b1c43d7a776026db6531ac72d42ee 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -1034,6 +1034,8 @@ lib_vrf_state_active_get_elem(struct nb_cb_get_elem_args *args)
 }
 
 /* clang-format off */
+
+/* cli_show callbacks are kept here for daemons not yet converted to mgmtd */
 const struct frr_yang_module_info frr_vrf_info = {
        .name = "frr-vrf",
        .nodes = {
@@ -1069,3 +1071,19 @@ const struct frr_yang_module_info frr_vrf_info = {
        }
 };
 
+const struct frr_yang_module_info frr_vrf_cli_info = {
+       .name = "frr-vrf",
+       .ignore_cfg_cbs = true,
+       .nodes = {
+               {
+                       .xpath = "/frr-vrf:lib/vrf",
+                       .cbs = {
+                               .cli_show = lib_vrf_cli_write,
+                               .cli_show_end = lib_vrf_cli_write_end,
+                       },
+               },
+               {
+                       .xpath = NULL,
+               },
+       }
+};
index f66a9e6b325ec34cdc279187ae64dae2a7984d11..4277a51bb1b8be863f23535f6d0770462cfe0397 100644 (file)
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -294,6 +294,7 @@ extern int vrf_enable(struct vrf *vrf);
 extern void vrf_delete(struct vrf *vrf);
 
 extern const struct frr_yang_module_info frr_vrf_info;
+extern const struct frr_yang_module_info frr_vrf_cli_info;
 
 #ifdef __cplusplus
 }
index 0f80377d28db85b44d363dbd7443bce0e8cf50e6..c0d90231254b26ccec6c4430ad5a311eac521976 100644 (file)
@@ -171,10 +171,10 @@ const struct frr_yang_module_info zebra_route_map_info = {
  */
 static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
        &frr_filter_cli_info,
-       &frr_interface_info,
+       &frr_interface_cli_info,
        &frr_route_map_cli_info,
-       &frr_routing_info,
-       &frr_vrf_info,
+       &frr_routing_cli_info,
+       &frr_vrf_cli_info,
        &frr_affinity_map_cli_info,
 
        /* mgmtd-only modules */