Replaced compile-time with CLICON_YANG_USE_ORIGINAL
Use original yang object in grouping/augment
This commit is contained in:
parent
45e744d6eb
commit
1994a405dd
4 changed files with 27 additions and 18 deletions
|
|
@ -29,12 +29,14 @@ Expected: October 2024
|
|||
* Added union and extended struct for uncommon fields
|
||||
* Removed per-object YANG linenr info
|
||||
* Yang-type cache only for original trees (not derived via grouping/augment)
|
||||
* Added option `CLICON_YANG_USE_ORIGINAL` to use original yang object in grouping/augment
|
||||
* New: [CLI simple alias](https://github.com/clicon/cligen/issues/112)
|
||||
* See: https://clixon-docs.readthedocs.io/en/latest/cli.html#cli-aliases
|
||||
* List pagination: Added where, sort-by and direction parameter for configured data
|
||||
* New `clixon-config@2024-08-01.yang` revision
|
||||
- Added: CLICON_YANG_DOMAIN_DIR
|
||||
- Deprecated: `CLICON_YANG_SCHEMA_MOUNT_SHARE`
|
||||
* Added: `CLICON_YANG_DOMAIN_DIR`
|
||||
* Added: `CLICON_YANG_USE_ORIGINAL`
|
||||
* Deprecated: `CLICON_YANG_SCHEMA_MOUNT_SHARE`
|
||||
* New `clixon-lib@2024-08-01.yang` revision
|
||||
- Added: list-pagination-partial-state extension
|
||||
|
||||
|
|
|
|||
|
|
@ -204,9 +204,3 @@
|
|||
* If not set, reduces memory with 8 bytes per yang-stmt.
|
||||
*/
|
||||
#undef YANG_SPEC_LINENR
|
||||
|
||||
/*! Use ref origin pointer to skip as many derived yang nodes as possible
|
||||
*
|
||||
* If set, do not copy some YANG nodes to derived trees (ie augmented or grouped trees)
|
||||
*/
|
||||
#define YANG_ORIG_PTR_SKIP
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ static const map_str2int ykmap[] = {
|
|||
static map_ptr2ptr *_yang_when_map = NULL;
|
||||
static map_ptr2ptr *_yang_mymodule_map = NULL;
|
||||
|
||||
/* See option CLICON_YANG_USE_ORIGINAL */
|
||||
static int _yang_use_orig = 0;
|
||||
|
||||
/* Forward static */
|
||||
static int yang_type_cache_free(yang_type_cache *ycache);
|
||||
|
||||
|
|
@ -1106,7 +1109,6 @@ yn_realloc(yang_stmt *yn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef YANG_ORIG_PTR_SKIP
|
||||
/*! Return 1 if yang stmt should be skipped in derived trees
|
||||
*
|
||||
* @param[in] keyword YANG keyword
|
||||
|
|
@ -1125,6 +1127,7 @@ yn_realloc(yang_stmt *yn)
|
|||
* - presence
|
||||
* - min/max-elements
|
||||
* - if-feature
|
||||
* @see CLICON_YANG_USE_ORIGINAL
|
||||
*/
|
||||
static int
|
||||
uses_orig_ptr(enum rfc_6020 keyword)
|
||||
|
|
@ -1160,7 +1163,6 @@ uses_orig_ptr(enum rfc_6020 keyword)
|
|||
|| keyword == Y_WHEN // children
|
||||
;
|
||||
}
|
||||
#endif /* YANG_ORIG_PTR_SKIP */
|
||||
|
||||
/*! Copy single yang statement no children
|
||||
*
|
||||
|
|
@ -1257,12 +1259,11 @@ ys_cp(yang_stmt *ynew,
|
|||
goto done;
|
||||
for (i=0,j=0; i<yold->ys_len; i++){
|
||||
yco = yold->ys_stmt[i];
|
||||
#ifdef YANG_ORIG_PTR_SKIP
|
||||
if (uses_orig_ptr(yang_keyword_get(yco))) {
|
||||
if (_yang_use_orig &&
|
||||
uses_orig_ptr(yang_keyword_get(yco))) {
|
||||
ynew->ys_len--;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if ((ycn = ys_dup(yco)) == NULL)
|
||||
goto done;
|
||||
ynew->ys_stmt[j++] = ycn;
|
||||
|
|
@ -1421,14 +1422,13 @@ yang_find(yang_stmt *yn,
|
|||
char *name;
|
||||
yang_stmt *yspec;
|
||||
yang_stmt *ym;
|
||||
#ifdef YANG_ORIG_PTR_SKIP
|
||||
yang_stmt *yorig;
|
||||
|
||||
if ((yorig = yang_orig_get(yn)) != NULL) {
|
||||
if (uses_orig_ptr(keyword))
|
||||
if (_yang_use_orig &&
|
||||
(yorig = yang_orig_get(yn)) != NULL &&
|
||||
uses_orig_ptr(keyword)){
|
||||
return yang_find(yorig, keyword, argument);
|
||||
}
|
||||
#endif
|
||||
for (i=0; i<yn->ys_len; i++){
|
||||
ys = yn->ys_stmt[i];
|
||||
if (keyword == 0 || ys->ys_keyword == keyword){
|
||||
|
|
@ -4470,6 +4470,7 @@ yang_init(clixon_handle h)
|
|||
map_ptr2ptr *mp;
|
||||
yang_stmt *ymounts;
|
||||
|
||||
_yang_use_orig = clicon_option_bool(h, "CLICON_YANG_USE_ORIGINAL");
|
||||
if ((mp = calloc(1, sizeof(*mp))) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ module clixon-config {
|
|||
description
|
||||
"Added options:
|
||||
CLICON_YANG_DOMAIN_DIR
|
||||
CLICON_YANG_USE_ORIGINAL
|
||||
Deprecated:
|
||||
CLICON_YANG_SCHEMA_MOUNT_SHARE
|
||||
Released in Clixon 7.2";
|
||||
|
|
@ -645,6 +646,17 @@ module clixon-config {
|
|||
See also CLICON_XMLDB_MODSTATE where the module state info is used to tag datastores
|
||||
with module information.";
|
||||
}
|
||||
leaf CLICON_YANG_USE_ORIGINAL{
|
||||
type boolean;
|
||||
default false;
|
||||
description
|
||||
"YANG memory optimization.
|
||||
If set, for a selected set of YANG nodes, (see uses_orig_ptr()):
|
||||
For augmented and grouping/uses, use original YANG node instead of the derived node.
|
||||
This is safe if all content of derived node is not changed (eg read-only).
|
||||
It is not safe if the derived node is in some way different than the original node.
|
||||
";
|
||||
}
|
||||
/* Backend */
|
||||
leaf CLICON_BACKEND_DIR {
|
||||
type string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue