From: JINMEI Tatuya Date: Sat, 10 Mar 2012 04:05:14 +0000 (-0800) Subject: [1608] handle additional names at or below a DNAME delegation point. X-Git-Tag: trac2351_base~226^2~116^2~127^2~3^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=004375eb0955a2eb1fbfa5d5988cdc5b10ae441f;p=thirdparty%2Fkea.git [1608] handle additional names at or below a DNAME delegation point. --- diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc index 801e30b85c..6255be4d3f 100644 --- a/src/lib/datasrc/memory_datasrc.cc +++ b/src/lib/datasrc/memory_datasrc.cc @@ -1273,7 +1273,11 @@ checkZoneCut(const DomainNode& node, pair* arg) { if (arg->first) { return (false); } - if (node.getData()->find(RRType::NS()) != node.getData()->end()) { + // Once we encounter a delegation point due to a DNAME, anything under it + // should be hidden. + if (node.getData()->find(RRType::DNAME()) != node.getData()->end()) { + return (true); + } else if (node.getData()->find(RRType::NS()) != node.getData()->end()) { arg->first = true; arg->second = true; return (false); diff --git a/src/lib/datasrc/tests/testdata/contexttest.zone b/src/lib/datasrc/tests/testdata/contexttest.zone index b442da9a6c..0504af4fdb 100644 --- a/src/lib/datasrc/tests/testdata/contexttest.zone +++ b/src/lib/datasrc/tests/testdata/contexttest.zone @@ -1,7 +1,7 @@ ;; test zone file used for ZoneFinderContext tests. ;; RRSIGs are (obviouslly) faked ones for testing. -example.org. 3600 IN SOA ns1.example.org. bugs.x.w.example.org. 29 3600 300 3600000 3600 +example.org. 3600 IN SOA ns1.example.org. bugs.x.w.example.org. 41 3600 300 3600000 3600 example.org. 3600 IN NS ns1.example.org. example.org. 3600 IN NS ns2.example.org. example.org. 3600 IN MX 1 mx1.example.org. @@ -39,8 +39,21 @@ ns.b.example.org. 3600 IN A 192.0.2.9 ;; additional section. mxatcut.example.org. 3600 IN MX 1 b.example.org. +;; delegation, one of its NS names is under a DNAME delegation point; +;; another is at that point; and yet another is under DNAME below a +;; zone cut. +c.example.org. 3600 IN NS ns.dname.example.org. +c.example.org. 3600 IN NS dname.example.org. +c.example.org. 3600 IN NS ns.deepdname.example.org. +ns.dname.example.org. 3600 IN A 192.0.2.11 +dname.example.org. 3600 IN A 192.0.2.12 +ns.deepdname.example.org. 3600 IN AAAA 2001:db8::9 + ;; CNAME alias.example.org. 3600 IN CNAME cname.example.org. ;; DNAME dname.example.org. 3600 IN DNAME dname.example.com. + +;; DNAME under a NS (strange one) +deepdname.c.example.org. 3600 IN DNAME deepdname.example.com. diff --git a/src/lib/datasrc/tests/zone_finder_context_unittest.cc b/src/lib/datasrc/tests/zone_finder_context_unittest.cc index 81751cbce9..ce277dd8a2 100644 --- a/src/lib/datasrc/tests/zone_finder_context_unittest.cc +++ b/src/lib/datasrc/tests/zone_finder_context_unittest.cc @@ -234,6 +234,20 @@ TEST_P(ZoneFinderContextTest, getAdditionalDelegationAtZoneCut) { result_sets_.begin(), result_sets_.end()); } +TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithDname) { + // Delegation: One of the NS names under a DNAME delegation; another + // is at the delegation point; yet another is under DNAME below a zone cut. + // The first should be hidden. + ZoneFinderContextPtr ctx = finder_->find(Name("www.c.example.org"), + RRType::TXT()); + EXPECT_EQ(ZoneFinder::DELEGATION, ctx->code); + + ctx->getAdditional(REQUESTED_BOTH, result_sets_); + rrsetsCheck("dname.example.org. 3600 IN A 192.0.2.12\n" + "ns.deepdname.example.org. 3600 IN AAAA 2001:db8::9\n", + result_sets_.begin(), result_sets_.end()); +} + TEST_P(ZoneFinderContextTest, getAdditionalMX) { // Similar to the previous cases, but for MX addresses. The test zone // contains MX name under a zone cut. Its address shouldn't be returned.