1
0
Fork 0

Adding upstream version 3.12.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-02 04:14:41 +02:00
parent 76b2c91d7e
commit f3d737b374
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
66 changed files with 4041 additions and 2142 deletions

View file

@ -216,7 +216,7 @@ lyd_val_diff_add(const struct lyd_node *node, enum lyd_diff_op op, struct lyd_no
}
/* create new diff tree */
LY_CHECK_GOTO(ret = lyd_diff_add(node, op, NULL, NULL, key, value, position, NULL, NULL, &new_diff), cleanup);
LY_CHECK_GOTO(ret = lyd_diff_add(node, op, NULL, NULL, key, value, position, NULL, NULL, &new_diff, NULL), cleanup);
/* merge into existing diff */
ret = lyd_diff_merge_all(diff, new_diff, 0);
@ -336,7 +336,8 @@ lyd_validate_autodel_node_del(struct lyd_node **first, struct lyd_node *del, con
/* remove nested from node_when set */
LYD_TREE_DFS_BEGIN(del, iter) {
if ((del != iter) && ly_set_contains(node_when, iter, &idx)) {
ly_set_rm_index(node_when, idx, NULL);
assert(0 && "Please contact libyang support with the use-case that triggered this assert.");
// ly_set_rm_index(node_when, idx, NULL);
}
LYD_TREE_DFS_END(del, iter);
}
@ -345,7 +346,9 @@ lyd_validate_autodel_node_del(struct lyd_node **first, struct lyd_node *del, con
if (node_types && node_types->count) {
/* remove from node_types set */
LYD_TREE_DFS_BEGIN(del, iter) {
if (ly_set_contains(node_types, iter, &idx)) {
if ((iter->schema->nodetype & LYD_NODE_TERM) &&
((struct lysc_node_leaf *)iter->schema)->type->plugin->validate &&
ly_set_contains(node_types, iter, &idx)) {
ly_set_rm_index(node_types, idx, NULL);
}
LYD_TREE_DFS_END(del, iter);
@ -490,8 +493,14 @@ lyd_validate_unres(struct lyd_node **tree, const struct lys_module *mod, enum ly
/* there must have been some when conditions resolved */
} while (prev_count > node_when->count);
/* there could have been no cyclic when dependencies, checked during compilation */
assert(!node_when->count || ((rc == LY_EVALID) && (val_opts & LYD_VALIDATE_MULTI_ERROR)));
if (node_when->count) {
/* there could have been no cyclic when dependencies, checked during compilation */
assert((rc == LY_EVALID) && (val_opts & LYD_VALIDATE_MULTI_ERROR));
/* when condition was validated and it is not satisfied, error printed, if kept in the set the following
* unres (for the next module) can fail this assert */
ly_set_erase(node_when, NULL);
}
}
if (node_types && node_types->count) {
@ -1140,13 +1149,17 @@ static LY_ERR
lyd_validate_minmax(const struct lyd_node *first, const struct lyd_node *parent, const struct lysc_node *snode,
uint32_t min, uint32_t max, uint32_t val_opts)
{
LY_ERR rc = LY_SUCCESS;
uint32_t count = 0;
struct lyd_node *iter;
struct lyd_node *iter, *last_iter = NULL;
const struct lysc_when *disabled;
char *log_path;
int r;
assert(min || max);
LYD_LIST_FOR_INST(first, snode, iter) {
last_iter = iter;
++count;
if (min && (count == min)) {
@ -1182,32 +1195,52 @@ lyd_validate_minmax(const struct lyd_node *first, const struct lyd_node *parent,
max = 0;
}
if (min) {
if (val_opts & LYD_VALIDATE_OPERATIONAL) {
/* only a warning */
LOG_LOCSET(snode, NULL);
LOGWRN(snode->module->ctx, "Too few \"%s\" instances.", snode->name);
LOG_LOCBACK(1, 0);
if (min || max) {
/* set log path */
if (last_iter) {
/* standard data path */
LOG_LOCSET(NULL, last_iter);
} else {
LOG_LOCSET(snode, NULL);
LOGVAL_APPTAG(snode->module->ctx, "too-few-elements", LY_VCODE_NOMIN, snode->name);
LOG_LOCBACK(1, 0);
return LY_EVALID;
/* data path with last schema node name or only the schema node if !parent */
if (lyd_node_module(parent) != snode->module) {
r = asprintf(&log_path, "/%s:%s", snode->module->name, snode->name);
} else {
r = asprintf(&log_path, "/%s", snode->name);
}
if (r == -1) {
LOGMEM_RET(snode->module->ctx);
}
ly_log_location(NULL, parent, log_path, NULL);
free(log_path);
}
} else if (max) {
if (val_opts & LYD_VALIDATE_OPERATIONAL) {
/* only a warning */
LOG_LOCSET(NULL, iter);
LOGWRN(snode->module->ctx, "Too many \"%s\" instances.", snode->name);
if (min) {
if (val_opts & LYD_VALIDATE_OPERATIONAL) {
/* only a warning */
LOGWRN(snode->module->ctx, "Too few \"%s\" instances.", snode->name);
} else {
LOGVAL_APPTAG(snode->module->ctx, "too-few-elements", LY_VCODE_NOMIN, snode->name);
rc = LY_EVALID;
}
} else if (max) {
if (val_opts & LYD_VALIDATE_OPERATIONAL) {
/* only a warning */
LOGWRN(snode->module->ctx, "Too many \"%s\" instances.", snode->name);
} else {
LOGVAL_APPTAG(snode->module->ctx, "too-many-elements", LY_VCODE_NOMAX, snode->name);
rc = LY_EVALID;
}
}
/* revert log path */
if (last_iter) {
LOG_LOCBACK(0, 1);
} else {
LOG_LOCSET(NULL, iter);
LOGVAL_APPTAG(snode->module->ctx, "too-many-elements", LY_VCODE_NOMAX, snode->name);
LOG_LOCBACK(0, 1);
return LY_EVALID;
ly_log_location_revert(0, parent ? 1 : 0, 1, 0);
}
}
return LY_SUCCESS;
return rc;
}
/**
@ -1588,7 +1621,8 @@ lyd_validate_obsolete(const struct lyd_node *node)
snode = node->schema;
do {
if (snode->flags & LYS_STATUS_OBSLT) {
if (snode->flags & LYS_STATUS_OBSLT &&
(!(snode->nodetype & LYD_NODE_INNER) || lyd_child(node))) {
LOG_LOCSET(NULL, node);
LOGWRN(snode->module->ctx, "Obsolete schema node \"%s\" instantiated in data.", snode->name);
LOG_LOCBACK(0, 1);
@ -2126,7 +2160,7 @@ LIBYANG_API_DEF LY_ERR
lyd_validate_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t val_opts, struct lyd_node **diff)
{
LY_CHECK_ARG_RET(NULL, tree, *tree || ctx, LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, ctx, LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(__func__, *tree ? LYD_CTX(*tree) : NULL, ctx, LY_EINVAL);
if (!ctx) {
ctx = LYD_CTX(*tree);
}
@ -2141,7 +2175,7 @@ LIBYANG_API_DEF LY_ERR
lyd_validate_module(struct lyd_node **tree, const struct lys_module *module, uint32_t val_opts, struct lyd_node **diff)
{
LY_CHECK_ARG_RET(NULL, tree, module, !(val_opts & LYD_VALIDATE_PRESENT), LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, module->ctx, LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(__func__, *tree ? LYD_CTX(*tree) : NULL, module->ctx, LY_EINVAL);
if (diff) {
*diff = NULL;
}
@ -2159,7 +2193,7 @@ lyd_validate_module_final(struct lyd_node *tree, const struct lys_module *module
struct ly_ht *getnext_ht = NULL;
LY_CHECK_ARG_RET(NULL, module, !(val_opts & (LYD_VALIDATE_PRESENT | LYD_VALIDATE_NOT_FINAL)), LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(tree ? LYD_CTX(tree) : NULL, module->ctx, LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(__func__, tree ? LYD_CTX(tree) : NULL, module->ctx, LY_EINVAL);
/* module is unchanged but we need to get the first module data node */
mod = lyd_mod_next_module(tree, module, module->ctx, &i, &first);