Skip to content
Snippets Groups Projects
Commit b9a0594c authored by Marek Vavruša's avatar Marek Vavruša
Browse files

net: V6ONLY for bound sockets only

parent 557fe443
No related branches found
No related tags found
No related merge requests found
......@@ -62,14 +62,6 @@ int net_unbound_socket(int type, struct sockaddr_storage *ss)
return socket;
}
/* Make the socket IPv6 only to allow 'any' for IPv4 and IPv6 at the same time. */
if (ss->ss_family == AF_INET6) {
/* Do not support mapping IPv4 in IPv6 sockets. */
int flag = 1;
(void) setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY,
&flag, sizeof(flag));
}
return socket;
}
......@@ -94,6 +86,12 @@ int net_bound_socket(int type, struct sockaddr_storage *ss)
unlink(addr_str);
}
/* Make the socket IPv6 only to allow 'any' for IPv4 and IPv6 at the same time. */
if (ss->ss_family == AF_INET6) {
(void) setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY,
&flag, sizeof(flag));
}
/* Bind to specified address. */
int ret = bind(socket, (struct sockaddr *)ss, sockaddr_len(ss));
if (ret < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment