From 8a923b48513316bda9ab9868ebe4f9ff4865c8a9 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 10 Sep 2020 17:12:09 -0300 Subject: lib: better support for nested YANG augmentations Change the way the YANG schema node iteration functions work so that the northbound layer won't have issues with more complex YANG modules that contain multiple levels of YANG augmentations or modules that augment themselves indirectly (by augmenting groupings). Summary of the changes: * Change the yang_snodes_iterate_subtree() function to always follow augmentations and add an optional "module" parameter to narrow down the iteration to nodes of a single module (which is necessary in some cases). Also, remove the YANG_ITER_ALLOW_AUGMENTATIONS flag as it's no longer necessary. * Change yang_snodes_iterate_all() to do a DFS iteration on the resolved YANG data hierarchy instead of iterating over each module and their augmentations sequentially. Reported-by: Rafael Zalamena Signed-off-by: Renato Westphal --- lib/yang.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/yang.h') diff --git a/lib/yang.h b/lib/yang.h index 94bbed233d..867ade9676 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -102,9 +102,6 @@ enum yang_iter_flags { /* Filter implicitely created nodes. */ YANG_ITER_FILTER_IMPLICIT = (1<<3), - - /* Allow iteration over augmentations. */ - YANG_ITER_ALLOW_AUGMENTATIONS = (1<<4), }; /* Callback used by the yang_snodes_iterate_*() family of functions. */ @@ -168,6 +165,9 @@ extern void yang_module_embed(struct yang_module_embed *embed); * snode * YANG schema node to operate on. * + * module + * When set, iterate over all nodes of the specified module only. + * * cb * Function to call with each schema node. * @@ -181,6 +181,7 @@ extern void yang_module_embed(struct yang_module_embed *embed); * The return value of the last called callback. */ extern int yang_snodes_iterate_subtree(const struct lys_node *snode, + const struct lys_module *module, yang_iterate_cb cb, uint16_t flags, void *arg); -- cgit v1.2.3