From 4c57edfc579d67b52bcca18d717e2526128cdce2 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 25 Nov 2024 15:09:10 +0100 Subject: [PATCH] System-only config: revert clearing of candidate after commit Add compile-time option SYSTEM_ONLY_CONFIG_CANDIDATE_CLEAR to document --- apps/backend/backend_commit.c | 2 ++ include/clixon_custom.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index 6a89dc0b..d3177d84 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -749,7 +749,9 @@ candidate_commit(clixon_handle h, /* Remove system-only-config data from destination cache */ if (clicon_option_bool(h, "CLICON_XMLDB_SYSTEM_ONLY_CONFIG")){ xmldb_clear(h, "running"); +#ifdef SYSTEM_ONLY_CONFIG_CANDIDATE_CLEAR xmldb_clear(h, db); +#endif } xmldb_modified_set(h, db, 0); /* reset dirty bit */ /* Here pointers to old (source) tree are obsolete */ diff --git a/include/clixon_custom.h b/include/clixon_custom.h index 981af158..ca386f7c 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -204,3 +204,13 @@ * If not set, reduces memory with 8 bytes per yang-stmt. */ #undef YANG_SPEC_LINENR + +/*! Effort to clear system-only config data from candidate cache after commit + * + * The idea was that the candidate would be re-loaded from file and populated (as running) + * However, there may be instances where the candidate cache is loaded without YANG binding, + * such as in xmldb_get0(h, "candidate", YB_NONE,...), whereas running cache is loaded with YANG. + * This causes xml_cmp to show that the datastores are unequal and may cause a wrong diff, or + * worse case an overwrite. + */ +#undef SYSTEM_ONLY_CONFIG_CANDIDATE_CLEAR