diff options
author | Denys Vlasenko | 2022-12-15 23:57:27 +0100 |
---|---|---|
committer | Denys Vlasenko | 2022-12-15 23:57:27 +0100 |
commit | 02ca56564628de474f7a59dbdf3a1a8711b5bee7 (patch) | |
tree | fd1afdc27dd43439743eaf2046f798eb99d3150d | |
parent | 6c2ddf808ed70bf515daf4d073411d86ec043550 (diff) | |
download | busybox-02ca56564628de474f7a59dbdf3a1a8711b5bee7.zip busybox-02ca56564628de474f7a59dbdf3a1a8711b5bee7.tar.gz |
udhcpc6: fix binding to network aliases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/d6_socket.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c index 21cf61c..acf1083 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c @@ -95,9 +95,6 @@ int FAST_FUNC d6_read_interface( close(fd); } - if (retval == 0) - return retval; - if (retval & (1<<0)) bb_error_msg("can't get %s", "MAC"); if (retval & (1<<1)) @@ -109,6 +106,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) { int fd; struct sockaddr_in6 addr; + char *colon; log2("opening listen socket on *:%d %s", port, inf); fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); @@ -117,10 +115,17 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) if (setsockopt_broadcast(fd) == -1) bb_simple_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.sin6_family = AF_INET6; addr.sin6_port = htons(port); |