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.
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;
&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. */
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;
}