mirror of
https://github.com/FRRouting/frr.git
synced 2026-01-16 23:14:01 +00:00
lib: add northbound support for frr-host YANG module
- Everyone loads frr-host module to process host config Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
8a3965ef19
commit
3bd8347f9a
5 changed files with 69 additions and 3 deletions
37
lib/host_nb.c
Normal file
37
lib/host_nb.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* June 12 2025, Christian Hopps <chopps@labn.net>
|
||||
*
|
||||
* Copyright (c) 2025, LabN Consulting, L.L.C.
|
||||
*
|
||||
*/
|
||||
#include <zebra.h>
|
||||
#include "northbound.h"
|
||||
#include "command.h"
|
||||
#include "host_nb.h"
|
||||
|
||||
/*
|
||||
* XPath: /frr-host:host/allow-reserved-ranges
|
||||
*/
|
||||
static int host_allow_reserved_ranges_modify(struct nb_cb_modify_args *args)
|
||||
{
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
host.allow_reserved_ranges = yang_dnode_get_bool(args->dnode, NULL);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
const struct frr_yang_module_info frr_host_nb_info = {
|
||||
.name = "frr-host",
|
||||
.nodes = {
|
||||
{ .xpath = "/frr-host:host/allow-reserved-ranges",
|
||||
.cbs.modify = host_allow_reserved_ranges_modify,
|
||||
.priority = NB_DFLT_PRIORITY - 3,
|
||||
},
|
||||
{ .xpath = NULL },
|
||||
}
|
||||
};
|
||||
/* clang-format on */
|
||||
12
lib/host_nb.h
Normal file
12
lib/host_nb.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* June 13 2025, Christian Hopps <chopps@labn.net>
|
||||
*
|
||||
* Copyright (c) 2025, LabN Consulting, L.L.C.
|
||||
*
|
||||
*/
|
||||
#include <zebra.h>
|
||||
#include "command.h"
|
||||
|
||||
extern const struct frr_yang_module_info frr_host_nb_info;
|
||||
extern struct host host;
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include <zebra.h>
|
||||
|
||||
#include "darr.h"
|
||||
#include "host_nb.h"
|
||||
#include "libfrr.h"
|
||||
#include "log.h"
|
||||
#include "lib_errors.h"
|
||||
|
|
@ -2753,7 +2754,7 @@ void nb_init(struct event_loop *tm,
|
|||
const struct frr_yang_module_info *const modules[],
|
||||
size_t nmodules, bool db_enabled, bool load_library)
|
||||
{
|
||||
struct yang_module *loaded[nmodules];
|
||||
struct yang_module *loaded[nmodules + 1];
|
||||
|
||||
/*
|
||||
* Currently using this explicit compile feature in libyang2 leads to
|
||||
|
|
@ -2777,14 +2778,21 @@ void nb_init(struct event_loop *tm,
|
|||
loaded[i]->frr_info = modules[i];
|
||||
}
|
||||
|
||||
/* Load the host module if it is not already. */
|
||||
if (!yang_module_find("frr-host")) {
|
||||
loaded[nmodules] = yang_module_load("frr-host", NULL);
|
||||
loaded[nmodules]->frr_info = &frr_host_nb_info;
|
||||
nmodules++;
|
||||
}
|
||||
|
||||
if (explicit_compile)
|
||||
yang_init_loading_complete();
|
||||
|
||||
/* Initialize the compiled nodes with northbound data */
|
||||
for (size_t i = 0; i < nmodules; i++) {
|
||||
yang_snodes_iterate(loaded[i]->info, nb_node_new_cb, 0,
|
||||
(void *)modules[i]);
|
||||
nb_load_callbacks(modules[i]);
|
||||
(void *)loaded[i]->frr_info);
|
||||
nb_load_callbacks(loaded[i]->frr_info);
|
||||
}
|
||||
|
||||
/* Validate northbound callbacks. */
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ lib_libfrr_la_SOURCES = \
|
|||
lib/grammar_sandbox.c \
|
||||
lib/graph.c \
|
||||
lib/hash.c \
|
||||
lib/host_nb.c \
|
||||
lib/hook.c \
|
||||
lib/id_alloc.c \
|
||||
lib/if.c \
|
||||
|
|
@ -147,6 +148,7 @@ nodist_lib_libfrr_la_SOURCES = \
|
|||
yang/frr-affinity-map.yang.c \
|
||||
yang/frr-backend.yang.c \
|
||||
yang/frr-filter.yang.c \
|
||||
yang/frr-host.yang.c \
|
||||
yang/frr-if-rmap.yang.c \
|
||||
yang/frr-interface.yang.c \
|
||||
yang/frr-route-map.yang.c \
|
||||
|
|
@ -226,6 +228,7 @@ pkginclude_HEADERS += \
|
|||
lib/graph.h \
|
||||
lib/hash.h \
|
||||
lib/hook.h \
|
||||
lib/host_nb.h \
|
||||
lib/iana_afi.h \
|
||||
lib/id_alloc.h \
|
||||
lib/if.h \
|
||||
|
|
|
|||
|
|
@ -63,9 +63,11 @@ struct mgmt_be_xpath_map {
|
|||
* above map as well.
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
static const char *const zebra_config_xpaths[] = {
|
||||
"/frr-affinity-map:lib",
|
||||
"/frr-filter:lib",
|
||||
"/frr-host:host",
|
||||
"/frr-route-map:lib",
|
||||
"/frr-zebra:zebra",
|
||||
"/frr-interface:lib",
|
||||
|
|
@ -91,6 +93,7 @@ static const char *const mgmtd_testc_oper_xpaths[] = {
|
|||
#ifdef HAVE_RIPD
|
||||
static const char *const ripd_config_xpaths[] = {
|
||||
"/frr-filter:lib",
|
||||
"/frr-host:host",
|
||||
"/frr-interface:lib/interface",
|
||||
"/frr-ripd:ripd",
|
||||
"/frr-route-map:lib",
|
||||
|
|
@ -113,6 +116,7 @@ static const char *const ripd_rpc_xpaths[] = {
|
|||
#ifdef HAVE_RIPNGD
|
||||
static const char *const ripngd_config_xpaths[] = {
|
||||
"/frr-filter:lib",
|
||||
"/frr-host:host",
|
||||
"/frr-interface:lib/interface",
|
||||
"/frr-ripngd:ripngd",
|
||||
"/frr-route-map:lib",
|
||||
|
|
@ -132,6 +136,7 @@ static const char *const ripngd_rpc_xpaths[] = {
|
|||
|
||||
#ifdef HAVE_STATICD
|
||||
static const char *const staticd_config_xpaths[] = {
|
||||
"/frr-host:host",
|
||||
"/frr-vrf:lib",
|
||||
"/frr-interface:lib",
|
||||
"/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd",
|
||||
|
|
@ -143,6 +148,7 @@ static const char *const staticd_oper_xpaths[] = {
|
|||
NULL,
|
||||
};
|
||||
#endif
|
||||
/* clang-format on */
|
||||
|
||||
static const char *const *be_client_config_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
|
||||
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_config_xpaths,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue