projects
/
folly.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0563998
)
Set IPV6_V6ONLY in folly::AsyncUDPServerSocket
author
Peter Griess
<pgriess@fb.com>
Thu, 13 Aug 2015 17:19:09 +0000
(10:19 -0700)
committer
facebook-github-bot-9
<folly-bot@fb.com>
Thu, 13 Aug 2015 18:20:31 +0000
(11:20 -0700)
Summary: - This mirrors the behavior in AsyncServerSocket
Reviewed By: @yfeldblum
Differential Revision:
D2338665
folly/io/async/AsyncUDPSocket.cpp
patch
|
blob
|
history
diff --git
a/folly/io/async/AsyncUDPSocket.cpp
b/folly/io/async/AsyncUDPSocket.cpp
index 5b12812616f60ef84c2c62c3f613d9bc255c2239..1364ed3fac93deb003a2c75ef07896e22d150838 100644
(file)
--- a/
folly/io/async/AsyncUDPSocket.cpp
+++ b/
folly/io/async/AsyncUDPSocket.cpp
@@
-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
sockaddr_storage addrStorage;
address.getAddress(&addrStorage);