diff --git a/lib/yang.c b/lib/yang.c index a707469a7881..0998133a5a25 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -745,6 +745,7 @@ struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile) { struct ly_ctx *ctx = NULL; const char *yang_models_path = YANG_MODELS_PATH; + uint options; LY_ERR err; if (access(yang_models_path, R_OK | X_OK)) { @@ -758,7 +759,7 @@ struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, bool explicit_compile) YANG_MODELS_PATH); } - uint options = LY_CTX_NO_YANGLIBRARY | LY_CTX_DISABLE_SEARCHDIR_CWD; + options = LY_CTX_NO_YANGLIBRARY | LY_CTX_DISABLE_SEARCHDIR_CWD; if (explicit_compile) options |= LY_CTX_EXPLICIT_COMPILE; err = ly_ctx_new(yang_models_path, options, &ctx); diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c index 793161dc3204..f0fb7f8a7b85 100644 --- a/mgmtd/mgmt_main.c +++ b/mgmtd/mgmt_main.c @@ -189,12 +189,33 @@ static void mgmt_vrf_terminate(void) extern const struct frr_yang_module_info frr_staticd_info; #endif + +/* + * These are stub info structs that are used to load the modules used by backend + * clients into mgmtd. The modules are used by libyang in order to support + * parsing binary data returns from the backend. + */ +const struct frr_yang_module_info zebra_info = { + .name = "frr-zebra", + .ignore_cbs = true, + .nodes = { { .xpath = NULL } }, +}; + +const struct frr_yang_module_info affinity_map_info = { + .name = "frr-affinity-map", + .ignore_cbs = true, + .nodes = { { .xpath = NULL } }, +}; + +const struct frr_yang_module_info zebra_route_map_info = { + .name = "frr-zebra-route-map", + .ignore_cbs = true, + .nodes = { { .xpath = NULL } }, +}; + /* * List of YANG modules to be loaded in the process context of * MGMTd. - * - * NOTE: In future this will also include the YANG modules of - * all individual Backend clients. */ static const struct frr_yang_module_info *const mgmt_yang_modules[] = { &frr_filter_info, @@ -202,21 +223,15 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = { &frr_route_map_info, &frr_routing_info, &frr_vrf_info, -/* - * YANG module info supported by backend clients get added here. - * NOTE: Always set .ignore_cbs true for to avoid validating - * backend configuration northbound callbacks during loading. - */ - &(struct frr_yang_module_info){ .name = "frr-zebra", - .ignore_cbs = true }, + /* - * TO support LYD_LYB parsing we have to include all the modules that - * backend clients include. + * YANG module info used by backend clients get added here. */ - &(struct frr_yang_module_info){ .name = "frr-affinity-map", - .ignore_cbs = true }, - &(struct frr_yang_module_info){ .name = "frr-zebra-route-map", - .ignore_cbs = true }, + + &zebra_info, + &affinity_map_info, + &zebra_route_map_info, + #ifdef HAVE_STATICD &frr_staticd_info, #endif diff --git a/tests/lib/test_darr.c b/tests/lib/test_darr.c index 1111b80eaabe..f297b7c714c4 100644 --- a/tests/lib/test_darr.c +++ b/tests/lib/test_darr.c @@ -343,13 +343,10 @@ static void test_string(void) assert(darr_strlen(da1) == srclen); assert(darr_cap(da1) >= 128); - da2 = da1; - darr_in_strdup_cap(da1, src, 1024); - assert(da1 != da2); + darr_in_strdup_cap(da1, src, 256); assert(darr_strlen(da1) == srclen); - assert(darr_cap(da1) >= 1024); + assert(darr_cap(da1) >= 256); darr_free(da1); - da2 = NULL; da1 = darr_strdup_cap(add, 2); assert(darr_strlen(da1) == addlen);