]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix working with linux aliased interfaces again.
authorRoy Marples <roy@marples.name>
Mon, 17 Nov 2008 22:50:37 +0000 (22:50 +0000)
committerRoy Marples <roy@marples.name>
Mon, 17 Nov 2008 22:50:37 +0000 (22:50 +0000)
dhcpcd.c
if-linux.c
net.c

index 27973ec00a792b88bb70b07a0a8117d5c6f1af7e..0a9244e9b497a27bd86e6565fa313ca1d18afdde 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -860,7 +860,7 @@ configure_interface(struct interface *iface, int argc, char **argv)
        /* If we haven't specified a ClientID and our hardware address
         * length is greater than DHCP_CHADDR_LEN then we enforce a ClientID
         * of the hardware address family and the hardware address. */
-       if (!(ifo->options & DHCPCD_CLIENTID) && iface->hwlen > DHCP_CHADDR_LEN)
+       if (iface->hwlen > DHCP_CHADDR_LEN)
                ifo->options |= DHCPCD_CLIENTID;
 
        free(iface->clientid);
index 1dca9ee11b6dc00ee8563e9052fb70374827d18d..d572e82d079c321235e8f107a268a967c56a802d 100644 (file)
@@ -431,7 +431,8 @@ struct interface *
 discover_interfaces(int argc, char * const *argv)
 {
        FILE *f;
-       char *p;
+       char ifn[IF_NAMESIZE];
+       char *p, *c;
        size_t ln = 0, n;
        int i;
        struct interface *ifs = NULL, *ifp, *ifl;
@@ -451,11 +452,18 @@ discover_interfaces(int argc, char * const *argv)
                        if (ifp)
                                continue;
                        if (argc > 0) {
-                               for (i = 0; i < argc; i++)
-                                       if (strcmp(argv[i], p) == 0)
+                               for (i = 0; i < argc; i++) {
+                                       /* Check the real interface name */
+                                       strlcpy(ifn, argv[i], sizeof(ifn));
+                                       c = strchr(ifn, ':');
+                                       if (c)
+                                               *c = '\0';
+                                       if (strcmp(ifn, p) == 0)
                                                break;
+                               }
                                if (i == argc)
                                        continue;
+                               p = argv[i];
                        } else {
                                for (i = 0; i < ifdc; i++)
                                        if (!fnmatch(ifdv[i], p, 0))
diff --git a/net.c b/net.c
index 01f99a74265f59d3f8158790da46d651c54323da..291f40cca23d36827b034a3685997e88dbdae916 100644 (file)
--- a/net.c
+++ b/net.c
@@ -487,6 +487,7 @@ open_udp_socket(struct interface *iface)
        int n;
 #ifdef SO_BINDTODEVICE
        struct ifreq ifr;
+       char *p;
 #endif
 
        if ((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
@@ -498,6 +499,10 @@ open_udp_socket(struct interface *iface)
 #ifdef SO_BINDTODEVICE
        memset(&ifr, 0, sizeof(ifr));
        strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
+       /* We can only bind to the real device */
+       p = strchr(ifr.ifr_name, ':');
+       if (p)
+               *p = '\0';
        if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) == -1)
                goto eexit;
 #endif