Skip to content

Commit

Permalink
lib: fixes required after rebasing
Browse files Browse the repository at this point in the history
lib: fix checkpatch warnings
lib: darr: disable check
mgmtd: fix initialization

Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Dec 27, 2023
1 parent 41909b9 commit 0094b17
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
3 changes: 2 additions & 1 deletion lib/yang.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,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)) {
Expand All @@ -735,7 +736,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);
Expand Down
47 changes: 31 additions & 16 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,34 +189,49 @@ 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,
&frr_interface_info,
&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
Expand Down
7 changes: 2 additions & 5 deletions tests/lib/test_darr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0094b17

Please sign in to comment.