diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c index de23cfbaef34..a16359d4a0a8 100644 --- a/lib/mgmt_be_client.c +++ b/lib/mgmt_be_client.c @@ -167,6 +167,7 @@ const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = { #ifdef HAVE_STATICD [MGMTD_BE_CLIENT_ID_STATICD] = "staticd", #endif + [MGMTD_BE_CLIENT_ID_ZEBRA] = "zebra", [MGMTD_BE_CLIENT_ID_MAX] = "Unknown/Invalid", }; diff --git a/lib/mgmt_be_client.h b/lib/mgmt_be_client.h index 4ad5ca5957cd..645bac3b55bf 100644 --- a/lib/mgmt_be_client.h +++ b/lib/mgmt_be_client.h @@ -30,6 +30,7 @@ enum mgmt_be_client_id { #ifdef HAVE_STATICD MGMTD_BE_CLIENT_ID_STATICD, #endif + MGMTD_BE_CLIENT_ID_ZEBRA, MGMTD_BE_CLIENT_ID_MAX }; diff --git a/mgmtd/mgmt_be_adapter.c b/mgmtd/mgmt_be_adapter.c index 1805dcc4ac96..410e643ab06e 100644 --- a/mgmtd/mgmt_be_adapter.c +++ b/mgmtd/mgmt_be_adapter.c @@ -79,6 +79,18 @@ static struct mgmt_be_client_xpath staticd_xpaths[] = { }, }; #endif +static struct mgmt_be_client_xpath zebra_xpaths[] = { + { + .xpath = "/frr-zebra:zebra/*", + .subscribed = MGMT_SUBSCR_VALIDATE_CFG | MGMT_SUBSCR_NOTIFY_CFG + | MGMT_SUBSCR_OPER_OWN, + }, + { + .xpath = "/frr-vrf:lib/vrf[name='*']/frr-zebra:zebra/*", + .subscribed = MGMT_SUBSCR_VALIDATE_CFG | MGMT_SUBSCR_NOTIFY_CFG + | MGMT_SUBSCR_OPER_OWN, + }, +}; static struct mgmt_be_client_xpath_map mgmt_client_xpaths[MGMTD_BE_CLIENT_ID_MAX] = { @@ -86,6 +98,8 @@ static struct mgmt_be_client_xpath_map [MGMTD_BE_CLIENT_ID_STATICD] = {staticd_xpaths, array_size(staticd_xpaths)}, #endif + [MGMTD_BE_CLIENT_ID_ZEBRA] = {zebra_xpaths, + array_size(zebra_xpaths)}, }; /* diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c index 39362fa74a83..d63a456ed7c1 100644 --- a/mgmtd/mgmt_main.c +++ b/mgmtd/mgmt_main.c @@ -207,6 +207,8 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = { &(struct frr_yang_module_info){.name = "frr-staticd", .ignore_cbs = true}, #endif + &(struct frr_yang_module_info){.name = "frr-zebra", + .ignore_cbs = true}, }; FRR_DAEMON_INFO(mgmtd, MGMTD, .vty_port = MGMTD_VTY_PORT, diff --git a/zebra/main.c b/zebra/main.c index 1e833ce7f182..94e830b5d677 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -21,6 +21,7 @@ #include "affinitymap.h" #include "routemap.h" #include "routing_nb.h" +#include "mgmt_be_client.h" #include "zebra/zebra_router.h" #include "zebra/zebra_errors.h" @@ -115,6 +116,8 @@ struct zebra_privs_t zserv_privs = { .cap_num_p = array_size(_caps_p), .cap_num_i = 0}; +struct mgmt_be_client *mgmt_be_client; + /* SIGHUP handler. */ static void sighup(void) { @@ -140,6 +143,8 @@ static void sigint(void) zlog_notice("Terminating on signal"); + mgmt_be_client_destroy(mgmt_be_client); + atomic_store_explicit(&zrouter.in_shutdown, true, memory_order_relaxed); @@ -418,6 +423,11 @@ int main(int argc, char **argv) zebra_ns_init(); router_id_cmd_init(); zebra_vty_init(); + + /* Initialize MGMT backend functionalities */ + mgmt_be_client = mgmt_be_client_create("zebra", NULL, 0, + zrouter.master); + access_list_init(); prefix_list_init(); rtadv_cmd_init(); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d36c2f81c789..80d34b884a57 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -20,6 +20,7 @@ #include "vxlan.h" #include "termtable.h" #include "affinitymap.h" +#include "mgmt_be_client.h" #include "zebra/zebra_router.h" #include "zebra/zserv.h" @@ -4702,4 +4703,6 @@ void zebra_vty_init(void) #endif /* HAVE_SCRIPTING */ install_element(VIEW_NODE, &zebra_show_routing_tables_summary_cmd); + + mgmt_be_client_lib_vty_init(); }