static gboolean
check_connection_compatible (NMDevice *self, NMConnection *connection)
{
- NMSettingConnection *s_con;
- const char *config_iface, *device_iface;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- 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)
+ 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);
+
+ /* 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);
+
+ if (strcmp (conn_iface, device_iface) != 0)
return FALSE;
return TRUE;
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);