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
"<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.

That means, we need to first delete, and then insert the key.

Fixes: 5d4c8521a3 ('ovs: set MAC address on the bridge for local interfaces')
This commit is contained in:
Thomas Haller 2023-01-11 19:51:18 +01:00
parent 17e16c8fa6
commit 2641af2cc9
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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));
}
/**