From: Roy Marples Date: Mon, 17 Nov 2008 22:50:37 +0000 (+0000) Subject: Fix working with linux aliased interfaces again. X-Git-Tag: v5.0.0~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f1643f5844b6cf6adba486c8712931b98533c74;p=thirdparty%2Fdhcpcd.git Fix working with linux aliased interfaces again. --- diff --git a/dhcpcd.c b/dhcpcd.c index 27973ec0..0a9244e9 100644 --- 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); diff --git a/if-linux.c b/if-linux.c index 1dca9ee1..d572e82d 100644 --- a/if-linux.c +++ b/if-linux.c @@ -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 01f99a74..291f40cc 100644 --- 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