Browse Source

[1808] Update InMemoryZoneFinder::find() in order to support NSEC
for NXRRSET at DNSSEC qureys. Two unittests were added to assure
these.

Xie Jiagui 13 years ago
parent
commit
86f48610df

+ 13 - 0
src/lib/datasrc/memory_datasrc.cc

@@ -1309,6 +1309,19 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
                                           rename));
             }
         }
+        // No exact match or CNAME. This is NXRRSET case.If with DNSSEC query, 
+        // get the NSEC RRSets,returns with result code NXRRSET.
+        if (zone_data_->nsec_signed_) {
+            found = node->getData()->find(RRType::NSEC());
+            if (found != node->getData()->end()) {
+                LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NXRRSET).arg(type).
+                          arg(name);
+                return (createFindResult(NXRRSET,
+                                          prepareRRset(name, found->second,
+                                                       rename, options),
+                                                       rename));
+            }
+        }
         // No exact match or CNAME.  Return NXRRSET.
         LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NXRRSET).arg(type).
             arg(name);

+ 0 - 2
src/lib/datasrc/memory_datasrc.h

@@ -68,8 +68,6 @@ public:
     /// \brief Looks up an RRset in the zone.
     ///
     /// See documentation in \c Zone.
-    ///
-    /// It returns NULL pointer in case of NXDOMAIN and NXRRSET.
     virtual ZoneFinderContextPtr find(const isc::dns::Name& name,
                                       const isc::dns::RRType& type,
                                       const FindOptions options =

+ 10 - 4
src/lib/datasrc/tests/memory_datasrc_unittest.cc

@@ -1009,6 +1009,16 @@ InMemoryZoneFinderTest::findCheck(ZoneFinder::FindResultFlags expected_flags) {
                  OutOfZone);
 }
 
+// Test if NSEC works
+TEST_F(InMemoryZoneFinderTest,NSEC4NXRRSET) {
+    findTest(origin_, RRType::TXT(), ZoneFinder::NXRRSET, true,
+            ConstRRsetPtr());
+    
+    EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_finder_.add(rr_nsec_)));
+    findTest(origin_, RRType::A(), ZoneFinder::NXRRSET, true,
+            rr_nsec_,ZoneFinder::RESULT_NSEC_SIGNED,NULL,ZoneFinder::FIND_DNSSEC);
+}
+
 TEST_F(InMemoryZoneFinderTest, find) {
     findCheck();
 }
@@ -1017,10 +1027,6 @@ TEST_F(InMemoryZoneFinderTest, findNSEC3Signed) {
     findCheck(ZoneFinder::RESULT_NSEC3_SIGNED);
 }
 
-TEST_F(InMemoryZoneFinderTest, findNSECSigned) {
-    findCheck(ZoneFinder::RESULT_NSEC_SIGNED);
-}
-
 void
 InMemoryZoneFinderTest::emptyNodeCheck(
     ZoneFinder::FindResultFlags expected_flags)