diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-08-10 00:27:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-08-10 00:27:22 +0200 |
commit | 6567edd10b0ebd3333f4283decd90e1d57a42885 (patch) | |
tree | cfcc85ba62b5006d7a23ce7f8465a1a97d4b2ac9 | |
parent | 4919565c152f2ecee760b5419c947764e991ab3e (diff) |
udhcp[cd]: fix binding to network aliases. Closes 5432, 5438
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/socket.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index a5220ba74..a42106960 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -80,6 +80,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) { int fd; struct sockaddr_in addr; + char *colon; log1("Opening listen socket on *:%d %s", port, inf); fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); @@ -88,10 +89,17 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) if (setsockopt_broadcast(fd) == -1) bb_perror_msg_and_die("SO_BROADCAST"); - /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */ + /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */ + colon = strrchr(inf, ':'); + if (colon) + *colon = '\0'; + if (setsockopt_bindtodevice(fd, inf)) xfunc_die(); /* warning is already printed */ + if (colon) + *colon = ':'; + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); |