From 8ebfdb81684f3480db87e65ec760a00ee199be68 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 8 May 2024 11:21:10 +0200 Subject: [PATCH] Changed datastore modstate to be last in file, as prior to 7.0 --- CHANGELOG.md | 1 + lib/src/clixon_datastore.c | 1 - lib/src/clixon_datastore_write.c | 10 ++++++++++ lib/src/clixon_xml.c | 2 +- yang/clixon/clixon-config@2024-04-01.yang | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ebde7b3..2643a08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Expected: June 2024 ### Features +* Changed datastore modstate to be last in file, as prior to 7.0 * New: Event priority. Backend socket has higher prio * New: Split configure datastore multiple sub-files on mount-point boundaries * Avoid writing sub-files without new data (dirty cache) diff --git a/lib/src/clixon_datastore.c b/lib/src/clixon_datastore.c index fecd9ac0..0f130b88 100644 --- a/lib/src/clixon_datastore.c +++ b/lib/src/clixon_datastore.c @@ -278,7 +278,6 @@ xmldb_disconnect(clixon_handle h) return retval; } - /*! Copy datastore from db1 to db2 * * May include copying datastore directory structure diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 89e0ba7e..f31df7d0 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -1482,8 +1482,18 @@ xmldb_dump(clixon_handle h, if ((xm = clicon_modst_cache_get(h, 1)) != NULL){ if ((xmodst = xml_dup(xm)) == NULL) goto done; + /* There are two views on where to insert modstate in config: first or last + * Request from user for last + */ +#if 1 + /* This is inserted last in config */ + if (xml_addsub(xt, xmodst) < 0) + goto done; +#else + /* This is inserted first in config */ if (xml_child_insert_pos(xt, xmodst, 0) < 0) goto done; +#endif xml_parent_set(xmodst, xt); } switch (format){ diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 3ff576bc..af348738 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -926,7 +926,7 @@ xml_child_order(cxobj *xp, * Further, never manipulate the child-list during operation or using the * same object recursively, the function uses an internal field to remember the * index used. It works as long as the same object is not iterated concurrently. - * If you need to delete a node you can do somethhing like: + * If you need to delete a node you can do something like: * @code * cxobj *xprev = NULL; * cxobj *x = NULL; diff --git a/yang/clixon/clixon-config@2024-04-01.yang b/yang/clixon/clixon-config@2024-04-01.yang index e0b48790..f4f3a880 100644 --- a/yang/clixon/clixon-config@2024-04-01.yang +++ b/yang/clixon/clixon-config@2024-04-01.yang @@ -1038,7 +1038,9 @@ module clixon-config { default false; description "If set, tag datastores with RFC 8525 YANG Module Library - info. When loaded at startup, a check is made if the system + info. + By default, modstate is added last in datastore. + When loaded at startup, a check is made if the system yang modules match."; } leaf CLICON_XMLDB_UPGRADE_CHECKOLD {