From f9ec7136413d941d7dcafc82bcc0f89e1fd2261f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 16 Feb 2016 15:07:57 +0100 Subject: [PATCH] device: move the interface name check from manager We not only want to check the device name when creating a virtual device, but also when determining if the connection can actually be activated there. Otherwise the device names will mix up if there's more connections that use virtual devices of the same type. --- src/devices/nm-device.c | 17 ++++++++++------- src/nm-manager.c | 4 +--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 711ac2acb0..21e653df43 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2958,15 +2958,18 @@ nm_device_complete_connection (NMDevice *self, static gboolean check_connection_compatible (NMDevice *self, NMConnection *connection) { - NMSettingConnection *s_con; - const char *config_iface, *device_iface; + const char *device_iface = nm_device_get_iface (self); + gs_free char *conn_iface = nm_manager_get_connection_iface (nm_manager_get (), + connection, + NULL, NULL); - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + /* We always need a interface name for virtual devices, but for + * physical ones a connection without interface name is fine for + * any device. */ + if (!conn_iface) + return !nm_connection_is_virtual (connection); - config_iface = nm_setting_connection_get_interface_name (s_con); - device_iface = nm_device_get_iface (self); - if (config_iface && strcmp (config_iface, device_iface) != 0) + if (strcmp (conn_iface, device_iface) != 0) return FALSE; return TRUE; diff --git a/src/nm-manager.c b/src/nm-manager.c index eb9576eeeb..dce5d3c80c 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1033,9 +1033,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) for (iter = priv->devices; iter; iter = g_slist_next (iter)) { NMDevice *candidate = iter->data; - if ( g_strcmp0 (nm_device_get_iface (candidate), iface) == 0 - && nm_device_check_connection_compatible (candidate, connection)) { - + if (nm_device_check_connection_compatible (candidate, connection)) { if (nm_device_is_real (candidate)) { nm_log_dbg (LOGD_DEVICE, "(%s) already created virtual interface name %s", nm_connection_get_id (connection), iface);