socket-dynamic: Use IPv6-only mode for IPv6 sockets

Same as the previous commit.

Fixes: 5f9ad62a81 ("socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore")
This commit is contained in:
Tobias Brunner
2022-09-22 17:38:58 +02:00
parent ebaaacc459
commit 03ea02175e
@@ -410,7 +410,13 @@ static int open_socket(private_socket_dynamic_socket_t *this,
DBG1(DBG_NET, "could not open socket: %s", strerror(errno));
return 0;
}
if (family == AF_INET6 &&
setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0)
{
DBG1(DBG_NET, "unable to set IPV6_V6ONLY on socket: %s", strerror(errno));
close(fd);
return 0;
}
if (bind(fd, &addr.s, addrlen) < 0)
{
DBG1(DBG_NET, "unable to bind socket: %s", strerror(errno));