Instance-id yang validation checks corrected
This commit is contained in:
parent
ab2f7cbbb4
commit
864e2d1692
1 changed files with 17 additions and 14 deletions
|
|
@ -1298,11 +1298,13 @@ api_path_resolve(clixon_path *cplist,
|
||||||
i = 0;
|
i = 0;
|
||||||
cva = NULL;
|
cva = NULL;
|
||||||
while ((cva = cvec_each(cp->cp_cvk, cva)) != NULL) {
|
while ((cva = cvec_each(cp->cp_cvk, cva)) != NULL) {
|
||||||
if (cv_name_get(cva) == NULL){
|
if (cv_name_get(cva) != NULL){
|
||||||
cvy = cvec_i(yang_cvec_get(yc), i);
|
clicon_err(OE_YANG, ENOENT, "Unexpected named key %s (shouldnt happen)",
|
||||||
cv_name_set(cva, cv_string_get(cvy));
|
cv_name_get(cva));
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
i++;
|
cvy = cvec_i(yang_cvec_get(yc), i++);
|
||||||
|
cv_name_set(cva, cv_string_get(cvy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -1349,10 +1351,9 @@ instance_id_resolve(clixon_path *cplist,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
clixon_path *cp;
|
clixon_path *cp;
|
||||||
yang_stmt *yc;
|
yang_stmt *yc;
|
||||||
int i;
|
|
||||||
cg_var *cva;
|
cg_var *cva;
|
||||||
cg_var *cvy;
|
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
|
char *kname;
|
||||||
|
|
||||||
yspec = ys_spec(yt);
|
yspec = ys_spec(yt);
|
||||||
if ((cp = cplist) != NULL){
|
if ((cp = cplist) != NULL){
|
||||||
|
|
@ -1368,7 +1369,7 @@ instance_id_resolve(clixon_path *cplist,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((yc = yang_find_datanode(yt, cp->cp_id)) == NULL){
|
if ((yc = yang_find_datanode(yt, cp->cp_id)) == NULL){
|
||||||
clicon_err(OE_YANG, ENOENT, "Corresponding yang node for id:%s not found",
|
clicon_err(OE_YANG, ENOENT, "Node %s used in path has no corresponding yang node",
|
||||||
cp->cp_id);
|
cp->cp_id);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
@ -1388,18 +1389,21 @@ instance_id_resolve(clixon_path *cplist,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
i = 0;
|
|
||||||
cva = NULL;
|
cva = NULL;
|
||||||
while ((cva = cvec_each(cp->cp_cvk, cva)) != NULL) {
|
while ((cva = cvec_each(cp->cp_cvk, cva)) != NULL) {
|
||||||
if (cv_name_get(cva) == NULL){
|
if ((kname = cv_name_get(cva)) != NULL){ /* Check var exists */
|
||||||
cvy = cvec_i(yang_cvec_get(yc), i);
|
if (yang_find(yc, 0, kname) == NULL){
|
||||||
cv_name_set(cva, cv_string_get(cvy));
|
clicon_err(OE_YANG, ENOENT, "Index variable %s used in path is not child of Yang node %s",
|
||||||
|
kname, yang_argument_get(yc));
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{ /* Assume index */
|
||||||
|
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Y_LEAF_LIST:
|
case Y_LEAF_LIST:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (cp->cp_cvk != NULL){
|
if (cp->cp_cvk != NULL){
|
||||||
|
|
@ -1461,7 +1465,6 @@ clixon_path_search(cxobj *xt,
|
||||||
goto done;
|
goto done;
|
||||||
for (i=0; i<clixon_xvec_len(xvecp); i++){
|
for (i=0; i<clixon_xvec_len(xvecp); i++){
|
||||||
xp = clixon_xvec_i(xvecp, i); /* Iterate over parent set */
|
xp = clixon_xvec_i(xvecp, i); /* Iterate over parent set */
|
||||||
|
|
||||||
if (cp->cp_cvk && /* cornercase for instance-id [<pos>] special case */
|
if (cp->cp_cvk && /* cornercase for instance-id [<pos>] special case */
|
||||||
(yang_keyword_get(yc) == Y_LIST || yang_keyword_get(yc) == Y_LEAF_LIST) &&
|
(yang_keyword_get(yc) == Y_LIST || yang_keyword_get(yc) == Y_LEAF_LIST) &&
|
||||||
cvec_len(cp->cp_cvk) == 1 && (cv = cvec_i(cp->cp_cvk,0)) &&
|
cvec_len(cp->cp_cvk) == 1 && (cv = cvec_i(cp->cp_cvk,0)) &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue