Commit 98af46c5 authored by Peter Griess's avatar Peter Griess Committed by facebook-github-bot-9

Set IPV6_V6ONLY in folly::AsyncUDPServerSocket

Summary: - This mirrors the behavior in AsyncServerSocket

Reviewed By: @yfeldblum

Differential Revision: D2338665
parent 05639983
...@@ -91,6 +91,18 @@ void AsyncUDPSocket::bind(const folly::SocketAddress& address) { ...@@ -91,6 +91,18 @@ void AsyncUDPSocket::bind(const folly::SocketAddress& address) {
} }
} }
// If we're using IPv6, make sure we don't accept V4-mapped connections
if (address.getFamily() == AF_INET6) {
int flag = 1;
if (::setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY,
&flag, sizeof(flag))) {
throw AsyncSocketException(
AsyncSocketException::NOT_OPEN,
"Failed to set IPV6_V6ONLY",
errno);
}
}
// bind to the address // bind to the address
sockaddr_storage addrStorage; sockaddr_storage addrStorage;
address.getAddress(&addrStorage); address.getAddress(&addrStorage);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment