summaryrefslogtreecommitdiffstats
path: root/net.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-11-17 22:50:37 +0000
committerRoy Marples <roy@marples.name>2008-11-17 22:50:37 +0000
commit5f1643f5844b6cf6adba486c8712931b98533c74 (patch)
treeefc942fbcc0a4f2fcb695f09da3a46cb42a72900 /net.c
parentc989b02361577d2227094cd396c760c1df39e697 (diff)
downloaddhcpcd-5f1643f5844b6cf6adba486c8712931b98533c74.tar.xz
Fix working with linux aliased interfaces again.
Diffstat (limited to 'net.c')
-rw-r--r--net.c5
1 files changed, 5 insertions, 0 deletions
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