From: JINMEI Tatuya Date: Fri, 11 May 2012 08:47:55 +0000 (-0700) Subject: [1808-2] updated findCheck so it can be used for normal the NXRRSET case. X-Git-Tag: trac2351_base~226^2~156^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff68e9ec714e6cffa7350f4379a813c4fab91b4e;p=thirdparty%2Fkea.git [1808-2] updated findCheck so it can be used for normal the NXRRSET case. also fixed a small problem in the main code that it didn't consider the FIND_DNSSEC flag. --- diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc index 26ffdbdad8..386c325436 100644 --- a/src/lib/datasrc/memory_datasrc.cc +++ b/src/lib/datasrc/memory_datasrc.cc @@ -1369,7 +1369,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { } // No exact match or CNAME. This is NXRRSET case. If with DNSSEC query, // get the NSEC RRset, returns with result code NXRRSET. - if (zone_data_->nsec_signed_) { + if (zone_data_->nsec_signed_ && (options & ZoneFinder::FIND_DNSSEC) != 0) { found = node->getData()->find(RRType::NSEC()); if (found != node->getData()->end()) { LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NXRRSET).arg(type). diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc index 24a59b767e..6533c885c9 100644 --- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc +++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc @@ -451,6 +451,8 @@ public: &rr_nsec3_}, {"example.org. 300 IN NSEC cname.example.org. A NS NSEC", &rr_nsec_}, + {"ns.example.org. 300 IN NSEC *.nswild.example.org. A AAAA NSEC", + &rr_ns_nsec_}, {NULL, NULL} }; @@ -516,6 +518,7 @@ public: RRsetPtr rr_not_wild_another_; RRsetPtr rr_nsec3_; RRsetPtr rr_nsec_; + RRsetPtr rr_ns_nsec_; // A faked NSEC3 hash calculator for convenience. // Tests that need to use the faked hashed values should call @@ -1006,12 +1009,6 @@ InMemoryZoneFinderTest::findCheck(ZoneFinder::FindResultFlags expected_flags, findTest(rr_ns_a_->getName(), RRType::A(), ZoneFinder::SUCCESS, true, rr_ns_a_); - // These domain exist but don't have the provided RRType - findTest(origin_, RRType::AAAA(), ZoneFinder::NXRRSET, true, - ConstRRsetPtr(), expected_flags); - findTest(rr_ns_a_->getName(), RRType::NS(), ZoneFinder::NXRRSET, true, - ConstRRsetPtr(), expected_flags); - // These domains don't exist. (and one is out of the zone). In an // NSEC-signed zone with DNSSEC records requested, it should return the // covering NSEC for the query name (the actual NSEC in the test data may @@ -1036,6 +1033,20 @@ InMemoryZoneFinderTest::findCheck(ZoneFinder::FindResultFlags expected_flags, NULL, find_options); EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()), OutOfZone); + + // These domain exist but don't have the provided RRType. For the latter + // one we now add its NSEC (which was delayed so that it wouldn't break + // other cases above). + findTest(origin_, RRType::AAAA(), ZoneFinder::NXRRSET, true, + expected_nsec, expected_flags, NULL, find_options); + if ((expected_flags & ZoneFinder::RESULT_NSEC_SIGNED) != 0) { + EXPECT_EQ(SUCCESS, zone_finder_.add(rr_ns_nsec_)); + if ((find_options & ZoneFinder::FIND_DNSSEC) != 0) { + expected_nsec = rr_ns_nsec_; + } + } + findTest(rr_ns_a_->getName(), RRType::NS(), ZoneFinder::NXRRSET, true, + expected_nsec, expected_flags, NULL, find_options); } // Test if NSEC works