diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-12-15 23:57:27 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-12-15 23:57:27 +0100 |
commit | 02ca56564628de474f7a59dbdf3a1a8711b5bee7 (patch) | |
tree | fd1afdc27dd43439743eaf2046f798eb99d3150d | |
parent | 6c2ddf808ed70bf515daf4d073411d86ec043550 (diff) | |
download | busybox-w32-02ca56564628de474f7a59dbdf3a1a8711b5bee7.tar.gz busybox-w32-02ca56564628de474f7a59dbdf3a1a8711b5bee7.tar.bz2 busybox-w32-02ca56564628de474f7a59dbdf3a1a8711b5bee7.zip |
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 21cf61c6e..acf108367 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c | |||
@@ -95,9 +95,6 @@ int FAST_FUNC d6_read_interface( | |||
95 | close(fd); | 95 | close(fd); |
96 | } | 96 | } |
97 | 97 | ||
98 | if (retval == 0) | ||
99 | return retval; | ||
100 | |||
101 | if (retval & (1<<0)) | 98 | if (retval & (1<<0)) |
102 | bb_error_msg("can't get %s", "MAC"); | 99 | bb_error_msg("can't get %s", "MAC"); |
103 | if (retval & (1<<1)) | 100 | if (retval & (1<<1)) |
@@ -109,6 +106,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) | |||
109 | { | 106 | { |
110 | int fd; | 107 | int fd; |
111 | struct sockaddr_in6 addr; | 108 | struct sockaddr_in6 addr; |
109 | char *colon; | ||
112 | 110 | ||
113 | log2("opening listen socket on *:%d %s", port, inf); | 111 | log2("opening listen socket on *:%d %s", port, inf); |
114 | fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); | 112 | fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); |
@@ -117,10 +115,17 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) | |||
117 | if (setsockopt_broadcast(fd) == -1) | 115 | if (setsockopt_broadcast(fd) == -1) |
118 | bb_simple_perror_msg_and_die("SO_BROADCAST"); | 116 | bb_simple_perror_msg_and_die("SO_BROADCAST"); |
119 | 117 | ||
120 | /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */ | 118 | /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */ |
119 | colon = strrchr(inf, ':'); | ||
120 | if (colon) | ||
121 | *colon = '\0'; | ||
122 | |||
121 | if (setsockopt_bindtodevice(fd, inf)) | 123 | if (setsockopt_bindtodevice(fd, inf)) |
122 | xfunc_die(); /* warning is already printed */ | 124 | xfunc_die(); /* warning is already printed */ |
123 | 125 | ||
126 | if (colon) | ||
127 | *colon = ':'; | ||
128 | |||
124 | memset(&addr, 0, sizeof(addr)); | 129 | memset(&addr, 0, sizeof(addr)); |
125 | addr.sin6_family = AF_INET6; | 130 | addr.sin6_family = AF_INET6; |
126 | addr.sin6_port = htons(port); | 131 | addr.sin6_port = htons(port); |