From: Otto Moerbeek Date: Tue, 31 Mar 2020 09:16:13 +0000 (+0200) Subject: test_referral_depth is actually hitting the limit in doCNAMECacheCheck() X-Git-Tag: dnsdist-1.5.0-rc1~17^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca34b34f89859d79b463010b92ff43e0c18f55c3;p=thirdparty%2Fpdns.git test_referral_depth is actually hitting the limit in doCNAMECacheCheck() and not the generic depth limit. Use one less of referal to fix that. Additionally, test and fix the non-limited case. --- diff --git a/pdns/recursordist/test-syncres_cc2.cc b/pdns/recursordist/test-syncres_cc2.cc index 5728011378..3e8d15917f 100644 --- a/pdns/recursordist/test-syncres_cc2.cc +++ b/pdns/recursordist/test-syncres_cc2.cc @@ -35,18 +35,19 @@ BOOST_AUTO_TEST_CASE(test_referral_depth) } else if (domain == DNSName("ns3.powerdns.org.")) { addRecordToLW(res, domain, QType::NS, "ns4.powerdns.org.", DNSResourceRecord::AUTHORITY, 172800); - } - else if (domain == DNSName("ns4.powerdns.org.")) { - addRecordToLW(res, domain, QType::NS, "ns5.powerdns.org.", DNSResourceRecord::AUTHORITY, 172800); - addRecordToLW(res, domain, QType::A, "192.0.2.1", DNSResourceRecord::AUTHORITY, 172800); + addRecordToLW(res, "ns4.powerdns.org.", QType::A, "192.0.2.1", DNSResourceRecord::ADDITIONAL, 3600); } return 1; } else if (ip == ComboAddress("192.0.2.1:53")) { - setLWResult(res, 0, true, false, false); - addRecordToLW(res, domain, QType::A, "192.0.2.2"); + if (domain == DNSName("www.powerdns.com.")) { + addRecordToLW(res, domain, QType::A, "192.0.2.2"); + } + else { + addRecordToLW(res, domain, QType::A, "192.0.2.1"); + } return 1; } @@ -62,6 +63,22 @@ BOOST_AUTO_TEST_CASE(test_referral_depth) BOOST_CHECK(false); } catch (const ImmediateServFailException& e) { + BOOST_CHECK(e.reason.find("max-recursion-depth") != string::npos); + } + + // Then check if the setup with high limit is OK. + SyncRes::s_maxdepth = 50; + try { + vector ret; + int rcode = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); + BOOST_CHECK_EQUAL(rcode, RCode::NoError); + BOOST_CHECK_EQUAL(ret.size(), 1U); + BOOST_CHECK_EQUAL(ret[0].d_name, target); + BOOST_REQUIRE(ret[0].d_type == QType::A); + BOOST_CHECK(getRR(ret[0])->getCA() == ComboAddress("192.0.2.2")); + } + catch (const ImmediateServFailException& e) { + BOOST_CHECK(false); } }