]> granicus.if.org Git - pdns/commitdiff
merge with head
authorMark Zealey <mark@markandruth.co.uk>
Mon, 13 Jan 2014 12:26:27 +0000 (14:26 +0200)
committerMark Zealey <mark@markandruth.co.uk>
Mon, 13 Jan 2014 12:26:27 +0000 (14:26 +0200)
1  2 
pdns/common_startup.cc
pdns/docs/pdns.xml
pdns/nameserver.cc
pdns/pdns.conf-dist

index 05b38792f5c2d736febd893293ccd7d079d2dbfd,82d1bbf6c79e57f3934d960cd57b42d881a9ab6f..a0fc5c7a3e1c6d4338cb3f23e1ee9b65046cde14
@@@ -53,8 -53,9 +53,10 @@@ void declareArguments(
    ::arg().set("urlredirector","Where we send hosts to that need to be url redirected")="127.0.0.1";
    ::arg().set("smtpredirector","Our smtpredir MX host")="a.misconfigured.powerdns.smtp.server";
    ::arg().set("local-address","Local IP addresses to which we bind")="0.0.0.0";
+   ::arg().setSwitch("local-address-nonexist-fail","Fail to start if one or more of the local-address's do not exist on this server")="yes";
    ::arg().set("local-ipv6","Local IP address to which we bind")="";
 +  ::arg().setSwitch("reuseport","Enable higher performance on compliant kernels by using SO_REUSEPORT allowing each receiver thread to open its own socket")="no";
+   ::arg().setSwitch("local-ipv6-nonexist-fail","Fail to start if one or more of the local-ipv6 addresses do not exist on this server")="yes";
    ::arg().set("query-local-address","Source IP address for sending queries")="0.0.0.0";
    ::arg().set("query-local-address6","Source IPv6 address for sending queries")="::";
    ::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0";
Simple merge
index 784a54748559ecfa83527155cc7f8f16a9203a62,04d9027010c0158c859531bdedcc9e7fcc7949b7..3f044190ce41f8156799979abdbfe52328ab18ab
@@@ -132,12 -126,15 +132,17 @@@ void UDPNameserver::bindIPv4(
      if(locala.sin4.sin_family != AF_INET) 
        throw PDNSException("Attempting to bind IPv4 socket to IPv6 address");
  
 -    g_localaddresses.push_back(locala);
 +    if( !d_additional_socket )
 +        g_localaddresses.push_back(locala);
 +
      if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
-       L<<Logger::Error<<"binding UDP socket to '"+locala.toStringWithPort()+": "<<strerror(errno)<<endl;
-       throw PDNSException("Unable to bind to UDP socket");
+       if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
+         L<<Logger::Error<<"IPv4 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
+         continue;
+       } else {
+         L<<Logger::Error<<"binding UDP socket to '"+locala.toStringWithPort()+": "<<strerror(errno)<<endl;
+         throw PDNSException("Unable to bind to UDP socket");
+       }
      }
      d_sockets.push_back(s);
      L<<Logger::Error<<"UDP server bound to "<<locala.toStringWithPort()<<endl;
@@@ -221,22 -217,20 +226,27 @@@ void UDPNameserver::bindIPv6(
      ComboAddress locala(localname, ::arg().asNum("local-port"));
      
      if(IsAnyAddress(locala)) {
 -      int val=1;
 -      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
 +      setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &one, sizeof(one));     // linux supports this, so why not - might fail on other systems
 +      setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one)); 
 +      setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));      // if this fails, we report an error in tcpreceiver too
      }
 -    g_localaddresses.push_back(locala);
 +
 +#ifdef SO_REUSEPORT
 +    if( d_can_reuseport )
 +        if( setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) )
 +          d_can_reuseport = false;
 +#endif
 +
 +    if( !d_additional_socket )
 +        g_localaddresses.push_back(locala);
      if(::bind(s, (sockaddr*)&locala, sizeof(locala))<0) {
-       L<<Logger::Error<<"binding to UDP ipv6 socket: "<<strerror(errno)<<endl;
-       throw PDNSException("Unable to bind to UDP ipv6 socket");
+       if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-ipv6-nonexist-fail") ) {
+         L<<Logger::Error<<"IPv6 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
+         continue;
+       } else {
+         L<<Logger::Error<<"binding to UDP ipv6 socket "<< localname <<": "<<strerror(errno)<<endl;
+         throw PDNSException("Unable to bind to UDP ipv6 socket");
+       }
      }
      d_sockets.push_back(s);
      struct pollfd pfd;
Simple merge