summary refs log tree commit diff
path: root/src/devices/ovs
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
committerMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
commit65f86e8f56267192d42f2b629fc6b0c99fb9cd0c (patch)
tree180827692f002e5f1dad6a0fa8ca489e6bb6438f /src/devices/ovs
parentf2ddac4cbc895837ddcc55015fae112f9859cd0a (diff)
New upstream version 1.28.0 upstream/1.28.0
Diffstat (limited to 'src/devices/ovs')
-rw-r--r--src/devices/ovs/nm-ovsdb.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
index 9826c1b7..27ef789f 100644
--- a/src/devices/ovs/nm-ovsdb.c
+++ b/src/devices/ovs/nm-ovsdb.c
@@ -707,7 +707,7 @@ _add_interface(NMOvsdb *     self,
     nm_auto_decref_json json_t *interfaces     = NULL;
     nm_auto_decref_json json_t *new_interfaces = NULL;
     gboolean                    has_interface  = FALSE;
-    gboolean                    interface_is_internal;
+    gboolean                    interface_is_local;
     gs_free char *              bridge_cloned_mac    = NULL;
     gs_free char *              interface_cloned_mac = NULL;
     GError *                    error                = NULL;
@@ -721,10 +721,10 @@ _add_interface(NMOvsdb *     self,
     new_ports      = json_array();
     new_interfaces = json_array();
 
-    bridge_name           = nm_connection_get_interface_name(bridge);
-    port_name             = nm_connection_get_interface_name(port);
-    interface_name        = nm_connection_get_interface_name(interface);
-    interface_is_internal = nm_streq0(bridge_name, interface_name);
+    bridge_name        = nm_connection_get_interface_name(bridge);
+    port_name          = nm_connection_get_interface_name(port);
+    interface_name     = nm_connection_get_interface_name(interface);
+    interface_is_local = nm_streq0(bridge_name, interface_name);
 
     /* Determine cloned MAC addresses */
     if (!nm_device_hw_addr_get_cloned(bridge_device,
@@ -733,7 +733,7 @@ _add_interface(NMOvsdb *     self,
                                       &bridge_cloned_mac,
                                       NULL,
                                       &error)) {
-        _LOGW("Cannot determine cloned mac for OVS %s '%s': %s",
+        _LOGW("Cannot determine cloned MAC for OVS %s '%s': %s",
               "bridge",
               bridge_name,
               error->message);
@@ -746,18 +746,34 @@ _add_interface(NMOvsdb *     self,
                                       &interface_cloned_mac,
                                       NULL,
                                       &error)) {
-        _LOGW("Cannot determine cloned mac for OVS %s '%s': %s",
+        _LOGW("Cannot determine cloned MAC for OVS %s '%s': %s",
               "interface",
               interface_name,
               error->message);
         g_clear_error(&error);
     }
 
-    if (interface_is_internal && !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);
@@ -823,7 +839,7 @@ _add_interface(NMOvsdb *     self,
             g_return_if_fail(ovs_bridge);
             _expect_bridge_ports(params, ovs_bridge->name, ports);
             _set_bridge_ports(params, bridge_name, new_ports);
-            if (bridge_cloned_mac && interface_is_internal)
+            if (bridge_cloned_mac && interface_is_local)
                 _set_bridge_mac(params, bridge_name, bridge_cloned_mac);
         }
 
@@ -1175,8 +1191,12 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
     }
 
     if (ovs) {
-        iter          = json_object_iter(ovs);
-        priv->db_uuid = iter ? g_strdup(json_object_iter_key(iter)) : NULL;
+        const char *s;
+
+        iter = json_object_iter(ovs);
+        s    = json_object_iter_key(iter);
+        if (s)
+            nm_utils_strdup_reset(&priv->db_uuid, s);
     }
 
     /* Interfaces */