summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-01-11 19:54:46 +0100
committerLubomir Rintel <lkundrak@v3.sk>2023-01-26 09:22:43 +0100
commitc3e1290e36ece6144ecf776e873edbfd02294a53 (patch)
treea0854b57179bffe4d8710e46d6767c01cd08284f
parent621b20fba2271487456d063c5f136a2456939865 (diff)
downloadNetworkManager-c3e1290e36ece6144ecf776e873edbfd02294a53.tar.gz
ovs: ensure existing "external-ids" get updated during reapply
"mutate" with operation "insert" does not update existing entries. Delete them first. Otherwise, a reapply that only change the value of an external-ids entry does not work. Note that https://www.rfc-editor.org/rfc/rfc7047 says about "<mutations>": If <mutator> is "insert", then each of the key-value pairs in the map in <value> is added to <column> only if its key is not already present. The required type of <value> is slightly relaxed, in that it may have fewer than the minimum number of elements specified by the column's type. Fixes: 7055539c9f7b ('core/ovs: support setting OVS external-ids') (cherry picked from commit d219527dbaf3abb9e53be3b7fafc2519c2652e64)
-rw-r--r--src/core/devices/ovs/nm-ovsdb.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/core/devices/ovs/nm-ovsdb.c b/src/core/devices/ovs/nm-ovsdb.c
index d3e858a19c..b9f59104bf 100644
--- a/src/core/devices/ovs/nm-ovsdb.c
+++ b/src/core/devices/ovs/nm-ovsdb.c
@@ -714,26 +714,27 @@ _j_create_external_ids_array_update(const char *connection_uuid,
mutations = json_array();
+ array = json_array();
if (exid_old) {
- array = NULL;
g_hash_table_iter_init(&iter, exid_old);
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
- if (nm_g_hash_table_contains(exid_new, key))
- continue;
- if (NM_STR_HAS_PREFIX(key, NM_OVS_EXTERNAL_ID_NM_PREFIX))
- continue;
-
- if (!array)
- array = json_array();
-
json_array_append_new(array, json_string(key));
}
- if (array) {
- json_array_append_new(
- mutations,
- json_pack("[s, s, [s, o]]", "external_ids", "delete", "set", array));
+ }
+ if (exid_new) {
+ g_hash_table_iter_init(&iter, exid_new);
+ while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
+ if (nm_g_hash_table_contains(exid_old, key))
+ continue;
+ json_array_append_new(array, json_string(key));
}
}
+ if (!nm_g_hash_table_contains(exid_old, NM_OVS_EXTERNAL_ID_NM_PREFIX)
+ && !nm_g_hash_table_contains(exid_new, NM_OVS_EXTERNAL_ID_NM_PREFIX)) {
+ json_array_append_new(array, json_string(NM_OVS_EXTERNAL_ID_NM_PREFIX));
+ }
+ json_array_append_new(mutations,
+ json_pack("[s, s, [s, o]]", "external_ids", "delete", "set", array));
array = json_array();