From 91034e5361718b2fb6b7c3009ae2a18939f70074 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 30 Jan 2023 11:49:11 +0100 Subject: [PATCH] YANG schema mount, added configure option --enable-yang-schema-mount --- CHANGELOG.md | 2 +- apps/backend/backend_get.c | 2 +- configure | 29 +++++++++++++++++++++++++++++ configure.ac | 17 +++++++++++++++++ include/clixon_config.h.in | 3 +++ include/clixon_custom.h | 6 ------ lib/src/clixon_datastore_write.c | 4 ++-- lib/src/clixon_validate.c | 4 ++-- lib/src/clixon_xml_bind.c | 2 +- lib/src/clixon_yang.c | 2 +- test/test_yang_schema_mount.sh | 6 +++--- 11 files changed, 60 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1d2024..f6bacd77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Expected: beginning of 2023 * Only presence containers can be mount-points * New plugin callback: `ca_yang_mount` * Standards: RFC 8528 - * To enable: define `YANG_SCHEMA_MOUNT` + * To enable configure with `--enable-yang-schema-mount` * Netconf monitoring RFC 6022 , part 2 * Datastores and sessions * Added clixon-specific transport identities: cli, snmp, netconf, restconf diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index 0ad46550..4938bd59 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -297,7 +297,7 @@ get_statedata(clicon_handle h, if (ret == 0) goto fail; } -#ifdef YANG_SCHEMA_MOUNT +#ifdef CLIXON_YANG_SCHEMA_MOUNT if ((ret = yang_schema_mount_statedata(h, yspec, xpath, nsc, xret, &xerr)) < 0) goto done; if (ret == 0){ diff --git a/configure b/configure index 05398669..33aa03e1 100755 --- a/configure +++ b/configure @@ -636,6 +636,7 @@ CPP MIB_GENERATED_YANG_DIR YANG_STANDARD_DIR YANG_INSTALLDIR +CLIXON_YANG_SCHEMA_MOUNT CLIXON_YANG_PATCH with_libxml2 HAVE_HTTP1 @@ -721,6 +722,7 @@ enable_option_checking enable_debug with_cligen enable_yang_patch +enable_yang_schema_mount enable_publish with_restconf enable_http1 @@ -1373,6 +1375,8 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-debug Build with debug symbols, 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 curl --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 # 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 +# 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. # Check whether --enable-publish was given. if test "${enable_publish+set}" = set; then : diff --git a/configure.ac b/configure.ac index 6b810dbf..c941465a 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,7 @@ AC_SUBST(HAVE_LIBNGHTTP2,false) # consider using neutral constant such as with-h AC_SUBST(HAVE_HTTP1,false) AC_SUBST(with_libxml2) AC_SUBST(CLIXON_YANG_PATCH) +AC_SUBST(CLIXON_YANG_SCHEMA_MOUNT) # Where Clixon installs its YANG specs AC_SUBST(YANG_INSTALLDIR) # 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]) 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. AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],[Enable publish of notification streams using SSE and curl]),[ if test "$enableval" = no; then diff --git a/include/clixon_config.h.in b/include/clixon_config.h.in index 4b0e6cd1..142e7611 100644 --- a/include/clixon_config.h.in +++ b/include/clixon_config.h.in @@ -21,6 +21,9 @@ /* Enable YANG patch, RFC 8072 */ #undef CLIXON_YANG_PATCH +/* Enable YANG schema mount, RFC 8528 */ +#undef CLIXON_YANG_SCHEMA_MOUNT + /* Define to 1 if you have the `alphasort' function. */ #undef HAVE_ALPHASORT diff --git a/include/clixon_custom.h b/include/clixon_custom.h index ce4e5f27..4415a22f 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -191,9 +191,3 @@ * To keep the previous behavior (as in 6.0) set this option with #define */ #undef NETCONF_DEFAULT_RETRIEVAL_REPORT_ALL - -/*! RFC 8528 YANG schema mount - * Experimental - * See also test/test_yang_schema_mount.sh - */ -#undef YANG_SCHEMA_MOUNT diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index defc8343..80b36868 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -856,7 +856,7 @@ text_modify(clicon_handle h, x1cname = xml_name(x1c); /* Get yang spec of the child by child matching */ if ((yc = yang_find_datanode(y0, x1cname)) == NULL){ -#ifdef YANG_SCHEMA_MOUNT +#ifdef CLIXON_YANG_SCHEMA_MOUNT yc = xml_spec(x1c); #endif if (yc == NULL){ @@ -904,7 +904,7 @@ text_modify(clicon_handle h, x0c = x0vec[i++]; x1cname = xml_name(x1c); if ((yc = yang_find_datanode(y0, x1cname)) == NULL){ -#ifdef YANG_SCHEMA_MOUNT +#ifdef CLIXON_YANG_SCHEMA_MOUNT yc = xml_spec(x1c); #endif } diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 6dfa24b9..6dd21830 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -1008,7 +1008,7 @@ xml_yang_validate_add(clicon_handle h, cg_var *cv0; enum cv_type cvtype; -#ifdef YANG_SCHEMA_MOUNT +#ifdef CLIXON_YANG_SCHEMA_MOUNT /* Do not validate beyond mountpoints */ if ((ret = xml_yang_mount_get(xt, NULL)) < 0) goto done; @@ -1225,7 +1225,7 @@ xml_yang_validate_all(clicon_handle h, cvec *nsc = NULL; int hit = 0; -#ifdef YANG_SCHEMA_MOUNT +#ifdef CLIXON_YANG_SCHEMA_MOUNT /* Do not validate beyond mountpoints */ if ((ret = xml_yang_mount_get(xt, NULL)) < 0) goto done; diff --git a/lib/src/clixon_xml_bind.c b/lib/src/clixon_xml_bind.c index fff0c56b..fc39afec 100644 --- a/lib/src/clixon_xml_bind.c +++ b/lib/src/clixon_xml_bind.c @@ -453,7 +453,7 @@ xml_bind_yang0_opt(clicon_handle h, goto ok; strip_body_objects(xt); ybc = YB_PARENT; -#ifdef YANG_SCHEMA_MOUNT // Maybe in populate? +#ifdef CLIXON_YANG_SCHEMA_MOUNT yspec1 = NULL; if ((ret = xml_yang_mount_get(xt, &yspec1)) < 0) goto done; diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index dc4f5989..aba7a779 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -661,7 +661,7 @@ ys_free1(yang_stmt *ys, cv_free(cv); } 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 * Freed here once. */ diff --git a/test/test_yang_schema_mount.sh b/test/test_yang_schema_mount.sh index d22a894b..1e8bbf0d 100755 --- a/test/test_yang_schema_mount.sh +++ b/test/test_yang_schema_mount.sh @@ -5,10 +5,10 @@ # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi -if true; then # enable YANG_SCHEMA_MOUNT - echo "...skipped: YANG_SCHEMA_MOUNT NYI" +if [ -z "${CLIXON_YANG_SCHEMA_MOUNT}" ]; then + echo "...skipped. To enable configure with: --enable-yang-schema-mount" 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 APPNAME=example