]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add zebra to mgmtd oper-state
authorChristian Hopps <chopps@labn.net>
Tue, 3 Oct 2023 21:53:11 +0000 (17:53 -0400)
committerChristian Hopps <chopps@labn.net>
Thu, 28 Dec 2023 17:53:40 +0000 (17:53 +0000)
Signed-off-by: Christian Hopps <chopps@labn.net>
mgmtd/mgmt_be_adapter.c
mgmtd/mgmt_be_adapter.h
mgmtd/mgmt_main.c
python/xref2vtysh.py
zebra/debug.c
zebra/main.c
zebra/zebra_nb_state.c

index 72dff4b062d9d900d3acacc515eabd97ef26c49a..0d678452f7da4d9fb94605c389b8617f6dfa9234 100644 (file)
@@ -35,6 +35,7 @@
 /* ---------- */
 
 const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = {
+       [MGMTD_BE_CLIENT_ID_ZEBRA] = "zebra",
 #ifdef HAVE_STATICD
        [MGMTD_BE_CLIENT_ID_STATICD] = "staticd",
 #endif
@@ -73,7 +74,16 @@ static const char *const *be_client_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
 #endif
 };
 
-static const char *const *be_client_oper_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {};
+static const char *const zebra_oper_xpaths[] = {
+       "/frr-interface:lib/interface",
+       "/frr-vrf:lib/vrf/frr-zebra:zebra",
+       "/frr-zebra:zebra",
+       NULL,
+};
+
+static const char *const *be_client_oper_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
+       [MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
+};
 
 /*
  * We would like to have a better ADT than one with O(n) comparisons
index 2afac949f5a884ed93132dd365c0a608c1b782b5..96e807f6c41920fa4e4be087f4652307edb81c67 100644 (file)
@@ -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
 };
 #define MGMTD_BE_CLIENT_ID_MIN 0
index b58b93c71d1742e785f8eb65ffd57fa38cf502c9..793161dc320402414ff80253d76066947c8587b0 100644 (file)
@@ -207,6 +207,16 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
  * NOTE: Always set .ignore_cbs true for to avoid validating
  * backend configuration northbound callbacks during loading.
  */
+       &(struct frr_yang_module_info){ .name = "frr-zebra",
+                                       .ignore_cbs = true },
+       /*
+        * TO support LYD_LYB parsing we have to include all the modules that
+        * backend clients include.
+        */
+       &(struct frr_yang_module_info){ .name = "frr-affinity-map",
+               .ignore_cbs = true },
+       &(struct frr_yang_module_info){ .name = "frr-zebra-route-map",
+               .ignore_cbs = true },
 #ifdef HAVE_STATICD
        &frr_staticd_info,
 #endif
index 0a7e28ec7ac1e2866b1f32739baccfedf8b87fb8..75fff8ddd9c399695979d49bfc042dea85e35fb8 100644 (file)
@@ -37,7 +37,7 @@ daemon_flags = {
     "lib/filter_cli.c": "VTYSH_ACL",
     "lib/if.c": "VTYSH_INTERFACE",
     "lib/keychain.c": "VTYSH_KEYS",
-    "lib/mgmt_be_client.c": "VTYSH_STATICD",
+    "lib/mgmt_be_client.c": "VTYSH_STATICD|VTYSH_ZEBRA",
     "lib/mgmt_fe_client.c": "VTYSH_MGMTD",
     "lib/lib_vty.c": "VTYSH_ALL",
     "lib/log_vty.c": "VTYSH_ALL",
index 68bedaf0578abcddb74e3c663117e6c440954f2d..cf1701be1938624c531aac4cece498a962c3c159 100644 (file)
@@ -7,6 +7,7 @@
 #include <zebra.h>
 #include "command.h"
 #include "debug.h"
+#include "mgmt_be_client.h"
 
 #include "zebra/debug_clippy.c"
 
@@ -846,4 +847,7 @@ void zebra_debug_init(void)
        install_element(CONFIG_NODE, &no_debug_zebra_pbr_cmd);
        install_element(CONFIG_NODE, &debug_zebra_mlag_cmd);
        install_element(CONFIG_NODE, &debug_zebra_evpn_mh_cmd);
+
+       /* Init mgmtd backend client debug commands. */
+       mgmt_be_client_lib_vty_init();
 }
index 604d8974b3051cd93f9de05419df7caa7b3590b3..be3b22590e7f801d2f68a9472c59ca39b40b8d19 100644 (file)
@@ -25,6 +25,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"
@@ -58,6 +59,8 @@ pid_t pid;
 /* Pacify zclient.o in libfrr, which expects this variable. */
 struct event_loop *master;
 
+struct mgmt_be_client *mgmt_be_client;
+
 /* Route retain mode flag. */
 int retain_mode = 0;
 
@@ -142,6 +145,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);
 
@@ -430,6 +435,8 @@ int main(int argc, char **argv)
        zebra_ns_init();
        router_id_cmd_init();
        zebra_vty_init();
+       mgmt_be_client = mgmt_be_client_create("zebra", NULL, 0,
+                                              zrouter.master);
        access_list_init();
        prefix_list_init();
 
index ba537475cbccca3f558f9dd93cb4ba1c9b7fb54f..4fa6587b0a93e408efacfd649cae976439957045 100644 (file)
@@ -156,6 +156,8 @@ const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args)
        safi_t safi;
 
        zvrf = zebra_vrf_lookup_by_id(vrf->vrf_id);
+       if (!zvrf)
+               return NULL;
 
        if (args->list_entry == NULL) {
                afi = AFI_IP;
@@ -198,6 +200,8 @@ lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args)
        uint32_t table_id = 0;
 
        zvrf = zebra_vrf_lookup_by_id(vrf->vrf_id);
+       if (!zvrf)
+               return NULL;
 
        yang_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
        table_id = yang_str2uint32(args->keys->key[1]);