chiark / gitweb /
core,logind,networkd: don't pick up devices from udev before they finished udev initi...
[elogind.git] / src / network / networkd-manager.c
index 724e5e5..6998562 100644 (file)
@@ -157,48 +157,41 @@ static int manager_process_link(Manager *m, struct udev_device *device) {
 }
 
 int manager_udev_enumerate_links(Manager *m) {
+        _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
         struct udev_list_entry *item = NULL, *first = NULL;
-        struct udev_enumerate *e;
         int r;
 
         assert(m);
 
         e = udev_enumerate_new(m->udev);
-        if (!e) {
-                r = -ENOMEM;
-                goto finish;
-        }
+        if (!e)
+                return -ENOMEM;
 
         r = udev_enumerate_add_match_subsystem(e, "net");
         if (r < 0)
-                goto finish;
+                return r;
 
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
-                goto finish;
+                return r;
 
         first = udev_enumerate_get_list_entry(e);
         udev_list_entry_foreach(item, first) {
-                struct udev_device *d;
+                _cleanup_udev_device_unref_ struct udev_device *d = NULL;
                 int k;
 
                 d = udev_device_new_from_syspath(m->udev, udev_list_entry_get_name(item));
-                if (!d) {
-                        r = -ENOMEM;
-                        goto finish;
-                }
+                if (!d)
+                        return -ENOMEM;
 
-                k = manager_process_link(m, d);
-                udev_device_unref(d);
+                if (!udev_device_get_is_initialized(d))
+                        continue;
 
+                k = manager_process_link(m, d);
                 if (k < 0)
                         r = k;
         }
 
-finish:
-        if (e)
-                udev_enumerate_unref(e);
-
         return r;
 }