package/sysrepo: Import upstream datastore corruption fix

See sysrepo/sysrepo#3268
This commit is contained in:
Tobias Waldekranz
2024-06-07 10:10:38 +02:00
parent b4e3c955d8
commit dfdd3b1090
5 changed files with 88 additions and 9 deletions
@@ -0,0 +1,53 @@
From 85efba771fcfa94d24b4851acb05adedb2b40082 Mon Sep 17 00:00:00 2001
From: Michal Vasko <mvasko@cesnet.cz>
Date: Mon, 15 Apr 2024 09:27:10 +0200
Subject: [PATCH 1/5] modinfo BUGFIX do not replace changed data
Organization: Addiva Elektronik
Fixes #3268
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
src/modinfo.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/modinfo.c b/src/modinfo.c
index c9b95bdf..88f46e09 100644
--- a/src/modinfo.c
+++ b/src/modinfo.c
@@ -2588,20 +2588,26 @@ sr_modinfo_data_load(struct sr_mod_info_s *mod_info, int read_only, const char *
* and not modifying the data */
mod_info->data_cached = 1;
mod_info->data = conn->run_cache_data;
+
+ for (i = 0; i < mod_info->mod_count; ++i) {
+ mod = &mod_info->mods[i];
+ assert(!(mod->state & MOD_INFO_CHANGED));
+ mod->state |= MOD_INFO_DATA;
+ }
} else {
/* duplicate data of all the modules, they will be modified */
for (i = 0; i < mod_info->mod_count; ++i) {
mod = &mod_info->mods[i];
+ if (mod->state & MOD_INFO_DATA) {
+ continue;
+ }
+
if ((err_info = sr_lyd_get_module_data(&conn->run_cache_data, mod->ly_mod, 0, 1, &mod_info->data))) {
goto cleanup;
}
- }
- }
- /* we have data fot all the modules */
- for (i = 0; i < mod_info->mod_count; ++i) {
- mod = &mod_info->mods[i];
- mod->state |= MOD_INFO_DATA;
+ mod->state |= MOD_INFO_DATA;
+ }
}
goto cleanup;
}
--
2.34.1
@@ -1,10 +1,12 @@
From 2b284c1addeecb767bcd7dc280b27411c81cbb74 Mon Sep 17 00:00:00 2001
From b5ad162fa8872f33e80b96e80a02d5c3a3a69a84 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Tue, 28 Mar 2023 10:37:53 +0200
Subject: [PATCH 1/4] sysrepo-plugind: add support for running in foreground
Subject: [PATCH 2/5] sysrepo-plugind: add support for running in foreground
with syslog
Organization: Addiva Elektronik
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
src/executables/sysrepo-plugind.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@@ -1,7 +1,8 @@
From 4861639df0ce14178dbcec4d9ba93f502a1d122d Mon Sep 17 00:00:00 2001
From d60d3eae79616fc0fcd2544736fb7247e02d96cb Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Tue, 7 May 2024 15:41:53 +0200
Subject: [PATCH 2/4] Allow SR_EV_DONE to return any error to sysrepocfg
Subject: [PATCH 3/5] Allow SR_EV_DONE to return any error to sysrepocfg
Organization: Addiva Elektronik
Importing a system configuration with sysrepocfg the model callbacks do
their best to validate the configuration and prepare the transaction in
@@ -16,6 +17,7 @@ This patch is a clumsy way of forcing the (first) error to bubble up to
the surface and cause a non-zero exit code from sysrepocfg.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
src/shm_sub.c | 36 ++++++++++++++++++++++++++++--------
src/shm_sub.h | 2 +-
@@ -1,8 +1,10 @@
From ff0e3f4197fabaf3de5e013b065a6d9765dfdb07 Mon Sep 17 00:00:00 2001
From 86674fd6a63f08cb4f3649fa5cb34605979a1d27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= <lazzer@gmail.com>
Date: Wed, 8 May 2024 17:00:50 +0200
Subject: [PATCH 3/4] Allow to copy from factory default
Subject: [PATCH 4/5] Allow to copy from factory default
Organization: Addiva Elektronik
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
src/sysrepo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -1,15 +1,19 @@
From a047f4b535f363cd97f02e80e2c5aec36f1cc081 Mon Sep 17 00:00:00 2001
From 600c6904a0687f0d237ccec750ae937cd76b9e54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= <lazzer@gmail.com>
Date: Mon, 6 May 2024 14:49:32 +0200
Subject: [PATCH 4/4] Add -z switch to sysrepoctl to install factory config
Subject: [PATCH 5/5] Add -z switch to sysrepoctl to install factory config
from a json file
Organization: Addiva Elektronik
This to be able to load the yang modules during build time instead on boot.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
src/executables/sysrepoctl.c | 20 +++++++++++++--
src/lyd_mods.h | 7 ++++++
src/sysrepo.c | 49 ++++++++++++++++++++++++++++++++++++
src/sysrepo.h | 10 +++++++-
3 files changed, 76 insertions(+), 3 deletions(-)
4 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/src/executables/sysrepoctl.c b/src/executables/sysrepoctl.c
index b9680551..4cdba6a0 100644
@@ -65,6 +69,22 @@ index b9680551..4cdba6a0 100644
case 'l':
/* list */
if ((r = srctl_list(conn))) {
diff --git a/src/lyd_mods.h b/src/lyd_mods.h
index 8f9cbac6..0a1ce2b4 100644
--- a/src/lyd_mods.h
+++ b/src/lyd_mods.h
@@ -102,4 +102,11 @@ sr_error_info_t *sr_lydmods_change_chng_feature(const struct ly_ctx *ly_ctx, con
sr_error_info_t *sr_lydmods_change_chng_replay_support(const struct lys_module *ly_mod, int enable,
struct ly_set *mod_set, sr_conn_ctx_t *conn, struct lyd_node **sr_mods);
+/**
+ * @brief Add factory default data to built-in modules
+ * @param[in] ly_ctx Context to use for parsing SR data.
+ * @return err_info, NULL on success.
+ */
+sr_error_info_t *sr_lydmods_create_data(const struct ly_ctx *ly_ctx);
+
#endif
diff --git a/src/sysrepo.c b/src/sysrepo.c
index 2eac2858..ce2fa822 100644
--- a/src/sysrepo.c