Browse Source

[1806] in-mem DS: add NSEC record for ENT

Jelte Jansen 13 years ago
parent
commit
28d8650609

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

@@ -437,8 +437,13 @@ 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);
-            return (ResultType(ZoneFinder::NXRRSET, node,
-                               ConstRBNodeRRsetPtr()));
+            if (nsec_signed_ && (options & ZoneFinder::FIND_DNSSEC) != 0) {
+                return (ResultType(ZoneFinder::NXRRSET, node,
+                                   getClosestNSEC(node_path, options)));
+            } else {
+                return (ResultType(ZoneFinder::NXRRSET, node,
+                                   ConstRBNodeRRsetPtr()));
+            }
         }
         if (node->getFlag(domain_flag::WILD)) { // maybe a wildcard
             if (node_path.getLastComparisonResult().getRelation() ==

+ 25 - 0
src/lib/datasrc/tests/memory_datasrc_unittest.cc

@@ -443,6 +443,10 @@ public:
              &rr_nsec3_},
             {"example.org. 300 IN NSEC cname.example.org. A NS NSEC",
              &rr_nsec_},
+            {"www.ent.example.org. 300 IN A 192.0.2.1",
+             &rr_ent_},
+            {"example.org. 300 IN NSEC www.ent.example.org. A NS NSEC",
+             &rr_ent_nsec_},
             {NULL, NULL}
         };
 
@@ -508,6 +512,8 @@ public:
     RRsetPtr rr_not_wild_another_;
     RRsetPtr rr_nsec3_;
     RRsetPtr rr_nsec_;
+    RRsetPtr rr_ent_;
+    RRsetPtr rr_ent_nsec_;
 
     // A faked NSEC3 hash calculator for convenience.
     // Tests that need to use the faked hashed values should call
@@ -1039,6 +1045,25 @@ TEST_F(InMemoryZoneFinderTest, findNSECSigned) {
     findCheck(ZoneFinder::RESULT_NSEC_SIGNED);
 }
 
+TEST_F(InMemoryZoneFinderTest,findNSECEmptyNonterminal) {
+    zone_finder_.add(rr_ent_);
+    const Name ent_name = Name("ent.example.org");
+
+    // Should result in NXRRSET
+    findTest(ent_name, RRType::A(), ZoneFinder::NXRRSET, true,
+             ConstRRsetPtr());
+
+    zone_finder_.add(rr_ent_nsec_);
+    // Should result in NXRRSET, and RESULT_NSEC_SIGNED
+    findTest(ent_name, RRType::A(), ZoneFinder::NXRRSET, true,
+             ConstRRsetPtr(), ZoneFinder::RESULT_NSEC_SIGNED);
+
+    // And check for the NSEC if DNSSEC_OK
+    findTest(ent_name, RRType::A(), ZoneFinder::NXRRSET, true,
+             rr_ent_nsec_, ZoneFinder::RESULT_NSEC_SIGNED,
+             NULL, ZoneFinder::FIND_DNSSEC);
+}
+
 void
 InMemoryZoneFinderTest::emptyNodeCheck(
     ZoneFinder::FindResultFlags expected_flags)