]> git.sur5r.net Git - openldap/commitdiff
Use IPV6_V6ONLY on IPv6 sockets if available. This way we only get IPv6
authorStig Venaas <venaas@openldap.org>
Thu, 27 Jun 2002 13:20:37 +0000 (13:20 +0000)
committerStig Venaas <venaas@openldap.org>
Thu, 27 Jun 2002 13:20:37 +0000 (13:20 +0000)
packets on the IPv6 socket, and we receive only IPv6 with -6.

servers/slapd/daemon.c

index d60f875f3a79dff6e019fc9f55f4b2ce05a8c534..9d260fc240913315f6ed5ed18fe5ed1aceb42e3c 100644 (file)
@@ -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