]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Only start on settled devices.
authorRoy Marples <roy@marples.name>
Mon, 9 Sep 2013 18:17:54 +0000 (18:17 +0000)
committerRoy Marples <roy@marples.name>
Mon, 9 Sep 2013 18:17:54 +0000 (18:17 +0000)
dev/udev.c
dev/udev.h
net.c

index 207253e82d56924f3b89c26302efe77986996e13..5cd99297878658849aaf1e6a06b0650f670fc542 100644 (file)
 #include "../eloop.h"
 #include "udev.h"
 
+static struct udev *udev;
 static struct udev_monitor *monitor;
 
+int
+libudev_settled(const char *ifname)
+{
+       struct udev_device *device;
+
+       device = udev_device_new_from_subsystem_sysname(udev, "net", ifname);
+       return device ? 1 : 0;
+}
+
 static void
 libudev_handledata(__unused void *arg)
 {
@@ -73,22 +83,28 @@ libudev_listening(void)
 void
 libudev_stop(void)
 {
-       struct udev *udev;
 
        if (monitor) {
-               udev = udev_monitor_get_udev(monitor);
-               udev_unref(udev);
                udev_monitor_unref(monitor);
                monitor = NULL;
        }
+
+       if (udev) {
+               udev_unref(udev);
+               udev = NULL;
+       }
 }
 
 int
 libudev_start(void)
 {
-       struct udev *udev;
        int fd;
 
+       if (udev) {
+               syslog(LOG_ERR, "libudev: already started");
+               return -1;
+       }
+
        syslog(LOG_DEBUG, "libudev: starting");
        udev = udev_new();
        if (udev == NULL) {
index a1702ffd0db5879da5d2e28412c54a26a2886223..0d785726ab05c844b0140f329b83e5940e332434 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef LIBUDEV_H
 #define LIBUDEV_H
 
+int libudev_settled(const char *);
 int libudev_listening(void);
 int libudev_start(void);
 void libudev_stop(void);
diff --git a/net.c b/net.c
index 0720a0f46b01d3e70e7843292d6e531945007165..cbdde113c5ad718622e03600535c6c2f7943fe97 100644 (file)
--- a/net.c
+++ b/net.c
@@ -73,6 +73,9 @@
 #include "ipv4.h"
 #include "ipv6nd.h"
 #include "net.h"
+#ifdef LIBUDEV
+#include "dev/udev.h"
+#endif
 
 int socket_afnet = -1;
 
@@ -267,6 +270,11 @@ discover_interfaces(int argc, char * const *argv)
 #endif
                }
 
+#ifdef LIBUDEV
+               if (!libudev_settled(ifa->ifa_name))
+                       continue;
+#endif
+
                /* It's possible for an interface to have >1 AF_LINK.
                 * For our purposes, we use the first one. */
                TAILQ_FOREACH(ifp, ifs, next) {