From bc60d37050c15651c5aa4c6777bfc57efba76965 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 6 Jun 2013 11:41:30 -0500 Subject: [PATCH] platform: fix enumeration of devices at startup to use udev after 2fe8019a nm_platform_query_devices() was just looking in the link_cache, completely ignoring udev, which means that the link list wasn't filtered for things NM wants to ignore. --- src/platform/nm-linux-platform.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 022b839c6a..d075fe5af8 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1039,8 +1039,12 @@ link_get_all (NMPlatform *platform) struct nl_object *object; for (object = nl_cache_get_first (priv->link_cache); object; object = nl_cache_get_next (object)) { - link_init (platform, &device, (struct rtnl_link *) object); - g_array_append_val (links, device); + int ifindex = rtnl_link_get_ifindex ((struct rtnl_link *) object); + + if (g_hash_table_lookup (priv->udev_devices, GINT_TO_POINTER (ifindex))) { + link_init (platform, &device, (struct rtnl_link *) object); + g_array_append_val (links, device); + } } return links; @@ -2326,15 +2330,7 @@ setup (NMPlatform *platform) devices = g_udev_enumerator_execute (enumerator); for (iter = devices; iter; iter = g_list_next (iter)) { - GUdevDevice *udev_device = iter->data; - - if (g_udev_device_get_sysfs_attr (udev_device, "ifindex")) { - int ifindex = g_udev_device_get_sysfs_attr_as_int (udev_device, "ifindex"); - - g_hash_table_insert (priv->udev_devices, GINT_TO_POINTER (ifindex), - g_object_ref (udev_device)); - } - + udev_device_added (platform, G_UDEV_DEVICE (iter->data)); g_object_unref (G_UDEV_DEVICE (iter->data)); } g_list_free (devices);