Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmtd get-data request expansion #15154

Merged
merged 9 commits into from
Jan 15, 2024
Next Next commit
lib: fix yang_lyd_trim_xpath
We should traverse all top-level siblings, not only the first one.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
  • Loading branch information
idryzhov committed Jan 14, 2024
commit 2b7d9532c8ab3590088aca0f22147224fce1df85
27 changes: 15 additions & 12 deletions lib/yang.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ LY_ERR yang_lyd_trim_xpath(struct lyd_node **root, const char *xpath)
}
return LY_SUCCESS;
#else
struct lyd_node *node;
struct lyd_node *node, *sib;
struct lyd_node **remove = NULL;
struct ly_set *set = NULL;
uint32_t i;
Expand Down Expand Up @@ -1123,18 +1123,21 @@ LY_ERR yang_lyd_trim_xpath(struct lyd_node **root, const char *xpath)
}

darr_ensure_cap(remove, 128);
LYD_TREE_DFS_BEGIN (*root, node) {
/*
* If this is a direct matching node then include it's subtree
* which won't be marked and would otherwise be removed.
*/
if (node->priv == (void *)2)
LYD_TREE_DFS_continue = 1;
else if (!node->priv) {
*darr_append(remove) = node;
LYD_TREE_DFS_continue = 1;
LY_LIST_FOR(*root, sib) {
LYD_TREE_DFS_BEGIN (sib, node) {
/*
* If this is a direct matching node then include its
* subtree which won't be marked and would otherwise
* be removed.
*/
if (node->priv == (void *)2)
LYD_TREE_DFS_continue = 1;
else if (!node->priv) {
*darr_append(remove) = node;
LYD_TREE_DFS_continue = 1;
}
LYD_TREE_DFS_END(sib, node);
}
LYD_TREE_DFS_END(*root, node);
}
darr_foreach_i (remove, i) {
if (remove[i] == *root)
Expand Down