summaryrefslogtreecommitdiffstats
path: root/crypto/bio
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2018-01-25 15:16:18 +0100
committerBernd Edlinger <bernd.edlinger@hotmail.de>2018-01-25 15:16:18 +0100
commitf1a0f9faa2a59835d962ade5acd731f85fbf3e6a (patch)
treeffbbc8ab7fc698be1bf49225ae33b869f8834a6b /crypto/bio
parent1f82eba718f758757a439e717ea7a5aa8be55f8d (diff)
Fix setting of IPV6_V6ONLY on Windows
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5139)
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/b_sock2.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/bio/b_sock2.c b/crypto/bio/b_sock2.c
index a28e1b4e1e..f62c07806c 100644
--- a/crypto/bio/b_sock2.c
+++ b/crypto/bio/b_sock2.c
@@ -175,8 +175,10 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
return 0;
# ifndef OPENSSL_SYS_WINDOWS
- /* SO_REUSEADDR has different behavior on Windows than on
- * other operating systems, don't set it there. */
+ /*
+ * SO_REUSEADDR has different behavior on Windows than on
+ * other operating systems, don't set it there.
+ */
if (options & BIO_SOCK_REUSEADDR) {
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const void *)&on, sizeof(on)) != 0) {
@@ -206,7 +208,12 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
}
# ifdef IPV6_V6ONLY
- if ((options & BIO_SOCK_V6_ONLY) && BIO_ADDR_family(addr) == AF_INET6) {
+ if (BIO_ADDR_family(addr) == AF_INET6) {
+ /*
+ * Note: Windows default of IPV6_V6ONLY is ON, and Linux is OFF.
+ * Therefore we always have to use setsockopt here.
+ */
+ on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
(const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());