Browse Source

[1808-2] Merge branch 'trac1808' into trac1808-2

JINMEI Tatuya 13 years ago
parent
commit
077179407a

+ 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 RRset, 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);

+ 1 - 5
src/lib/datasrc/memory_datasrc.h

@@ -65,11 +65,7 @@ public:
     /// \brief Returns the class of the zone.
     virtual isc::dns::RRClass getClass() const;
 
-    /// \brief Looks up an RRset in the zone.
-    ///
-    /// See documentation in \c Zone.
-    ///
-    /// It returns NULL pointer in case of NXDOMAIN and NXRRSET.
+    /// \brief Find an RRset in the datasource
     virtual ZoneFinderContextPtr find(const isc::dns::Name& name,
                                       const isc::dns::RRType& type,
                                       const FindOptions options =

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

@@ -1009,6 +1009,17 @@ 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 +1028,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)