From: Remi Gacogne Date: Mon, 6 Nov 2017 17:10:57 +0000 (+0100) Subject: dnsdist: Add a class option to health checks X-Git-Tag: dnsdist-1.3.0~191^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de9f7157b6e83a6a69ce428a236d591791c7d5bf;p=pdns dnsdist: Add a class option to health checks --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 9ddb588e6..07dde791c 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -465,6 +465,10 @@ vector> setupLua(bool client, const std::string& confi ret->checkType=boost::get(vars["checkType"]); } + if(vars.count("checkClass")) { + ret->checkClass=std::stoi(boost::get(vars["checkClass"])); + } + if(vars.count("setCD")) { ret->setCD=boost::get(vars["setCD"]); } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 4e646dca2..a1ba41094 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1545,7 +1545,7 @@ static bool upCheck(DownstreamState& ds) try { vector packet; - DNSPacketWriter dpw(packet, ds.checkName, ds.checkType.getCode()); + DNSPacketWriter dpw(packet, ds.checkName, ds.checkType.getCode(), ds.checkClass); dnsheader * requestHeader = dpw.getHeader(); requestHeader->rd=true; if (ds.setCD) { diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index c9ff9bb5a..1d51beaf3 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -599,6 +599,7 @@ struct DownstreamState ComboAddress sourceAddr; DNSName checkName{"a.root-servers.net."}; QType checkType{QType::A}; + uint16_t checkClass{QClass::IN}; std::atomic idOffset{0}; std::atomic sendErrors{0}; std::atomic outstanding{0}; diff --git a/pdns/dnsdistdist/docs/guides/downstreams.rst b/pdns/dnsdistdist/docs/guides/downstreams.rst index 699fea268..3e73b162c 100644 --- a/pdns/dnsdistdist/docs/guides/downstreams.rst +++ b/pdns/dnsdistdist/docs/guides/downstreams.rst @@ -26,7 +26,7 @@ Healthcheck dnsdist uses a health check, sent once every second, to determine the availability of a backend server. By default, an A query for "a.root-servers.net." is sent. -A different query type and target can be specified by passing, respectively, the ``checkType`` and ``checkName`` parameters to :func:`newServer`. +A different query type, class and target can be specified by passing, respectively, the ``checkType``, ``checkClass`` and ``checkName`` parameters to :func:`newServer`. The default behavior is to consider any valid response with an RCODE different from ServFail as valid. If the ``mustResolve`` parameter of :func:`newServer` is set to ``true``, a response will only be considered valid if its RCODE differs from NXDomain, ServFail and Refused. @@ -35,7 +35,7 @@ The number of health check failures before a server is considered down is config The CD flag can be set on the query by setting ``setCD`` to true. e.g.:: - newServer({address="192.0.2.1", checkType="AAAA", checkName="a.root-servers.net.", mustResolve=true}) + newServer({address="192.0.2.1", checkType="AAAA", checkType=DNSClass.CHAOS, checkName="a.root-servers.net.", mustResolve=true}) Source address selection ------------------------ diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index 80cd1bf4b..a9a5ef3e3 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -226,6 +226,7 @@ Servers tcpFastOpen=BOOL, -- Whether to enable TCP Fast Open ipBindAddrNoPort=BOOL, -- Whether to enable IP_BIND_ADDRESS_NO_PORT if available, default: true name=STRING, -- The name associated to this backend, for display purpose + checkClass=NUM, -- Use NUM as QCLASS in the health-check query, default: DNSClass.IN 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" setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false