Browse Source

[1806] removed double nsec_signed_ && FIND_DNSSEC check

also added an extra sanity check
Jelte Jansen 13 years ago
parent
commit
3b3fdd3a93

+ 4 - 7
src/lib/datasrc/memory_datasrc.cc

@@ -437,13 +437,10 @@ ZoneData::findNode(const Name& name, RBTreeNodeChain<Domain>& node_path,
         if (node_path.getLastComparisonResult().getRelation() ==
             NameComparisonResult::SUPERDOMAIN) { // empty node, so NXRRSET
             LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_SUPER_STOP).arg(name);
-            if (nsec_signed_ && (options & ZoneFinder::FIND_DNSSEC) != 0) {
-                return (ResultType(ZoneFinder::NXRRSET, node,
-                                   getClosestNSEC(node_path, options)));
-            } else {
-                return (ResultType(ZoneFinder::NXRRSET, node,
-                                   ConstRBNodeRRsetPtr()));
-            }
+            // getClosestNSEC returns empty node for non-NSEC zones or if
+            // option FIND_DNSSEC is not set, so no need to check here
+            return (ResultType(ZoneFinder::NXRRSET, node,
+                               getClosestNSEC(node_path, options)));
         }
         if (node->getFlag(domain_flag::WILD)) { // maybe a wildcard
             if (node_path.getLastComparisonResult().getRelation() ==

+ 5 - 1
src/lib/datasrc/tests/memory_datasrc_unittest.cc

@@ -1049,9 +1049,13 @@ TEST_F(InMemoryZoneFinderTest,findNSECEmptyNonterminal) {
     zone_finder_.add(rr_ent_);
     const Name ent_name = Name("ent.example.org");
 
-    // Should result in NXRRSET
+    // Sanity check: Should result in NXRRSET
     findTest(ent_name, RRType::A(), ZoneFinder::NXRRSET, true,
              ConstRRsetPtr());
+    // Sanity check: No NSEC added yet
+    findTest(ent_name, RRType::A(), ZoneFinder::NXRRSET, true,
+             ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT,
+             NULL, ZoneFinder::FIND_DNSSEC);
 
     zone_finder_.add(rr_ent_nsec_);
     // Should result in NXRRSET, and RESULT_NSEC_SIGNED