xml_merge1(): Allow merging trees with nodes below mountpoints

xml_merge1() fails right now when merging trees which have data
below mountpoints with an error message like this:

XML node %s/%s has no corresponding yang specification (Invalid XML or wrong Yang spec?

This is because xml_merge1() does not handle mountpoints. Adjust
it accordingly.

Note that this was encountered when generating the state of a a yang
module that has both state and config below a mountpoint. In that case
netconf_trymerge() will be called to merge state and config and will
trigger the problem in xml_merge1().
This commit is contained in:
Colin Baumgarten 2024-04-25 10:22:08 +02:00 committed by Olof Hagsand
parent b6480ac07d
commit d29b7e574c

View file

@ -1310,6 +1310,22 @@ xml_merge1(cxobj *x0, /* the target */
x1cname = xml_name(x1c); x1cname = xml_name(x1c);
/* Get yang spec of the child */ /* Get yang spec of the child */
if ((yc = yang_find_datanode(y0, x1cname)) == NULL){ if ((yc = yang_find_datanode(y0, x1cname)) == NULL){
/*
* Actually the CLICON_YANG_SCHEMA_MOUNT option should be checked below
* to be consistent with what is done e.g. in
* clixon_datastore_write.c::text_modify() when yang_find_datanode()
* returns NULL.
* However the clixon_handle needed to check this option is not
* available here.
* So check for the YANG_FLAG_MOUNTPOINT flag on y0 as an alternative.
* It will only have been set if CLICON_YANG_SCHEMA_MOUNT is enabled
* and it will be set for exactly those cases where the xml_spec()
* call is needed.
*/
if (yang_flag_get(y0, YANG_FLAG_MOUNTPOINT))
yc = xml_spec(x1c);
}
if (yc == NULL) {
if (reason){ if (reason){
if ((cbr = cbuf_new()) == NULL){ if ((cbr = cbuf_new()) == NULL){
clixon_err(OE_XML, errno, "cbuf_new"); clixon_err(OE_XML, errno, "cbuf_new");