From 043acb6a54a816adc5d049968e1d654edb1979ac Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 28 Aug 2020 09:51:14 +0200 Subject: [PATCH] Remove default sets in init cache --- lib/src/clixon_datastore_read.c | 8 +++++++- test/test_nacm_protocol.sh | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index bcb686d2..9c9cad1a 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -776,7 +776,6 @@ xmldb_get_cache(clicon_handle h, if ((x1t = xml_new(xml_name(x0t), NULL, CX_ELMNT)) == NULL) goto done; xml_spec_set(x1t, xml_spec(x0t)); - if (xlen < 1000){ /* This is optimized for the case when the tree is large and xlen is small @@ -806,6 +805,13 @@ xmldb_get_cache(clicon_handle h, if (xml_apply(x1t, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)(XML_FLAG_MARK|XML_FLAG_CHANGE)) < 0) goto done; } + /* Remove global defaults from cache + * Mark non-presence containers as XML_FLAG_DEFAULT */ + if (xml_apply(x0t, CX_ELMNT, xml_nopresence_default_mark, (void*)XML_FLAG_DEFAULT) < 0) + goto done; + /* Clear XML tree of defaults */ + if (xml_tree_prune_flagged(x0t, XML_FLAG_DEFAULT, 1) < 0) + goto done; /* x1t is wrong here should be .. but is .. */ /* XXX where should we apply default values once? */ if (xml_default_recurse(x1t) < 0) diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index bb001b67..bc072b75 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -210,7 +210,7 @@ new "commit it" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "enable nacm" -expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/1.1 201 Created" +expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/1.1 204 No Content" # Rule 3: permit-edit-config new "permit-edit-config: limited ok restconf"