summaryrefslogtreecommitdiff
path: root/lib/yang.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2020-04-03 19:43:02 -0300
committerRenato Westphal <renato@opensourcerouting.org>2020-04-03 22:34:55 -0300
commitb90204a8e99808378621e50f8e586e6eabb30b76 (patch)
tree1c9b73b4eabb8de2257c409dda4640738faf89c9 /lib/yang.c
parent5f37f5304f337a7fe5e0e80afaa85a108b8bc809 (diff)
lib, tools: silence harmless warnings in the northbound tools
Our two northbound tools don't have embedded YANG modules like the other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be called when the YANG subsystem it being initialized by a northbound tool. To make that possible, add a new "embedded_modules" parameter to the yang_init() function to control whether libyang should look for embedded modules or not. With this fix, "gen_northbound_callbacks" and "gen_yang_deviations" won't emit "YANG model X not embedded, trying external file" warnings anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 93e6db3055..0502d4952d 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -628,7 +628,7 @@ void yang_debugging_set(bool enable)
}
}
-struct ly_ctx *yang_ctx_new_setup(void)
+struct ly_ctx *yang_ctx_new_setup(bool embedded_modules)
{
struct ly_ctx *ctx;
const char *yang_models_path = YANG_MODELS_PATH;
@@ -647,18 +647,21 @@ struct ly_ctx *yang_ctx_new_setup(void)
ctx = ly_ctx_new(yang_models_path, LY_CTX_DISABLE_SEARCHDIR_CWD);
if (!ctx)
return NULL;
- ly_ctx_set_module_imp_clb(ctx, yang_module_imp_clb, NULL);
+
+ if (embedded_modules)
+ ly_ctx_set_module_imp_clb(ctx, yang_module_imp_clb, NULL);
+
return ctx;
}
-void yang_init(void)
+void yang_init(bool embedded_modules)
{
/* Initialize libyang global parameters that affect all containers. */
ly_set_log_clb(ly_log_cb, 1);
ly_log_options(LY_LOLOG | LY_LOSTORE);
/* Initialize libyang container for native models. */
- ly_native_ctx = yang_ctx_new_setup();
+ ly_native_ctx = yang_ctx_new_setup(embedded_modules);
if (!ly_native_ctx) {
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);