Fixed: Yang xpath statements containing prefixes stopped working due to namespace context updates

This commit is contained in:
Olof hagsand 2020-01-23 22:53:19 +01:00
parent e8ae628d06
commit 6384fb89f1
4 changed files with 20 additions and 5 deletions

View file

@ -1,5 +1,10 @@
# Clixon Changelog # Clixon Changelog
## 4.3.1 (Expected: January 2020)
### Corrected Bugs
* 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.
@ -12,6 +17,7 @@ There were several issues with multiple namespaces with augmented yangs in 4.2 t
* Optional yang files can be installed in a separate dir with `--with-opt-yang-installdir=DIR` (renamed from `with-std-yang-installdir`) * Optional yang files can be installed in a separate dir with `--with-opt-yang-installdir=DIR` (renamed from `with-std-yang-installdir`)
* C-API * C-API
* Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)` * Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)`
* If you pass NULL as arg it produces the same message as before.
* Added namespace-context parameter `nsc` to `xpath_first` and `xpath_vec`, (`xpath_vec_nsc` and * Added namespace-context parameter `nsc` to `xpath_first` and `xpath_vec`, (`xpath_vec_nsc` and
xpath_first_nsc` are removed). xpath_first_nsc` are removed).
* Added clicon_handle as parameter to all `clicon_connect_` functions to get better error message * Added clicon_handle as parameter to all `clicon_connect_` functions to get better error message

4
configure vendored
View file

@ -2173,8 +2173,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MAJOR="4"
CLIXON_VERSION_MINOR="3" CLIXON_VERSION_MINOR="3"
CLIXON_VERSION_PATCH="0" CLIXON_VERSION_PATCH="1"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\""
# Check CLIgen # Check CLIgen
if test "$prefix" = "NONE"; then if test "$prefix" = "NONE"; then

View file

@ -44,8 +44,8 @@ AC_INIT(lib/clixon/clixon.h.in)
CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MAJOR="4"
CLIXON_VERSION_MINOR="3" CLIXON_VERSION_MINOR="3"
CLIXON_VERSION_PATCH="0" CLIXON_VERSION_PATCH="1"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\""
# Check CLIgen # Check CLIgen
if test "$prefix" = "NONE"; then if test "$prefix" = "NONE"; then

View file

@ -1064,6 +1064,7 @@ xml_yang_validate_all(clicon_handle h,
cxobj *x; cxobj *x;
char *namespace = NULL; char *namespace = NULL;
cbuf *cb = NULL; cbuf *cb = NULL;
cvec *nsc = NULL;
/* if not given by argument (overide) use default link /* if not given by argument (overide) use default link
and !Node has a config sub-statement and it is false */ and !Node has a config sub-statement and it is false */
@ -1124,7 +1125,9 @@ xml_yang_validate_all(clicon_handle h,
if (yang_keyword_get(yc) != Y_MUST) if (yang_keyword_get(yc) != Y_MUST)
continue; continue;
xpath = yang_argument_get(yc); /* "must" has xpath argument */ xpath = yang_argument_get(yc); /* "must" has xpath argument */
if ((nr = xpath_vec_bool(xt, NULL, "%s", xpath)) < 0) if (xml_nsctx_yang(yc, &nsc) < 0)
goto done;
if ((nr = xpath_vec_bool(xt, nsc, "%s", xpath)) < 0)
goto done; goto done;
if (!nr){ if (!nr){
ye = yang_find(yc, Y_ERROR_MESSAGE, NULL); ye = yang_find(yc, Y_ERROR_MESSAGE, NULL);
@ -1133,6 +1136,10 @@ xml_yang_validate_all(clicon_handle h,
goto done; goto done;
goto fail; goto fail;
} }
if (nsc){
xml_nsctx_free(nsc);
nsc = NULL;
}
} }
/* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */ /* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */
if ((yc = yang_find(ys, Y_WHEN, NULL)) != NULL){ if ((yc = yang_find(ys, Y_WHEN, NULL)) != NULL){
@ -1165,6 +1172,8 @@ xml_yang_validate_all(clicon_handle h,
ok: ok:
retval = 1; retval = 1;
done: done:
if (nsc)
xml_nsctx_free(nsc);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
return retval; return retval;