From: Stig Venaas Date: Thu, 27 Jun 2002 13:20:37 +0000 (+0000) Subject: Use IPV6_V6ONLY on IPv6 sockets if available. This way we only get IPv6 X-Git-Tag: NO_SLAP_OP_BLOCKS~1389 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=804490a8b12a94a19e7c1a8710a7d8a2fb7d5477;p=openldap Use IPV6_V6ONLY on IPv6 sockets if available. This way we only get IPv6 packets on the IPv6 socket, and we receive only IPv6 with -6. --- diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index d60f875f3a..9d260fc240 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -743,6 +743,24 @@ static int slap_open_listener( break; #ifdef LDAP_PF_INET6 case AF_INET6: +#ifdef IPV6_V6ONLY + /* Try to use IPv6 sockets for IPv6 only */ + tmp = 1; + rc = setsockopt( l.sl_sd, IPPROTO_IPV6, IPV6_V6ONLY, + (char *) &tmp, sizeof(tmp) ); + if ( rc == AC_SOCKET_ERROR ) { + int err = sock_errno(); +#ifdef NEW_LOGGING + LDAP_LOG(( "connection", LDAP_LEVEL_INFO, + "slap_open_listener: setsockopt( %ld, IPV6_V6ONLY ) failed errno %d (%s)\n", + (long)l.sl_sd, err, sock_errstr(err) )); +#else + Debug( LDAP_DEBUG_ANY, + "slapd(%ld): setsockopt(IPV6_V6ONLY) failed errno=%d (%s)\n", + (long) l.sl_sd, err, sock_errstr(err) ); +#endif + } +#endif addrlen = sizeof(struct sockaddr_in6); break; #endif