Fixed: Leafref validation did not cover case of when the "path" statement is declared within a typedef, only if it was declared in the data part directly under leaf.
This commit is contained in:
parent
6384fb89f1
commit
64f73771d9
2 changed files with 19 additions and 6 deletions
|
|
@ -3,8 +3,10 @@
|
||||||
## 4.3.1 (Expected: January 2020)
|
## 4.3.1 (Expected: January 2020)
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* Fixed: Leafref validation did not cover case of when the "path" statement is declared within a typedef, only if it was declared in the data part directly under leaf.
|
||||||
* Fixed: Yang `must` xpath statements containing prefixes stopped working due to namespace context updates
|
* Fixed: Yang `must` xpath statements containing prefixes stopped working due to namespace context updates
|
||||||
|
|
||||||
|
|
||||||
## 4.3.0 (1 January 2020)
|
## 4.3.0 (1 January 2020)
|
||||||
|
|
||||||
There were several issues with multiple namespaces with augmented yangs in 4.2 that have been fixed in 4.3. Some other highlights include: several issues with XPaths including "canonical namespace context" support, a reorganization of the YANG files shipped with the release, and a wildchar in the CLICON_MODE variable.
|
There were several issues with multiple namespaces with augmented yangs in 4.2 that have been fixed in 4.3. Some other highlights include: several issues with XPaths including "canonical namespace context" support, a reorganization of the YANG files shipped with the release, and a wildchar in the CLICON_MODE variable.
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@
|
||||||
|
|
||||||
/*! Validate xml node of type leafref, ensure the value is one of that path's reference
|
/*! Validate xml node of type leafref, ensure the value is one of that path's reference
|
||||||
* @param[in] xt XML leaf node of type leafref
|
* @param[in] xt XML leaf node of type leafref
|
||||||
|
* @param[in] ys Yang spec of leaf
|
||||||
* @param[in] ytype Yang type statement belonging to the XML node
|
* @param[in] ytype Yang type statement belonging to the XML node
|
||||||
* @param[out] xret Error XML tree. Free with xml_free after use
|
* @param[out] xret Error XML tree. Free with xml_free after use
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
|
|
@ -103,11 +104,13 @@
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
validate_leafref(cxobj *xt,
|
validate_leafref(cxobj *xt,
|
||||||
|
yang_stmt *ys,
|
||||||
yang_stmt *ytype,
|
yang_stmt *ytype,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *ypath;
|
yang_stmt *ypath;
|
||||||
|
yang_stmt *yp;
|
||||||
cxobj **xvec = NULL;
|
cxobj **xvec = NULL;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -115,6 +118,7 @@ validate_leafref(cxobj *xt,
|
||||||
char *leafrefbody;
|
char *leafrefbody;
|
||||||
char *leafbody;
|
char *leafbody;
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
|
char *path;
|
||||||
|
|
||||||
if ((leafrefbody = xml_body(xt)) == NULL)
|
if ((leafrefbody = xml_body(xt)) == NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
@ -123,10 +127,17 @@ validate_leafref(cxobj *xt,
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* XXX see comment above regarding typeref or not */
|
/* See comment^: If path is defined in typedef or not */
|
||||||
if (xml_nsctx_yang(ytype, &nsc) < 0)
|
if ((yp = yang_parent_get(ytype)) != NULL &&
|
||||||
goto done;
|
yang_keyword_get(yp) == Y_TYPEDEF){
|
||||||
if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, yang_argument_get(ypath)) < 0)
|
if (xml_nsctx_yang(ys, &nsc) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (xml_nsctx_yang(ytype, &nsc) < 0)
|
||||||
|
goto done;
|
||||||
|
path = yang_argument_get(ypath);
|
||||||
|
if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, path) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
for (i = 0; i < xlen; i++) {
|
for (i = 0; i < xlen; i++) {
|
||||||
x = xvec[i];
|
x = xvec[i];
|
||||||
|
|
@ -1103,7 +1114,7 @@ xml_yang_validate_all(clicon_handle h,
|
||||||
if (yang_type_get(ys, NULL, &yc, NULL, NULL, NULL, NULL, NULL) < 0)
|
if (yang_type_get(ys, NULL, &yc, NULL, NULL, NULL, NULL, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (strcmp(yang_argument_get(yc), "leafref") == 0){
|
if (strcmp(yang_argument_get(yc), "leafref") == 0){
|
||||||
if ((ret = validate_leafref(xt, yc, xret)) < 0)
|
if ((ret = validate_leafref(xt, ys, yc, xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue