]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Instead of just renaming the interface on Linux, take the FreeBSD
authorRoy Marples <roy@marples.name>
Tue, 10 Sep 2013 09:56:11 +0000 (09:56 +0000)
committerRoy Marples <roy@marples.name>
Tue, 10 Sep 2013 09:56:11 +0000 (09:56 +0000)
approach and remove the old and create a new one.
This simple change allows the the allow/deny rules to be followed.

dev/udev.c
dhcpcd.c
dhcpcd.h
if-linux.c

index 56f790f6ed1024d8a00ca80e7514c8d4b12dcf0c..1eaa510c5a81d635c672eb136e01cd1b3a6c85f2 100644 (file)
@@ -69,15 +69,17 @@ libudev_handledata(__unused void *arg)
        subsystem = udev_device_get_subsystem(device);
        ifname = udev_device_get_sysname(device);
        action = udev_device_get_action(device);
-       udev_device_unref(device);
 
        /* udev filter documentation says "usually" so double check */
        if (strcmp(subsystem, "net") == 0) {
-               if (strcmp(action, "add") == 0)
+               syslog(LOG_DEBUG, "%s: libudev: %s", ifname, action);
+               if (strcmp(action, "add") == 0 || strcmp(action, "move") == 0)
                        handle_interface(1, ifname);
                else if (strcmp(action, "remove") == 0)
                        handle_interface(-1, ifname);
        }
+
+       udev_device_unref(device);
 }
 
 int
index 085510ee6f068c51cc256c6b6d2e487d1a52714e..f94b2d4fc14dfcbdb502ef24c12c77552aded3f0 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -392,22 +392,6 @@ configure_interface(struct interface *ifp, int argc, char **argv)
        configure_interface1(ifp);
 }
 
-int
-handle_rename(unsigned int ifindex, const char *ifname)
-{
-       struct interface *ifp;
-
-       TAILQ_FOREACH(ifp, ifaces, next) {
-               if (ifp->index == ifindex && strcmp(ifp->name, ifname)) {
-                       syslog(LOG_INFO, "%s: renamed to %s",
-                           ifp->name, ifname);
-                       strlcpy(ifp->name, ifname, sizeof(ifp->name));
-                       return 1;
-               }
-       }
-       return 0;
-}
-
 void
 handle_carrier(int carrier, int flags, const char *ifname)
 {
index 15ca3e187eb69cb122f7285a14c6a8462146f475..4f0f56f5e802a66f0bd20c7aeffa4087abeeb235 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -85,7 +85,6 @@ struct interface *find_interface(const char *);
 int handle_args(struct fd_list *, int, char **);
 void handle_carrier(int, int, const char *);
 void handle_interface(int, const char *);
-int handle_rename(unsigned int, const char *);
 void handle_hwaddr(const char *, const unsigned char *, size_t);
 void drop_interface(struct interface *, const char *);
 int select_profile(struct interface *, const char *);
index d474ede332aa13c68474db636c48743550c414f4..ddbfc0edce53526e5ed6fa2fca8140ba1e40579a 100644 (file)
@@ -415,6 +415,26 @@ static short l2addr_len(unsigned short if_type)
        }
 }
 
+static int
+handle_rename(unsigned int ifindex, const char *ifname)
+{
+       struct interface *ifp;
+
+       TAILQ_FOREACH(ifp, ifaces, next) {
+               if (ifp->index == ifindex && strcmp(ifp->name, ifname)) {
+                       handle_interface(-1, ifp->name);
+#ifdef LIBUDEV
+                       /* Let udev announce the interface for renaming */
+                       if (libudev_listening())
+                               return 1;
+#endif
+                       handle_interface(1, ifname);
+                       return 1;
+               }
+       }
+       return 0;
+}
+
 static int
 link_netlink(struct nlmsghdr *nlm)
 {