Call ys_populate_feature from if_feature_check
In some cases, the feature won't be populated yet, and therefore, we will consider this feature as disabled. Fixes #429
This commit is contained in:
parent
8732d118dd
commit
b13917b2ac
6 changed files with 15 additions and 5 deletions
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue