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.
This commit is contained in:
Lubomir Rintel 2016-02-16 15:07:57 +01:00 committed by Thomas Haller
parent adc9895ebe
commit f9ec713641
2 changed files with 11 additions and 10 deletions

View file

@ -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;

View file

@ -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);