mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 04:40:09 +01:00
core: check duplicate devices by interface name not UDI
We can't have devices with duplicate interface names so we might
as well use that for dupe checking instead of the (mostly useless)
UDI.
(cherry picked from commit 81db512997)
This commit is contained in:
parent
a81830c766
commit
dee7f89b62
1 changed files with 17 additions and 15 deletions
|
|
@ -470,20 +470,6 @@ _config_changed_cb (NMConfig *config, NMConfigData *config_data, NMConfigChangeF
|
|||
|
||||
/************************************************************************/
|
||||
|
||||
static NMDevice *
|
||||
nm_manager_get_device_by_udi (NMManager *manager, const char *udi)
|
||||
{
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (udi != NULL, NULL);
|
||||
|
||||
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
||||
if (!strcmp (nm_device_get_udi (NM_DEVICE (iter->data)), udi))
|
||||
return NM_DEVICE (iter->data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NMDevice *
|
||||
nm_manager_get_device_by_path (NMManager *manager, const char *path)
|
||||
{
|
||||
|
|
@ -545,6 +531,18 @@ find_device_by_ip_iface (NMManager *self, const gchar *iface)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static NMDevice *
|
||||
find_device_by_iface (NMManager *self, const gchar *iface)
|
||||
{
|
||||
GSList *iter;
|
||||
|
||||
for (iter = NM_MANAGER_GET_PRIVATE (self)->devices; iter; iter = g_slist_next (iter)) {
|
||||
if (g_strcmp0 (nm_device_get_iface (NM_DEVICE (iter->data)), iface) == 0)
|
||||
return NM_DEVICE (iter->data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
manager_sleeping (NMManager *self)
|
||||
{
|
||||
|
|
@ -1751,9 +1749,13 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
|
|||
RfKillType rtype;
|
||||
GSList *iter, *remove = NULL;
|
||||
gboolean connection_assumed = FALSE;
|
||||
int ifindex;
|
||||
|
||||
/* No duplicates */
|
||||
if (nm_manager_get_device_by_udi (self, nm_device_get_udi (device)))
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
if (ifindex > 0 && nm_manager_get_device_by_ifindex (self, ifindex))
|
||||
return;
|
||||
if (find_device_by_iface (self, nm_device_get_iface (device)))
|
||||
return;
|
||||
|
||||
/* Remove existing devices owned by the new device; eg remove ethernet
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue