]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
move to IPV6_V6ONLY, warn if it fails but charge on regardless.
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 11 Oct 2012 09:39:08 +0000 (09:39 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 11 Oct 2012 09:39:08 +0000 (09:39 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2799 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/nameserver.cc
pdns/tcpreceiver.cc

index 60195b3f48b93d828e92b7e7d7ea552e1aeb5de6..3d31c099df5f9f6149d6dfaa4f03329a9f9e6ea1 100644 (file)
@@ -174,8 +174,9 @@ void UDPNameserver::bindIPv6()
     
     if(IsAnyAddress(locala)) {
       int val=1;
-      setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val));
-      setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val));
+      setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val));     // linux supports this, so why not - might fail on other systems
+      setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); 
+      setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));      // if this fails, we report an error in tcpreceiver too
     }
     
     if(::bind(s, (sockaddr*)&locala, sizeof(locala))<0) {
index f3fe7c1c3e18001ce88875bd3d87d2e0105149e5..06c7e0602d4e6872dce8984361d3e0a1dcfcb25a 100644 (file)
@@ -194,6 +194,7 @@ catch(NetworkError& ae) {
 static void proxyQuestion(shared_ptr<DNSPacket> packet)
 {
   int sock=socket(AF_INET, SOCK_STREAM, 0);
+  
   Utility::setCloseOnExec(sock);
   if(sock < 0)
     throw NetworkError("Error making TCP connection socket to recursor: "+stringerror());
@@ -822,7 +823,7 @@ TCPNameserver::TCPNameserver()
   for(vector<string>::const_iterator laddr=locals.begin();laddr!=locals.end();++laddr) {
     int s=socket(AF_INET,SOCK_STREAM,0); 
     Utility::setCloseOnExec(s);
-
+    
     if(s<0) 
       throw AhuException("Unable to acquire TCP socket: "+stringerror());
 
@@ -833,7 +834,7 @@ TCPNameserver::TCPNameserver()
       L<<Logger::Error<<"Setsockopt failed"<<endl;
       exit(1);  
     }
-
+    
     if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) {
       L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
       throw AhuException("Unable to bind to TCP socket");
@@ -867,7 +868,9 @@ TCPNameserver::TCPNameserver()
       L<<Logger::Error<<"Setsockopt failed"<<endl;
       exit(1);  
     }
-
+    if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp)) < 0) {
+      L<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
+    }
     if(bind(s, (const sockaddr*)&local, local.getSocklen())<0) {
       L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
       throw AhuException("Unable to bind to TCPv6 socket");