YANG schema mount, added configure option --enable-yang-schema-mount

This commit is contained in:
Olof hagsand 2023-01-30 11:49:11 +01:00
parent 034ab632f1
commit 91034e5361
11 changed files with 60 additions and 17 deletions

View file

@ -50,7 +50,7 @@ Expected: beginning of 2023
* Only presence containers can be mount-points * Only presence containers can be mount-points
* New plugin callback: `ca_yang_mount` * New plugin callback: `ca_yang_mount`
* Standards: RFC 8528 * Standards: RFC 8528
* To enable: define `YANG_SCHEMA_MOUNT` * To enable configure with `--enable-yang-schema-mount`
* Netconf monitoring RFC 6022 , part 2 * Netconf monitoring RFC 6022 , part 2
* Datastores and sessions * Datastores and sessions
* Added clixon-specific transport identities: cli, snmp, netconf, restconf * Added clixon-specific transport identities: cli, snmp, netconf, restconf

View file

@ -297,7 +297,7 @@ get_statedata(clicon_handle h,
if (ret == 0) if (ret == 0)
goto fail; goto fail;
} }
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
if ((ret = yang_schema_mount_statedata(h, yspec, xpath, nsc, xret, &xerr)) < 0) if ((ret = yang_schema_mount_statedata(h, yspec, xpath, nsc, xret, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){

29
configure vendored
View file

@ -636,6 +636,7 @@ CPP
MIB_GENERATED_YANG_DIR MIB_GENERATED_YANG_DIR
YANG_STANDARD_DIR YANG_STANDARD_DIR
YANG_INSTALLDIR YANG_INSTALLDIR
CLIXON_YANG_SCHEMA_MOUNT
CLIXON_YANG_PATCH CLIXON_YANG_PATCH
with_libxml2 with_libxml2
HAVE_HTTP1 HAVE_HTTP1
@ -721,6 +722,7 @@ enable_option_checking
enable_debug enable_debug
with_cligen with_cligen
enable_yang_patch enable_yang_patch
enable_yang_schema_mount
enable_publish enable_publish
with_restconf with_restconf
enable_http1 enable_http1
@ -1373,6 +1375,8 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug Build with debug symbols, default: no --enable-debug Build with debug symbols, default: no
--enable-yang-patch Enable YANG patch, RFC 8072, default: no --enable-yang-patch Enable YANG patch, RFC 8072, default: no
--enable-yang-schema-mount
Enable YANG schema mount, RFC 8528, default: no
--enable-publish Enable publish of notification streams using SSE and --enable-publish Enable publish of notification streams using SSE and
curl curl
--disable-http1 Disable http1 for native restconf http/1, ie http/2 --disable-http1 Disable http1 for native restconf http/1, ie http/2
@ -3402,6 +3406,7 @@ HAVE_HTTP1=false
# Where Clixon installs its YANG specs # Where Clixon installs its YANG specs
# Examples require standard IETF YANGs. You need to provide these for example and tests # Examples require standard IETF YANGs. You need to provide these for example and tests
@ -4668,6 +4673,30 @@ $as_echo "#define CLIXON_YANG_PATCH 1" >>confdefs.h
fi fi
# Enable/disable YANG schema mount RFC 8528
# Check whether --enable-yang-schema-mount was given.
if test "${enable_yang_schema_mount+set}" = set; then :
enableval=$enable_yang_schema_mount;
if test "$enableval" = no; then
enable_yang_schema_mount=no
else
enable_yang_schema_mount=yes
fi
else
enable_yang_schema_mount=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enable-yang-schema-mount is ${enable_yang_schema_mount}" >&5
$as_echo "enable-yang-schema-mount is ${enable_yang_schema_mount}" >&6; }
if test "${enable_yang_schema_mount}" = "yes"; then
CLIXON_YANG_SCHEMA_MOUNT=1
$as_echo "#define CLIXON_YANG_SCHEMA_MOUNT 1" >>confdefs.h
fi
# Experimental: Curl publish notification stream to eg Nginx nchan. # Experimental: Curl publish notification stream to eg Nginx nchan.
# Check whether --enable-publish was given. # Check whether --enable-publish was given.
if test "${enable_publish+set}" = set; then : if test "${enable_publish+set}" = set; then :

View file

@ -120,6 +120,7 @@ AC_SUBST(HAVE_LIBNGHTTP2,false) # consider using neutral constant such as with-h
AC_SUBST(HAVE_HTTP1,false) AC_SUBST(HAVE_HTTP1,false)
AC_SUBST(with_libxml2) AC_SUBST(with_libxml2)
AC_SUBST(CLIXON_YANG_PATCH) AC_SUBST(CLIXON_YANG_PATCH)
AC_SUBST(CLIXON_YANG_SCHEMA_MOUNT)
# Where Clixon installs its YANG specs # Where Clixon installs its YANG specs
AC_SUBST(YANG_INSTALLDIR) AC_SUBST(YANG_INSTALLDIR)
# Examples require standard IETF YANGs. You need to provide these for example and tests # Examples require standard IETF YANGs. You need to provide these for example and tests
@ -195,6 +196,22 @@ if test "${enable_yang_patch}" = "yes"; then
AC_DEFINE(CLIXON_YANG_PATCH, 1, [Enable YANG patch, RFC 8072]) AC_DEFINE(CLIXON_YANG_PATCH, 1, [Enable YANG patch, RFC 8072])
fi fi
# Enable/disable YANG schema mount RFC 8528
AC_ARG_ENABLE(yang-schema-mount, AS_HELP_STRING([--enable-yang-schema-mount],[Enable YANG schema mount, RFC 8528, default: no]),[
if test "$enableval" = no; then
enable_yang_schema_mount=no
else
enable_yang_schema_mount=yes
fi
],
[ enable_yang_schema_mount=no])
AC_MSG_RESULT(enable-yang-schema-mount is ${enable_yang_schema_mount})
if test "${enable_yang_schema_mount}" = "yes"; then
CLIXON_YANG_SCHEMA_MOUNT=1
AC_DEFINE(CLIXON_YANG_SCHEMA_MOUNT, 1, [Enable YANG schema mount, RFC 8528])
fi
# Experimental: Curl publish notification stream to eg Nginx nchan. # Experimental: Curl publish notification stream to eg Nginx nchan.
AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],[Enable publish of notification streams using SSE and curl]),[ AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],[Enable publish of notification streams using SSE and curl]),[
if test "$enableval" = no; then if test "$enableval" = no; then

View file

@ -21,6 +21,9 @@
/* Enable YANG patch, RFC 8072 */ /* Enable YANG patch, RFC 8072 */
#undef CLIXON_YANG_PATCH #undef CLIXON_YANG_PATCH
/* Enable YANG schema mount, RFC 8528 */
#undef CLIXON_YANG_SCHEMA_MOUNT
/* Define to 1 if you have the `alphasort' function. */ /* Define to 1 if you have the `alphasort' function. */
#undef HAVE_ALPHASORT #undef HAVE_ALPHASORT

View file

@ -191,9 +191,3 @@
* To keep the previous behavior (as in 6.0) set this option with #define * To keep the previous behavior (as in 6.0) set this option with #define
*/ */
#undef NETCONF_DEFAULT_RETRIEVAL_REPORT_ALL #undef NETCONF_DEFAULT_RETRIEVAL_REPORT_ALL
/*! RFC 8528 YANG schema mount
* Experimental
* See also test/test_yang_schema_mount.sh
*/
#undef YANG_SCHEMA_MOUNT

View file

@ -856,7 +856,7 @@ text_modify(clicon_handle h,
x1cname = xml_name(x1c); x1cname = xml_name(x1c);
/* Get yang spec of the child by child matching */ /* Get yang spec of the child by child matching */
if ((yc = yang_find_datanode(y0, x1cname)) == NULL){ if ((yc = yang_find_datanode(y0, x1cname)) == NULL){
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
yc = xml_spec(x1c); yc = xml_spec(x1c);
#endif #endif
if (yc == NULL){ if (yc == NULL){
@ -904,7 +904,7 @@ text_modify(clicon_handle h,
x0c = x0vec[i++]; x0c = x0vec[i++];
x1cname = xml_name(x1c); x1cname = xml_name(x1c);
if ((yc = yang_find_datanode(y0, x1cname)) == NULL){ if ((yc = yang_find_datanode(y0, x1cname)) == NULL){
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
yc = xml_spec(x1c); yc = xml_spec(x1c);
#endif #endif
} }

View file

@ -1008,7 +1008,7 @@ xml_yang_validate_add(clicon_handle h,
cg_var *cv0; cg_var *cv0;
enum cv_type cvtype; enum cv_type cvtype;
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
/* Do not validate beyond mountpoints */ /* Do not validate beyond mountpoints */
if ((ret = xml_yang_mount_get(xt, NULL)) < 0) if ((ret = xml_yang_mount_get(xt, NULL)) < 0)
goto done; goto done;
@ -1225,7 +1225,7 @@ xml_yang_validate_all(clicon_handle h,
cvec *nsc = NULL; cvec *nsc = NULL;
int hit = 0; int hit = 0;
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
/* Do not validate beyond mountpoints */ /* Do not validate beyond mountpoints */
if ((ret = xml_yang_mount_get(xt, NULL)) < 0) if ((ret = xml_yang_mount_get(xt, NULL)) < 0)
goto done; goto done;

View file

@ -453,7 +453,7 @@ xml_bind_yang0_opt(clicon_handle h,
goto ok; goto ok;
strip_body_objects(xt); strip_body_objects(xt);
ybc = YB_PARENT; ybc = YB_PARENT;
#ifdef YANG_SCHEMA_MOUNT // Maybe in populate? #ifdef CLIXON_YANG_SCHEMA_MOUNT
yspec1 = NULL; yspec1 = NULL;
if ((ret = xml_yang_mount_get(xt, &yspec1)) < 0) if ((ret = xml_yang_mount_get(xt, &yspec1)) < 0)
goto done; goto done;

View file

@ -661,7 +661,7 @@ ys_free1(yang_stmt *ys,
cv_free(cv); cv_free(cv);
} }
if (ys->ys_cvec){ if (ys->ys_cvec){
#ifdef YANG_SCHEMA_MOUNT #ifdef CLIXON_YANG_SCHEMA_MOUNT
/* Schema mount uses cvec in unknown to keep track of all yspecs /* Schema mount uses cvec in unknown to keep track of all yspecs
* Freed here once. * Freed here once.
*/ */

View file

@ -5,10 +5,10 @@
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if true; then # enable YANG_SCHEMA_MOUNT if [ -z "${CLIXON_YANG_SCHEMA_MOUNT}" ]; then
echo "...skipped: YANG_SCHEMA_MOUNT NYI" echo "...skipped. To enable configure with: --enable-yang-schema-mount"
rm -rf $dir rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
APPNAME=example APPNAME=example