From: JINMEI Tatuya Date: Thu, 20 Sep 2012 23:30:13 +0000 (-0700) Subject: [2219] regression fix: support glue_ok option at the zone cut in the main find X-Git-Tag: trac2351_base~37^2~1^2~13^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b35c2aba35663034479b293e238deeff068dced;p=thirdparty%2Fkea.git [2219] regression fix: support glue_ok option at the zone cut in the main find in the old implementation we did it for the specialized finder context, but we are currently using the generic context, so we need to handle the case in the main method. (and, technically, this case should be handled in the main method even if we had a specialized context as it's an API contract.) --- diff --git a/src/lib/datasrc/memory/tests/zone_finder_unittest.cc b/src/lib/datasrc/memory/tests/zone_finder_unittest.cc index 5141b6b8e5..df19d0a99d 100644 --- a/src/lib/datasrc/memory/tests/zone_finder_unittest.cc +++ b/src/lib/datasrc/memory/tests/zone_finder_unittest.cc @@ -180,6 +180,8 @@ public: {"example.org. 300 IN NS ns.example.org.", &rr_ns_}, {"example.org. 300 IN A 192.0.2.1", &rr_a_}, {"ns.example.org. 300 IN A 192.0.2.2", &rr_ns_a_}, + // This one will place rr_ns_a_ at a zone cut, making it a glue: + {"ns.example.org. 300 IN NS 192.0.2.2", &rr_ns_ns_}, {"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_}, {"cname.example.org. 300 IN CNAME canonical.example.org", &rr_cname_}, @@ -370,6 +372,7 @@ public: rr_ns_aaaa_, // A of example.org rr_a_; + RRsetPtr rr_ns_ns_; // used to make rr_ns_a_ a glue. RRsetPtr rr_cname_; // CNAME in example.org (RDATA will be added) RRsetPtr rr_cname_a_; // for mixed CNAME + A case RRsetPtr rr_dname_; // DNAME in example.org (RDATA will be added) @@ -711,6 +714,9 @@ TEST_F(InMemoryZoneFinderTest, glue) { EXPECT_NO_THROW(addZoneData(rr_grandchild_ns_)); // glue under the deeper zone cut EXPECT_NO_THROW(addZoneData(rr_grandchild_glue_)); + // glue 'at the' zone cut + EXPECT_NO_THROW(addZoneData(rr_ns_a_)); + EXPECT_NO_THROW(addZoneData(rr_ns_ns_)); // by default glue is hidden due to the zone cut findTest(rr_child_glue_->getName(), RRType::A(), ZoneFinder::DELEGATION, @@ -743,6 +749,13 @@ TEST_F(InMemoryZoneFinderTest, glue) { findTest(Name("www.grand.child.example.org"), RRType::TXT(), ZoneFinder::DELEGATION, true, rr_child_ns_, ZoneFinder::RESULT_DEFAULT, NULL, ZoneFinder::FIND_GLUE_OK); + + // Glue at a zone cut + findTest(Name("ns.example.org"), RRType::A(), + ZoneFinder::DELEGATION, true, rr_ns_ns_); + findTest(Name("ns.example.org"), RRType::A(), ZoneFinder::SUCCESS, + true, rr_ns_a_, ZoneFinder::RESULT_DEFAULT, + NULL, ZoneFinder::FIND_GLUE_OK); } /** diff --git a/src/lib/datasrc/memory/zone_finder.cc b/src/lib/datasrc/memory/zone_finder.cc index 35b1d35575..6d3e70d2bd 100644 --- a/src/lib/datasrc/memory/zone_finder.cc +++ b/src/lib/datasrc/memory/zone_finder.cc @@ -582,10 +582,13 @@ InMemoryZoneFinder::find_internal(const isc::dns::Name& name, // If the node callback is enabled, this may be a zone cut. If it // has a NS RR, we should return a delegation, but not in the apex. - // There is one exception: the case for DS query, which should always - // be considered in-zone lookup. + // There are two exceptions: + // - the case for DS query, which should always be considered in-zone + // lookup. + // - when we are looking for glue records (FIND_GLUE_OK) if (node->getFlag(ZoneNode::FLAG_CALLBACK) && - node != zone_data_.getOriginNode() && type != RRType::DS()) { + (options & FIND_GLUE_OK) == 0 && + node != zone_data_.getOriginNode() && type != RRType::DS()) { found = RdataSet::find(node->getData(), RRType::NS()); if (found != NULL) { LOG_DEBUG(logger, DBG_TRACE_DATA,