* Fixed: Validation of user state data led to wrong validation, if state relied on config data, eg leafref/must/when etc.

* Fixed: No revision in yang module led to errors in validation of state data
This commit is contained in:
Olof hagsand 2020-01-27 22:11:35 +01:00
parent 64f73771d9
commit f5209b1fab
3 changed files with 18 additions and 12 deletions

View file

@ -3,10 +3,11 @@
## 4.3.1 (Expected: January 2020) ## 4.3.1 (Expected: January 2020)
### Corrected Bugs ### Corrected Bugs
* Fixed: Validation of user state data led to wrong validation, if state relied on config data, eg leafref/must/when etc.
* Fixed: No revision in yang module led to errors in validation of state data
* 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: 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.

View file

@ -116,6 +116,7 @@ clixon_plugin_statedata(clicon_handle h,
clixon_plugin *cp = NULL; clixon_plugin *cp = NULL;
plgstatedata_t *fn; /* Plugin statedata fn */ plgstatedata_t *fn; /* Plugin statedata fn */
cbuf *cberr = NULL; cbuf *cberr = NULL;
int i = 0;
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if ((fn = cp->cp_api.ca_statedata) == NULL) if ((fn = cp->cp_api.ca_statedata) == NULL)
@ -124,14 +125,25 @@ clixon_plugin_statedata(clicon_handle h,
goto done; goto done;
if (fn(h, nsc, xpath, x) < 0) if (fn(h, nsc, xpath, x) < 0)
goto fail; /* Dont quit here on user callbacks */ goto fail; /* Dont quit here on user callbacks */
i++; /* indicates that new state data is added */
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0) if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
goto done; goto done;
if ((ret = netconf_trymerge(x, yspec, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
if (x){
xml_free(x);
x = NULL;
}
}
if (i){
/* Check XML from state callback by validating it. return internal /* Check XML from state callback by validating it. return internal
* error with error cause * error with error cause
*/ */
if ((ret = xml_yang_validate_all_top(h, x, &xerr)) < 0) if ((ret = xml_yang_validate_all_top(h, *xret, &xerr)) < 0)
goto done; goto done;
if (ret > 0 && (ret = xml_yang_validate_add(h, x, &xerr)) < 0) if (ret > 0 && (ret = xml_yang_validate_add(h, *xret, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
cxobj *xe; cxobj *xe;
@ -164,14 +176,6 @@ clixon_plugin_statedata(clicon_handle h,
cbuf_free(ccc); cbuf_free(ccc);
} }
#endif #endif
if ((ret = netconf_trymerge(x, yspec, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
if (x){
xml_free(x);
x = NULL;
}
} }
retval = 1; retval = 1;
done: done:

View file

@ -1104,7 +1104,8 @@ ys_cv_validate(clicon_handle h,
/* Note restype can be NULL here for example with unresolved hardcoded uuid */ /* Note restype can be NULL here for example with unresolved hardcoded uuid */
if (restype && strcmp(restype, "union") == 0){ if (restype && strcmp(restype, "union") == 0){
assert(cvtype == CGV_REST); assert(cvtype == CGV_REST);
val = cv_string_get(cv); if ((val = cv_string_get(cv)) == NULL)
val = "";
if ((retval2 = ys_cv_validate_union(h, ys, reason, yrestype, origtype, val)) < 0) if ((retval2 = ys_cv_validate_union(h, ys, reason, yrestype, origtype, val)) < 0)
goto done; goto done;
retval = retval2; /* invalid (0) with latest reason or valid 1 */ retval = retval2; /* invalid (0) with latest reason or valid 1 */