diff options
-rw-r--r-- | lib/grammar_sandbox_main.c | 2 | ||||
-rw-r--r-- | lib/libfrr.c | 2 | ||||
-rw-r--r-- | lib/yang.c | 11 | ||||
-rw-r--r-- | lib/yang.h | 10 | ||||
-rw-r--r-- | lib/yang_translator.c | 4 | ||||
-rw-r--r-- | tests/bgpd/test_peer_attr.c | 2 | ||||
-rw-r--r-- | tests/helpers/c/main.c | 2 | ||||
-rw-r--r-- | tests/lib/cli/common_cli.c | 2 | ||||
-rw-r--r-- | tests/lib/cli/test_commands.c | 2 | ||||
-rw-r--r-- | tests/lib/northbound/test_oper_data.c | 2 | ||||
-rw-r--r-- | tools/gen_northbound_callbacks.c | 2 | ||||
-rw-r--r-- | tools/gen_yang_deviations.c | 2 |
12 files changed, 26 insertions, 17 deletions
diff --git a/lib/grammar_sandbox_main.c b/lib/grammar_sandbox_main.c index 5d3f6675a..aa54720da 100644 --- a/lib/grammar_sandbox_main.c +++ b/lib/grammar_sandbox_main.c @@ -58,7 +58,7 @@ int main(int argc, char **argv) vty_init(master, true); lib_cmd_init(); - yang_init(); + yang_init(true); nb_init(master, NULL, 0); vty_stdio(vty_do_exit); diff --git a/lib/libfrr.c b/lib/libfrr.c index 3622890e4..9a681103d 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -717,7 +717,7 @@ struct thread_master *frr_init(void) log_ref_vty_init(); lib_error_init(); - yang_init(); + yang_init(true); debug_init_cli(); diff --git a/lib/yang.c b/lib/yang.c index 93e6db305..0502d4952 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); diff --git a/lib/yang.h b/lib/yang.h index 6892e3601..8af440d3e 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -482,8 +482,11 @@ extern struct yang_data *yang_data_list_find(const struct list *list, /* * Create and set up a libyang context (for use by the translator) + * + * embedded_modules + * Specify whether libyang should attempt to look for embedded YANG modules. */ -extern struct ly_ctx *yang_ctx_new_setup(void); +extern struct ly_ctx *yang_ctx_new_setup(bool embedded_modules); /* * Enable or disable libyang verbose debugging. @@ -496,8 +499,11 @@ extern void yang_debugging_set(bool enable); /* * Initialize the YANG subsystem. Should be called only once during the * daemon initialization process. + * + * embedded_modules + * Specify whether libyang should attempt to look for embedded YANG modules. */ -extern void yang_init(void); +extern void yang_init(bool embedded_modules); /* * Finish the YANG subsystem gracefully. Should be called only when the daemon diff --git a/lib/yang_translator.c b/lib/yang_translator.c index 341420eed..7dbb1f3f1 100644 --- a/lib/yang_translator.c +++ b/lib/yang_translator.c @@ -171,7 +171,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(); + translator->ly_ctx = yang_ctx_new_setup(false); if (!translator->ly_ctx) { flog_warn(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__); goto error; @@ -511,7 +511,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(); + ly_translator_ctx = yang_ctx_new_setup(true); if (!ly_translator_ctx) { flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__); exit(1); diff --git a/tests/bgpd/test_peer_attr.c b/tests/bgpd/test_peer_attr.c index 422d39747..490b0ee73 100644 --- a/tests/bgpd/test_peer_attr.c +++ b/tests/bgpd/test_peer_attr.c @@ -1387,7 +1387,7 @@ static void bgp_startup(void) zprivs_init(&bgpd_privs); master = thread_master_create(NULL); - yang_init(); + yang_init(true); nb_init(master, NULL, 0); bgp_master_init(master, BGP_SOCKET_SNDBUF_SIZE); bgp_option_set(BGP_OPT_NO_LISTEN); diff --git a/tests/helpers/c/main.c b/tests/helpers/c/main.c index 2de29cbdb..68ed16d51 100644 --- a/tests/helpers/c/main.c +++ b/tests/helpers/c/main.c @@ -155,7 +155,7 @@ int main(int argc, char **argv) cmd_init(1); vty_init(master, false); lib_cmd_init(); - yang_init(); + yang_init(true); nb_init(master, NULL, 0); /* OSPF vty inits. */ diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c index e091372ab..bd81656ca 100644 --- a/tests/lib/cli/common_cli.c +++ b/tests/lib/cli/common_cli.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) vty_init(master, false); lib_cmd_init(); - yang_init(); + yang_init(true); nb_init(master, NULL, 0); test_init(argc, argv); diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index bbdc8b238..779a7539e 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -142,7 +142,7 @@ static void test_init(void) struct cmd_element *cmd; cmd_init(1); - yang_init(); + yang_init(true); nb_init(master, NULL, 0); install_node(&bgp_node, NULL); diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c index 18d318088..786fce33f 100644 --- a/tests/lib/northbound/test_oper_data.c +++ b/tests/lib/northbound/test_oper_data.c @@ -413,7 +413,7 @@ int main(int argc, char **argv) cmd_hostname_set("test"); vty_init(master, false); lib_cmd_init(); - yang_init(); + yang_init(true); nb_init(master, modules, array_size(modules)); /* Create artificial data. */ diff --git a/tools/gen_northbound_callbacks.c b/tools/gen_northbound_callbacks.c index cbdf01e7b..711898685 100644 --- a/tools/gen_northbound_callbacks.c +++ b/tools/gen_northbound_callbacks.c @@ -358,7 +358,7 @@ int main(int argc, char *argv[]) if (argc != 1) usage(EXIT_FAILURE); - yang_init(); + yang_init(false); if (search_path) ly_ctx_set_searchdir(ly_native_ctx, search_path); diff --git a/tools/gen_yang_deviations.c b/tools/gen_yang_deviations.c index f611f1c57..f908e1fc6 100644 --- a/tools/gen_yang_deviations.c +++ b/tools/gen_yang_deviations.c @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) if (argc != 1) usage(EXIT_FAILURE); - yang_init(); + yang_init(false); /* Load YANG module. */ module = yang_module_load(argv[0]); |