]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add configuration option to disable IP_BIND_ADDRESS_NO_PORT.
authorDan McCombs <dmccombs@dyn.com>
Mon, 30 Oct 2017 22:50:55 +0000 (18:50 -0400)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 14 Feb 2018 10:37:05 +0000 (11:37 +0100)
(cherry picked from commit 5602f131f16a933a6c298e35bff859d0b91d1cc3)

pdns/dnsdist-lua.cc
pdns/dnsdist-tcp.cc
pdns/dnsdist.hh
pdns/dnsdistdist/docs/reference/config.rst

index 799c10eb1acb114a78370b23066c2751298bed08..96be0672682cc16a91801cb67c5993fabf80d0e1 100644 (file)
@@ -471,6 +471,10 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
                          ret->useECS=boost::get<bool>(vars["useClientSubnet"]);
                        }
 
+                       if(vars.count("ipBindAddrNoPort")) {
+                         ret->ipBindAddrNoPort=boost::get<bool>(vars["ipBindAddrNoPort"]);
+                       }
+
                        if(vars.count("maxCheckFailures")) {
                          ret->maxCheckFailures=std::stoi(boost::get<string>(vars["maxCheckFailures"]));
                        }
index b5fe2fd5b92c4cdbc1ddb47411562fe31fce45d3..9d887d03e6414e770e78d121c7bbcfae9a4e482a 100644 (file)
@@ -56,7 +56,9 @@ static int setupTCPDownstream(shared_ptr<DownstreamState> ds, uint16_t& downstre
       if (!IsAnyAddress(ds->sourceAddr)) {
         SSetsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
 #ifdef IP_BIND_ADDRESS_NO_PORT
-        SSetsockopt(sock, SOL_IP, IP_BIND_ADDRESS_NO_PORT, 1);
+        if (ds->ipBindAddrNoPort) {
+          SSetsockopt(sock, SOL_IP, IP_BIND_ADDRESS_NO_PORT, 1);
+        }
 #endif
         SBind(sock, ds->sourceAddr);
       }
index d1c7891333b77a3690617a8eefbaf45b4348c832..34f36d916046a7abed3e0830250ea2747f141b58 100644 (file)
@@ -628,6 +628,7 @@ struct DownstreamState
   bool setCD{false};
   std::atomic<bool> connected{false};
   bool tcpFastOpen{false};
+  bool ipBindAddrNoPort{true};
   bool isUp() const
   {
     if(availability == Availability::Down)
index a8eae8e6a594dbf8f25af03f48901445cb0bdb89..f79abe4f0f0e42cc5b7cdb8a20d941869abd9688 100644 (file)
@@ -223,6 +223,7 @@ Servers
       tcpSendTimeout=NUM,    -- The timeout (in seconds) of a TCP write attempt
       tcpRecvTimeout=NUM,    -- The timeout (in seconds) of a TCP read attempt
       tcpFastOpen=BOOL,      -- Whether to enable TCP Fast Open
+      ipBindAddrNoPort=BOOL, -- Whether to enable IP Bind Address No Port
       name=STRING,           -- The name associated to this backend, for display purpose
       checkName=STRING,      -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net."
       checkType=STRING,      -- Use STRING as QTYPE in the health-check query, default: "A"