From: Stephane Bakhos Date: Thu, 23 Jul 2020 02:51:28 +0000 (-0400) Subject: Add an option to toggle the reconnectOnUp option X-Git-Tag: rec-4.4.0-beta1~50^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7da1535de9d4d87b4502fc453f11264b4817c69;p=thirdparty%2Fpdns.git Add an option to toggle the reconnectOnUp option --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 9b3255db48..26b12012b9 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -462,7 +462,7 @@ const std::vector g_consoleKeywords{ { "newQPSLimiter", true, "rate, burst", "configure a QPS limiter with that rate and that burst capacity" }, { "newRemoteLogger", true, "address:port [, timeout=2, maxQueuedEntries=100, reconnectWaitTime=1]", "create a Remote Logger object, to use with `RemoteLogAction()` and `RemoteLogResponseAction()`" }, { "newRuleAction", true, "DNS rule, DNS action [, {uuid=\"UUID\"}]", "return a pair of DNS Rule and DNS Action, to be used with `setRules()`" }, - { "newServer", true, "{address=\"ip:port\", qps=1000, order=1, weight=10, pool=\"abuse\", retries=5, tcpConnectTimeout=5, tcpSendTimeout=30, tcpRecvTimeout=30, checkName=\"a.root-servers.net.\", checkType=\"A\", maxCheckFailures=1, mustResolve=false, useClientSubnet=true, source=\"address|interface name|address@interface\", sockets=1}", "instantiate a server" }, + { "newServer", true, "{address=\"ip:port\", qps=1000, order=1, weight=10, pool=\"abuse\", retries=5, tcpConnectTimeout=5, tcpSendTimeout=30, tcpRecvTimeout=30, checkName=\"a.root-servers.net.\", checkType=\"A\", maxCheckFailures=1, mustResolve=false, useClientSubnet=true, source=\"address|interface name|address@interface\", sockets=1, reconnectOnUp=false}", "instantiate a server" }, { "newServerPolicy", true, "name, function", "create a policy object from a Lua function" }, { "newSuffixMatchNode", true, "", "returns a new SuffixMatchNode" }, { "NoneAction", true, "", "Does nothing. Subsequent rules are processed after this action" }, diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 39d2e595ad..796753ebc9 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -465,6 +465,10 @@ static void setupLuaConfig(bool client, bool configCheck) ret->minRiseSuccesses=std::stoi(boost::get(vars["rise"])); } + if(vars.count("reconnectOnUp")) { + ret->reconnectOnUp=boost::get(vars["reconnectOnUp"]); + } + if(vars.count("cpus")) { for (const auto& cpu : boost::get>>(vars["cpus"])) { cpus.insert(std::stoi(cpu.second)); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 1ffb3aeb74..0e413bcc84 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -843,6 +843,7 @@ struct DownstreamState std::atomic_flag threadStarted; bool tcpFastOpen{false}; bool ipBindAddrNoPort{true}; + bool reconnectOnUp{false}; bool isUp() const { diff --git a/pdns/dnsdistdist/dnsdist-healthchecks.cc b/pdns/dnsdistdist/dnsdist-healthchecks.cc index 5b9716c504..ce79c3405b 100644 --- a/pdns/dnsdistdist/dnsdist-healthchecks.cc +++ b/pdns/dnsdistdist/dnsdist-healthchecks.cc @@ -60,7 +60,7 @@ void updateHealthCheckResult(const std::shared_ptr& dss, bool n if(newState != dss->upStatus) { warnlog("Marking downstream %s as '%s'", dss->getNameWithAddr(), newState ? "up" : "down"); - if (newState) { + if (newState && dss->reconnectOnUp) { newState = dss->reconnect(); if (dss->connected && !dss->threadStarted.test_and_set()) { diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index 2a036de868..6297ce487e 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -469,7 +469,8 @@ Servers sockets=NUM, -- Number of sockets (and thus source ports) used toward the backend server, defaults to a single one disableZeroScope=BOOL, -- Disable the EDNS Client Subnet 'zero scope' feature, which does a cache lookup for an answer valid for all subnets (ECS scope of 0) before adding ECS information to the query and doing the regular lookup. This requires the ``parseECS`` option of the corresponding cache to be set to true rise=NUM, -- Require NUM consecutive successful checks before declaring the backend up, default: 1 - useProxyProtocol=BOOL -- Add a proxy protocol header to the query, passing along the client's IP address and port along with the original destination address and port. Default is disabled. + useProxyProtocol=BOOL, -- Add a proxy protocol header to the query, passing along the client's IP address and port along with the original destination address and port. Default is disabled. + reconnectOnUp=BOOL -- Close and reopen the sockets when a server transits from Down to Up. This helps when an interface is missing when dnsdist is started. Default is disabled. }) :param str server_string: A simple IP:PORT string.