From 2641af2cc94bdfd1c4d20c886b195b070ab6e1c0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 11 Jan 2023 19:51:18 +0100 Subject: [PATCH] ovs: don't replace all "other_config" in _set_bridge_mac() Doing an "update" is wrong, because that will replace all "other_config" entries. We only want to reset the "hwaddr". Note that https://www.rfc-editor.org/rfc/rfc7047 says about "": If is "insert", then each of the key-value pairs in the map in is added to only if its key is not already present. The required type of is slightly relaxed, in that it may have fewer than the minimum number of elements specified by the column's type. That means, we need to first delete, and then insert the key. Fixes: 5d4c8521a38c ('ovs: set MAC address on the bridge for local interfaces') --- src/core/devices/ovs/nm-ovsdb.c | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/core/devices/ovs/nm-ovsdb.c b/src/core/devices/ovs/nm-ovsdb.c index f835a79f15..a8f284a3c7 100644 --- a/src/core/devices/ovs/nm-ovsdb.c +++ b/src/core/devices/ovs/nm-ovsdb.c @@ -592,21 +592,30 @@ _set_bridge_ports(json_t *params, const char *ifname, json_t *new_ports) static void _set_bridge_mac(json_t *params, const char *ifname, const char *mac) { - json_array_append_new(params, - json_pack("{s:s, s:s, s:{s:[s, [[s, s]]]}, s:[[s, s, s]]}", - "op", - "update", - "table", - "Bridge", - "row", - "other_config", - "map", - "hwaddr", - mac, - "where", - "name", - "==", - ifname)); + json_array_append_new( + params, + json_pack("{s:s, s:s, s:[[s, s, [s, [s]]], [s, s, [s, [[s, s]]]]], s:[[s, s, s]]}", + "op", + "mutate", + "table", + "Bridge", + "mutations", + + "other_config", + "delete", + "set", + "hwaddr", + + "other_config", + "insert", + "map", + "hwaddr", + mac, + + "where", + "name", + "==", + ifname)); } /**