Browse Source

- set IPV6_V6ONLY socket option
- a few other dual-stack fixes


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1130 e5f2f494-b856-4b98-b285-d166d9295462

Evan Hunt 15 years ago
parent
commit
3d53e9c286
1 changed files with 18 additions and 7 deletions
  1. 18 7
      src/bin/auth/main.cc

+ 18 - 7
src/bin/auth/main.cc

@@ -106,6 +106,13 @@ getSocket(int af, const char* port) {
         return (-1);
     }
 
+    if (af == AF_INET6) {
+        int on = 1;
+        if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
+            cerr << "couldn't set IPV6_V6ONLY socket option" << endl;
+        }
+    }
+
     if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
         cerr << "binding socket failure" << endl;
         close(s);
@@ -147,7 +154,7 @@ main(int argc, char* argv[]) {
         cerr << "-4 and -6 can't coexist" << endl;
         usage();
     }
-    if (!ipv4_only) {
+    if (!ipv6_only) {
         ps4 = getSocket(AF_INET, port);
         if (ps4 < 0) {
             exit(1);
@@ -200,13 +207,17 @@ main(int argc, char* argv[]) {
                 throw FatalError("select error");
             }
 
-            if (FD_ISSET(ps4, &fds)) {
-                ++counter;
-                auth_server->processMessage(ps4);
+            if (ps4 >= 0) {
+                if (FD_ISSET(ps4, &fds)) {
+                    ++counter;
+                    auth_server->processMessage(ps4);
+                }
             }
-            if (FD_ISSET(ps6, &fds)) {
-                ++counter;
-                auth_server->processMessage(ps6);
+            if (ps6 >= 0) {
+                if (FD_ISSET(ps6, &fds)) {
+                    ++counter;
+                    auth_server->processMessage(ps6);
+                }
             }
     
             if (FD_ISSET(ss, &fds)) {