ovs: avoid ovs error when same MAC is set on a local interface and bridge

If the same MAC address is set on both the bridge connection and the
interface connection, and the interface is local, NM currently sets
the hwaddr record in both Bridge and Interface ovsdb tables. As a
result, ovs complains with error:

  bridge|ERR|interface br0: ignoring mac in Interface record (use Bridge record to set local port's mac)

Avoid this error: if the bridge and interface MACs are the same, just
set the address in the Bridge table; if they are different, give a
more detailed warning and ignore the interface MAC.

https://bugzilla.redhat.com/show_bug.cgi?id=1899745
This commit is contained in:
Beniamino Galvani 2020-11-23 09:34:31 +01:00
parent e9e99b8677
commit c4beaac67b

View file

@ -1038,11 +1038,27 @@ _add_interface(NMOvsdb * self,
g_clear_error(&error);
}
if (interface_is_local && !bridge_cloned_mac && interface_cloned_mac) {
_LOGT("'%s' is a local ovs-interface, the MAC will be set on ovs-bridge '%s'",
interface_name,
bridge_name);
bridge_cloned_mac = g_steal_pointer(&interface_cloned_mac);
/* For local interfaces, ovs complains if it finds a
* MAC address in the Interface table because it only takes
* the MAC from the Bridge table.
* Set any cloned MAC present in a local interface connection
* into the Bridge table, unless conflicting with the bridge MAC. */
if (interface_is_local && interface_cloned_mac) {
if (bridge_cloned_mac && !nm_streq(interface_cloned_mac, bridge_cloned_mac)) {
_LOGW("Cloned MAC '%s' of local ovs-interface '%s' conflicts with MAC '%s' of bridge "
"'%s'",
interface_cloned_mac,
interface_name,
bridge_cloned_mac,
bridge_name);
nm_clear_g_free(&interface_cloned_mac);
} else {
nm_clear_g_free(&bridge_cloned_mac);
bridge_cloned_mac = g_steal_pointer(&interface_cloned_mac);
_LOGT("'%s' is a local ovs-interface, the MAC will be set on ovs-bridge '%s'",
interface_name,
bridge_name);
}
}
g_hash_table_iter_init(&iter, priv->bridges);