]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Because dhcpcd now binds to the interfaces LL address when not
authorRoy Marples <roy@marples.name>
Tue, 25 Apr 2017 19:47:53 +0000 (20:47 +0100)
committerRoy Marples <roy@marples.name>
Tue, 25 Apr 2017 19:47:53 +0000 (20:47 +0100)
running in master mode, the socket options SO_REUSEADDR and
SO_REUSEPORT can be dropped.
If there is a problem binding the socket, log an error.

src/dhcp6.c

index dfa8d91dba7ff7a261a48ede9285b3e09e492483..3b304f38944846e65b7b9e150fd7845a6e324a28 100644 (file)
@@ -3213,11 +3213,6 @@ dhcp6_open(struct dhcpcd_ctx *ctx)
        ctx->dhcp6_fd = xsocket(PF_INET6, SOCK_DGRAM | SOCK_FLAGS, IPPROTO_UDP);
 #undef SOCK_FLAGS
        if (ctx->dhcp6_fd == -1)
-               return -1;
-
-       n = 1;
-       if (setsockopt(ctx->dhcp6_fd, SOL_SOCKET, SO_REUSEADDR,
-           &n, sizeof(n)) == -1)
                goto errexit;
 
        n = 1;
@@ -3225,13 +3220,6 @@ dhcp6_open(struct dhcpcd_ctx *ctx)
            &n, sizeof(n)) == -1)
                goto errexit;
 
-#ifdef SO_REUSEPORT
-       n = 1;
-       if (setsockopt(ctx->dhcp6_fd, SOL_SOCKET, SO_REUSEPORT,
-           &n, sizeof(n)) == -1)
-               logerr("SO_REUSEPORT");
-#endif
-
        if (!(ctx->options & DHCPCD_MASTER)) {
                /* Bind to the link-local address to allow more than one
                 * DHCPv6 client to work. */
@@ -3260,8 +3248,11 @@ dhcp6_open(struct dhcpcd_ctx *ctx)
        return 0;
 
 errexit:
-       close(ctx->dhcp6_fd);
-       ctx->dhcp6_fd = -1;
+       logerr(__func__);
+       if (ctx->dhcp6_fd != -1) {
+               close(ctx->dhcp6_fd);
+               ctx->dhcp6_fd = -1;
+       }
        return -1;
 }