From dfdd3b1090a5a6d7b774280ed971ea4feea6b59d Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 5 Jun 2024 13:39:46 +0200 Subject: [PATCH] package/sysrepo: Import upstream datastore corruption fix See sysrepo/sysrepo#3268 --- ...o-BUGFIX-do-not-replace-changed-data.patch | 53 +++++++++++++++++++ ...dd-support-for-running-in-foregroun.patch} | 6 ++- ...E-to-return-any-error-to-sysrepocfg.patch} | 6 ++- ...-Allow-to-copy-from-factory-default.patch} | 6 ++- ...ysrepoctl-to-install-factory-config.patch} | 26 +++++++-- 5 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 patches/sysrepo/2.2.170/0001-modinfo-BUGFIX-do-not-replace-changed-data.patch rename patches/sysrepo/2.2.170/{0001-sysrepo-plugind-add-support-for-running-in-foregroun.patch => 0002-sysrepo-plugind-add-support-for-running-in-foregroun.patch} (92%) rename patches/sysrepo/2.2.170/{0002-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch => 0003-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch} (96%) rename patches/sysrepo/2.2.170/{0003-Allow-to-copy-from-factory-default.patch => 0004-Allow-to-copy-from-factory-default.patch} (80%) rename patches/sysrepo/2.2.170/{0004-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch => 0005-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch} (84%) diff --git a/patches/sysrepo/2.2.170/0001-modinfo-BUGFIX-do-not-replace-changed-data.patch b/patches/sysrepo/2.2.170/0001-modinfo-BUGFIX-do-not-replace-changed-data.patch new file mode 100644 index 00000000..732ffc58 --- /dev/null +++ b/patches/sysrepo/2.2.170/0001-modinfo-BUGFIX-do-not-replace-changed-data.patch @@ -0,0 +1,53 @@ +From 85efba771fcfa94d24b4851acb05adedb2b40082 Mon Sep 17 00:00:00 2001 +From: Michal Vasko +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 +--- + 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 + diff --git a/patches/sysrepo/2.2.170/0001-sysrepo-plugind-add-support-for-running-in-foregroun.patch b/patches/sysrepo/2.2.170/0002-sysrepo-plugind-add-support-for-running-in-foregroun.patch similarity index 92% rename from patches/sysrepo/2.2.170/0001-sysrepo-plugind-add-support-for-running-in-foregroun.patch rename to patches/sysrepo/2.2.170/0002-sysrepo-plugind-add-support-for-running-in-foregroun.patch index 6d3fda21..c4fc8746 100644 --- a/patches/sysrepo/2.2.170/0001-sysrepo-plugind-add-support-for-running-in-foregroun.patch +++ b/patches/sysrepo/2.2.170/0002-sysrepo-plugind-add-support-for-running-in-foregroun.patch @@ -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 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 +Signed-off-by: Tobias Waldekranz --- src/executables/sysrepo-plugind.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/patches/sysrepo/2.2.170/0002-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch b/patches/sysrepo/2.2.170/0003-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch similarity index 96% rename from patches/sysrepo/2.2.170/0002-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch rename to patches/sysrepo/2.2.170/0003-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch index 306474c1..9f2e5466 100644 --- a/patches/sysrepo/2.2.170/0002-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch +++ b/patches/sysrepo/2.2.170/0003-Allow-SR_EV_DONE-to-return-any-error-to-sysrepocfg.patch @@ -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 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 +Signed-off-by: Tobias Waldekranz --- src/shm_sub.c | 36 ++++++++++++++++++++++++++++-------- src/shm_sub.h | 2 +- diff --git a/patches/sysrepo/2.2.170/0003-Allow-to-copy-from-factory-default.patch b/patches/sysrepo/2.2.170/0004-Allow-to-copy-from-factory-default.patch similarity index 80% rename from patches/sysrepo/2.2.170/0003-Allow-to-copy-from-factory-default.patch rename to patches/sysrepo/2.2.170/0004-Allow-to-copy-from-factory-default.patch index bd76995c..e93ae9dc 100644 --- a/patches/sysrepo/2.2.170/0003-Allow-to-copy-from-factory-default.patch +++ b/patches/sysrepo/2.2.170/0004-Allow-to-copy-from-factory-default.patch @@ -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?= 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 --- src/sysrepo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/sysrepo/2.2.170/0004-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch b/patches/sysrepo/2.2.170/0005-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch similarity index 84% rename from patches/sysrepo/2.2.170/0004-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch rename to patches/sysrepo/2.2.170/0005-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch index 04acc03b..12709bfe 100644 --- a/patches/sysrepo/2.2.170/0004-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch +++ b/patches/sysrepo/2.2.170/0005-Add-z-switch-to-sysrepoctl-to-install-factory-config.patch @@ -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?= 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 --- 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