Fixed: [cl:autocli-op hide has no effect in yang submodule](https://github.com/clicon/clixon/issues/282)

This commit is contained in:
Olof hagsand 2021-11-04 16:22:27 +01:00
parent d335a72659
commit 5297ebe3cb
4 changed files with 73 additions and 4 deletions

View file

@ -2355,6 +2355,14 @@ ys_populate_unique(clicon_handle h,
* RFC 7950 Sec 7.19:
* If no "argument" statement is present, the keyword expects no argument when
* it is used.
* Note there is some complexity in different yang modules with unknown-statements.
* y0) The location of the extension definition. E.g. extension autocli-op
* y1) The location of the unknown-statement (ys). This is for example: cl:autocli-op hide.
* Lookup of "cl" is lexically scoped in this context (to find (y0)).
* y2) The unknown statement may be used by uses/grouping of (y1). But "cl" is declared
* in y1 context. This is fixed by setting ys_mymodule to y1 which is then used in
* lookups such as in yang_extension_value().
* @see yang_extension_value Called on expanded YANG, eg in context of (y2)
*/
static int
ys_populate_unknown(clicon_handle h,
@ -2376,6 +2384,8 @@ ys_populate_unknown(clicon_handle h,
clicon_err(OE_YANG, ENOENT, "Extension \"%s:%s\", module not found", prefix, id);
goto done;
}
/* To find right binding eg after grouping/uses */
ys->ys_mymodule = ys_module(ys);
if ((yext = yang_find(ymod, Y_EXTENSION, id)) == NULL){
clicon_err(OE_YANG, ENOENT, "Extension \"%s:%s\" not found", prefix, id);
goto done;
@ -3572,6 +3582,7 @@ yang_anydata_add(yang_stmt *yp,
* // use extension value
* }
* @endcode
* @see ys_populate_unknown Called when parsing YANGo
*/
int
yang_extension_value(yang_stmt *ys,

View file

@ -71,9 +71,13 @@ struct yang_stmt{
char *ys_argument; /* String / argument depending on keyword */
uint16_t ys_flags; /* Flags according to YANG_FLAG_MARK and others */
yang_stmt *ys_mymodule; /* Shortcut to "my" module. Augmented
nodes can belong to other
modules than the ancestor module */
yang_stmt *ys_mymodule; /* Shortcut to "my" module. Used by:
1) Augmented nodes "belong" to the module where the
augment is declared, which may be differnt from
the direct ancestor module
2) Unknown nodes "belong" to where the extension is
declared
*/
cg_var *ys_cv; /* cligen variable. See ys_populate()
Following stmts have cv:s:
leaf: for default value