diff --git a/lib/clixon/clixon_yang.h b/lib/clixon/clixon_yang.h index 70ee95cb..e48652d6 100644 --- a/lib/clixon/clixon_yang.h +++ b/lib/clixon/clixon_yang.h @@ -297,5 +297,6 @@ int yang_init(clicon_handle h); int yang_single_child_type(yang_stmt *ys, enum rfc_6020 subkeyw); void *yang_action_cb_get(yang_stmt *ys); int yang_action_cb_add(yang_stmt *ys, void *rc); +int ys_populate_feature(clicon_handle h, yang_stmt *ys); #endif /* _CLIXON_YANG_H_ */ diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index 3569621f..d9b3d9ed 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -2610,7 +2610,7 @@ if_feature(yang_stmt *yspec, * @param[in] ys Feature yang statement to populate. * Bootstrapping: A feature is enabled if found in clixon-config */ -static int +int ys_populate_feature(clicon_handle h, yang_stmt *ys) { @@ -2947,7 +2947,7 @@ yang_features(clicon_handle h, if ((ymod = ys_module(ys)) != NULL) mainfile = yang_filename_get(ymod); ret = 0; - if (yang_subparse(yang_argument_get(ys), ys, YA_IF_FEATURE, mainfile, 1, &ret) < 0) + if (yang_subparse(yang_argument_get(ys), ys, YA_IF_FEATURE, mainfile, 1, &ret, h) < 0) goto done; clicon_debug(CLIXON_DBG_DETAIL, "%s %s %d", __FUNCTION__, yang_argument_get(ys), ret); if (ret == 0) diff --git a/lib/src/clixon_yang_parse_lib.c b/lib/src/clixon_yang_parse_lib.c index 06dc2f67..79b425c6 100644 --- a/lib/src/clixon_yang_parse_lib.c +++ b/lib/src/clixon_yang_parse_lib.c @@ -1986,7 +1986,7 @@ ys_parse_sub(yang_stmt *ys, * pass 1 is not yet resolved, only check syntax, actual feature check made in next pass * @see yang_features */ - if (yang_subparse(yang_argument_get(ys), ys, YA_IF_FEATURE, filename, yang_linenum_get(ys), NULL) < 0) + if (yang_subparse(yang_argument_get(ys), ys, YA_IF_FEATURE, filename, yang_linenum_get(ys), NULL, NULL) < 0) goto done; break; case Y_AUGMENT: /* If parent is module/submodule: absolute-schema-nodeid diff --git a/lib/src/clixon_yang_sub_parse.c b/lib/src/clixon_yang_sub_parse.c index e76059a6..d4f5e4e2 100644 --- a/lib/src/clixon_yang_sub_parse.c +++ b/lib/src/clixon_yang_sub_parse.c @@ -64,6 +64,7 @@ * @param[in] accept Sub-parse rule to accept * @param[in] mainfile Name of main parse file * @param[in] linenum Line number context in mainfile (assume parse module of ys) + * @param[in] h Clixon handle * @param[out] enabled 0: Disabled, 1: Enabled (if present) * @retval 0 OK * @retval -1 Error @@ -74,7 +75,8 @@ yang_subparse(char *str, enum yang_sub_parse_accept accept, const char *mainfile, int linenum, - int *enabled) + int *enabled, + clicon_handle h) { int retval = -1; clixon_yang_sub_parse_yacc ife = {0,}; @@ -86,6 +88,7 @@ yang_subparse(char *str, ife.if_ys = ys; /* Used as trigger to check if enabled */ ife.if_accept = accept; ife.if_mainfile = mainfile; + ife.h = h; if (clixon_yang_sub_parsel_init(&ife) < 0) goto done; if (clixon_yang_sub_parseparse(&ife) != 0) { /* yacc returns 1 on error */ diff --git a/lib/src/clixon_yang_sub_parse.h b/lib/src/clixon_yang_sub_parse.h index c203ea51..e778b711 100644 --- a/lib/src/clixon_yang_sub_parse.h +++ b/lib/src/clixon_yang_sub_parse.h @@ -56,6 +56,7 @@ struct clixon_yang_sub_parse_yacc { yang_stmt *if_ys; /* Yang statement, NULL if no check */ enum yang_sub_parse_accept if_accept; /* Which sub-parse rule to accept */ int if_enabled; /* Result: 0: feature disabled, 1: enabled */ + clicon_handle h; }; typedef struct clixon_yang_sub_parse_yacc clixon_yang_sub_parse_yacc; @@ -73,7 +74,7 @@ int clixon_yang_sub_parsel_linenr(void); int clixon_yang_sub_parselex(void *); int clixon_yang_sub_parseparse(void *); -int yang_subparse(char *str, yang_stmt *ys, enum yang_sub_parse_accept accept, const char *mainfile, int linenum, int *enabled); +int yang_subparse(char *str, yang_stmt *ys, enum yang_sub_parse_accept accept, const char *mainfile, int linenum, int *enabled, clicon_handle h); int yang_schema_nodeid_subparse(char *str, enum yang_sub_parse_accept accept, const char *mainfile, int linenum); #endif /* _CLIXON_YANG_SUB_PARSER_H_ */ diff --git a/lib/src/clixon_yang_sub_parse.y b/lib/src/clixon_yang_sub_parse.y index a4ef06f1..6950aef5 100644 --- a/lib/src/clixon_yang_sub_parse.y +++ b/lib/src/clixon_yang_sub_parse.y @@ -162,6 +162,11 @@ if_feature_check(clixon_yang_sub_parse_yacc *ife, /* Check if this feature is enabled or not * Continue loop to catch unbound features and make verdict at end */ + cv = yang_cv_get(yfeat); + if (cv == NULL && ife->h) { + ys_populate_feature(ife->h, yfeat); + } + cv = yang_cv_get(yfeat); if (cv == NULL || !cv_bool_get(cv)) /* disabled */ retval = 0;