Skip to content

Commit

Permalink
zebra: add zebra to mgmtd oper-state
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Oct 6, 2023
1 parent a90a510 commit 77cadfb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/mgmt_be_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct mgmt_be_client {
struct debug mgmt_dbg_be_client = {0, "Management backend client operations"};

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
Expand Down
1 change: 1 addition & 0 deletions lib/mgmt_be_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
11 changes: 10 additions & 1 deletion mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ static const char *const *be_client_xpaths[] = {
#endif
};

static const char **be_client_oper_xpaths[] = {};
static const char *const zebra_oper_xpaths[] = {
"/frr-interface:lib/frr-interface:interface/frr-zebra:zebra/*",
"/frr-vrf:lib/vrf/frr-zebra:zebra/*",
"/frr-zebra:zebra/*",
NULL,
};

static const char *const *be_client_oper_xpaths[] = {
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
};

/*
* We would like to have a better ADT than one with O(n) comparisons
Expand Down
2 changes: 2 additions & 0 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
* NOTE: Always set .ignore_cbs true for to avoid validating
* backend northbound callbacks during loading.
*/
&(struct frr_yang_module_info){.name = "frr-zebra",
.ignore_cbs = true},
#ifdef HAVE_STATICD
&(struct frr_yang_module_info){.name = "frr-staticd",
.ignore_cbs = true},
Expand Down
4 changes: 4 additions & 0 deletions zebra/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <zebra.h>
#include "command.h"
#include "debug.h"
#include "mgmt_be_client.h"

#include "zebra/debug_clippy.c"

Expand Down Expand Up @@ -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();
}
7 changes: 7 additions & 0 deletions zebra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,6 +55,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;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -418,6 +423,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();
rtadv_cmd_init();
Expand Down
4 changes: 4 additions & 0 deletions zebra/zebra_nb_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 77cadfb

Please sign in to comment.