summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/grammar_sandbox_main.c2
-rw-r--r--lib/libfrr.c3
-rw-r--r--lib/libfrr.h5
-rw-r--r--lib/log.c1
-rw-r--r--lib/northbound.c4
-rw-r--r--lib/northbound.h8
-rw-r--r--lib/yang.c10
-rw-r--r--lib/yang.h10
-rw-r--r--lib/yang_translator.c4
-rw-r--r--lib/zclient.h1
10 files changed, 30 insertions, 18 deletions
diff --git a/lib/grammar_sandbox_main.c b/lib/grammar_sandbox_main.c
index abd42f359f..05088d52d1 100644
--- a/lib/grammar_sandbox_main.c
+++ b/lib/grammar_sandbox_main.c
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
vty_init(master, true);
lib_cmd_init();
- nb_init(master, NULL, 0, false);
+ nb_init(master, NULL, 0, false, false);
vty_stdio(vty_do_exit);
diff --git a/lib/libfrr.c b/lib/libfrr.c
index a1982841d3..f2247a48e5 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -820,7 +820,8 @@ struct event_loop *frr_init(void)
log_ref_vty_init();
lib_error_init();
- nb_init(master, di->yang_modules, di->n_yang_modules, true);
+ nb_init(master, di->yang_modules, di->n_yang_modules, true,
+ (di->flags & FRR_LOAD_YANG_LIBRARY) != 0);
if (nb_db_init() != NB_OK)
flog_warn(EC_LIB_NB_DATABASE,
"%s: failed to initialize northbound database",
diff --git a/lib/libfrr.h b/lib/libfrr.h
index 7ed7be4d98..df537e2e3b 100644
--- a/lib/libfrr.h
+++ b/lib/libfrr.h
@@ -46,6 +46,11 @@ extern "C" {
* is responsible for calling frr_vty_serv() itself.
*/
#define FRR_MANUAL_VTY_START (1 << 7)
+/* If FRR_LOAD_YANG_LIBRARY is set then libyang will be told to load and
+ * implement it's internal ietf-yang-library implementation. This should
+ * normally only be done from mgmtd.
+ */
+#define FRR_LOAD_YANG_LIBRARY (1 << 8)
PREDECL_DLIST(log_args);
struct log_arg {
diff --git a/lib/log.c b/lib/log.c
index 880180ae5a..04b789b5da 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -351,7 +351,6 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_BFD_DEST_REPLAY),
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ROUTE_ADD),
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ROUTE_DEL),
- DESC_ENTRY(ZEBRA_VRF_UNREGISTER),
DESC_ENTRY(ZEBRA_VRF_ADD),
DESC_ENTRY(ZEBRA_VRF_DELETE),
DESC_ENTRY(ZEBRA_VRF_LABEL),
diff --git a/lib/northbound.c b/lib/northbound.c
index 2dae21341e..a385cc9ece 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -2701,7 +2701,7 @@ void nb_validate_callbacks(void)
void nb_init(struct event_loop *tm,
const struct frr_yang_module_info *const modules[],
- size_t nmodules, bool db_enabled)
+ size_t nmodules, bool db_enabled, bool load_library)
{
struct yang_module *loaded[nmodules], **loadedp = loaded;
@@ -2717,7 +2717,7 @@ void nb_init(struct event_loop *tm,
nb_db_enabled = db_enabled;
- yang_init(true, explicit_compile);
+ yang_init(true, explicit_compile, load_library);
/* Load YANG modules and their corresponding northbound callbacks. */
for (size_t i = 0; i < nmodules; i++) {
diff --git a/lib/northbound.h b/lib/northbound.h
index dd3fbf8f73..97a1d31e57 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -1703,10 +1703,12 @@ void nb_validate_callbacks(void);
*
* db_enabled
* Set this to record the transactions in the transaction log.
+ *
+ * load_library
+ * Set this to have libyang to load/implement the ietf-yang-library.
*/
-extern void nb_init(struct event_loop *tm,
- const struct frr_yang_module_info *const modules[],
- size_t nmodules, bool db_enabled);
+extern void nb_init(struct event_loop *tm, const struct frr_yang_module_info *const modules[],
+ size_t nmodules, bool db_enabled, bool load_library);
/*
* Finish the northbound layer gracefully. Should be called only when the daemon
diff --git a/lib/yang.c b/lib/yang.c
index 14d5b118c6..b847b8b77b 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -976,7 +976,7 @@ void yang_debugging_set(bool enable)
}
}
-struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile)
+struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile, bool load_library)
{
struct ly_ctx *ctx = NULL;
const char *yang_models_path = YANG_MODELS_PATH;
@@ -994,7 +994,9 @@ struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile)
YANG_MODELS_PATH);
}
- options = LY_CTX_NO_YANGLIBRARY | LY_CTX_DISABLE_SEARCHDIR_CWD;
+ options = LY_CTX_DISABLE_SEARCHDIR_CWD;
+ if (!load_library)
+ options |= LY_CTX_NO_YANGLIBRARY;
if (explicit_compile)
options |= LY_CTX_EXPLICIT_COMPILE;
err = ly_ctx_new(yang_models_path, options, &ctx);
@@ -1007,7 +1009,7 @@ struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile)
return ctx;
}
-void yang_init(bool embedded_modules, bool defer_compile)
+void yang_init(bool embedded_modules, bool defer_compile, bool load_library)
{
/* Initialize libyang global parameters that affect all containers. */
ly_set_log_clb(ly_zlog_cb
@@ -1019,7 +1021,7 @@ void yang_init(bool embedded_modules, bool defer_compile)
ly_log_options(LY_LOLOG | LY_LOSTORE);
/* Initialize libyang container for native models. */
- ly_native_ctx = yang_ctx_new_setup(embedded_modules, defer_compile);
+ ly_native_ctx = yang_ctx_new_setup(embedded_modules, defer_compile, load_library);
if (!ly_native_ctx) {
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);
diff --git a/lib/yang.h b/lib/yang.h
index c4fc78b8ae..52857ecf00 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -607,9 +607,11 @@ extern struct yang_data *yang_data_list_find(const struct list *list,
* explicit_compile
* True if the caller will later call ly_ctx_compile to compile all loaded
* modules at once.
+ * load_library
+ * Set this to have libyang to load/implement the ietf-yang-library.
*/
-extern struct ly_ctx *yang_ctx_new_setup(bool embedded_modules,
- bool explicit_compile);
+extern struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile,
+ bool load_library);
/*
* Enable or disable libyang verbose debugging.
@@ -727,8 +729,10 @@ extern const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf,
* Specify whether libyang should attempt to look for embedded YANG modules.
* defer_compile
* Hold off on compiling modules until yang_init_loading_complete is called.
+ * load_library
+ * Set this to have libyang to load/implement the ietf-yang-library.
*/
-extern void yang_init(bool embedded_modules, bool defer_compile);
+extern void yang_init(bool embedded_modules, bool defer_compile, bool load_library);
/*
* Should be called after yang_init and all yang_module_load()s have been done,
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index 005f6422f3..b7599e0a71 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -166,7 +166,7 @@ struct yang_translator *yang_translator_load(const char *path)
RB_INSERT(yang_translators, &yang_translators, translator);
/* Initialize the translator libyang context. */
- translator->ly_ctx = yang_ctx_new_setup(false, false);
+ translator->ly_ctx = yang_ctx_new_setup(false, false, false);
if (!translator->ly_ctx) {
flog_warn(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
goto error;
@@ -512,7 +512,7 @@ static unsigned int yang_module_nodes_count(const struct lys_module *module)
void yang_translator_init(void)
{
- ly_translator_ctx = yang_ctx_new_setup(true, false);
+ ly_translator_ctx = yang_ctx_new_setup(true, false, false);
if (!ly_translator_ctx) {
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);
diff --git a/lib/zclient.h b/lib/zclient.h
index 2877b347d8..91c0c9ed6d 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -124,7 +124,6 @@ typedef enum {
ZEBRA_BFD_DEST_REPLAY,
ZEBRA_REDISTRIBUTE_ROUTE_ADD,
ZEBRA_REDISTRIBUTE_ROUTE_DEL,
- ZEBRA_VRF_UNREGISTER,
ZEBRA_VRF_ADD,
ZEBRA_VRF_DELETE,
ZEBRA_VRF_LABEL,