[git commit] udhcpc6: fix binding to network aliases

Denys Vlasenko vda.linux at googlemail.com
Thu Dec 15 22:57:27 UTC 2022


commit: https://git.busybox.net/busybox/commit/?id=02ca56564628de474f7a59dbdf3a1a8711b5bee7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 networking/udhcp/d6_socket.c | 13 +++++++++----
 1 file 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(
 		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);


More information about the busybox-cvs mailing list