From: JINMEI Tatuya Date: Wed, 26 Sep 2012 00:29:05 +0000 (-0700) Subject: [2282] cover the case of coexistence of DNAME and additional. X-Git-Tag: trac2351_base~37^2~1^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e016cdf94cb3377f4e186e4f175ef89eb382089f;p=thirdparty%2Fkea.git [2282] cover the case of coexistence of DNAME and additional. added one more test for that. --- diff --git a/src/lib/datasrc/memory/zone_finder.cc b/src/lib/datasrc/memory/zone_finder.cc index 83937c75a2..9e52097254 100644 --- a/src/lib/datasrc/memory/zone_finder.cc +++ b/src/lib/datasrc/memory/zone_finder.cc @@ -673,12 +673,17 @@ InMemoryZoneFinder::Context::findAdditional( return; } - // Ignore data at a zone cut unless glue is allowed. - // TODO: DNAME case consideration (with test) + // Ignore data at a zone cut (due to subdomain delegation) unless glue is + // allowed. Checking the node callback flag is a cheap way to detect + // zone cuts, but it includes DNAME delegation, in which case we should + // keep finding the additional records regardless of the 'GLUE_OK' flag. + // The last two conditions limit the case to delegation NS, i.e, the node + // has an NS and it's not the zone origin. const ZoneNode* node = node_result.node; if ((options & ZoneFinder::FIND_GLUE_OK) == 0 && node->getFlag(ZoneNode::FLAG_CALLBACK) && - node != zone_data_->getOriginNode()) { + node != zone_data_->getOriginNode() && + RdataSet::find(node->getData(), RRType::NS()) != NULL) { return; } diff --git a/src/lib/datasrc/tests/testdata/contexttest.zone b/src/lib/datasrc/tests/testdata/contexttest.zone index e499e0d6ce..a39649d376 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. 67 3600 300 3600000 3600 +example.org. 3600 IN SOA ns1.example.org. bugs.x.w.example.org. 71 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. @@ -71,6 +71,9 @@ a.*.emptywild.example.org. 3600 IN AAAA 2001:db8::2 ;; expansion *.wildmx.example.org. 3600 IN MX 1 mx1.example.org. +;; the owner name of additional for an answer RRset (MX) has DNAME +dnamemx.example.org. 3600 IN MX 1 dname.example.org. + ;; CNAME alias.example.org. 3600 IN CNAME cname.example.org. diff --git a/src/lib/datasrc/tests/zone_finder_context_unittest.cc b/src/lib/datasrc/tests/zone_finder_context_unittest.cc index 8b0bc9af39..14429aea51 100644 --- a/src/lib/datasrc/tests/zone_finder_context_unittest.cc +++ b/src/lib/datasrc/tests/zone_finder_context_unittest.cc @@ -235,6 +235,18 @@ TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithDname) { result_sets_.begin(), result_sets_.end()); } +TEST_P(ZoneFinderContextTest, getAdditionalOnDname) { + // The additional name has a DNAME as well as the additional record. + // The existence of DNAME shouldn't hide the additional record. + ZoneFinderContextPtr ctx = finder_->find(Name("dnamemx.example.org"), + RRType::MX()); + EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code); + + ctx->getAdditional(REQUESTED_BOTH, result_sets_); + rrsetsCheck("dname.example.org. 3600 IN A 192.0.2.12\n", + result_sets_.begin(), result_sets_.end()); +} + TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithEmptyName) { // One of NS names is at an empty non terminal node. It shouldn't cause // any disruption.