Parcourir la source

[master] Merge branch 'trac1571'

JINMEI Tatuya il y a 13 ans
Parent
commit
d22e90b5ef

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

@@ -557,7 +557,10 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
 
         // If the node callback is enabled, this may be a zone cut.  If it
         // has a NS RR, we should return a delegation, but not in the apex.
-        if (node->getFlag(DomainNode::FLAG_CALLBACK) && node != origin_data_) {
+        // There is one exception: the case for DS query, which should always
+        // be considered in-zone lookup.
+        if (node->getFlag(DomainNode::FLAG_CALLBACK) && node != origin_data_ &&
+            type != RRType::DS()) {
             found = node->getData()->find(RRType::NS());
             if (found != node->getData()->end()) {
                 LOG_DEBUG(logger, DBG_TRACE_DATA,

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

@@ -291,6 +291,8 @@ public:
             {"example.org. 300 IN DNAME example.com.", &rr_dname_apex_},
             {"child.example.org. 300 IN NS ns.child.example.org.",
              &rr_child_ns_},
+            {"child.example.org. 300 IN DS 12345 5 1 DEADBEEF",
+             &rr_child_ds_},
             {"ns.child.example.org. 300 IN A 192.0.2.153",
              &rr_child_glue_},
             {"grand.child.example.org. 300 IN NS ns.grand.child.example.org.",
@@ -353,6 +355,7 @@ public:
     RRsetPtr rr_dname_ns_; // for mixed DNAME + NS case
     RRsetPtr rr_dname_apex_; // for mixed DNAME + NS case in the apex
     RRsetPtr rr_child_ns_; // NS of a child domain (for delegation)
+    RRsetPtr rr_child_ds_; // DS of a child domain (for delegation, auth data)
     RRsetPtr rr_child_glue_; // glue RR of the child domain
     RRsetPtr rr_grandchild_ns_; // NS below a zone cut (unusual)
     RRsetPtr rr_grandchild_glue_; // glue RR below a deeper zone cut
@@ -656,6 +659,26 @@ TEST_F(InMemoryZoneFinderTest, delegationNS) {
              ZoneFinder::DELEGATION, true, rr_child_ns_);
 }
 
+TEST_F(InMemoryZoneFinderTest, delegationWithDS) {
+    // Similar setup to the previous one, but with DS RR at the delegation
+    // point.
+    EXPECT_EQ(SUCCESS, zone_finder_.add(rr_ns_));
+    EXPECT_EQ(SUCCESS, zone_finder_.add(rr_child_ns_));
+    EXPECT_EQ(SUCCESS, zone_finder_.add(rr_child_ds_));
+
+    // Normal types of query should result in delegation, but DS query
+    // should be considered in-zone.
+    findTest(Name("child.example.org"), RRType::A(), ZoneFinder::DELEGATION,
+             true, rr_child_ns_);
+    findTest(Name("child.example.org"), RRType::DS(), ZoneFinder::SUCCESS,
+             true, rr_child_ds_);
+
+    // There's nothing special for DS query at the zone apex.  It would
+    // normally result in NXRRSET.
+    findTest(Name("example.org"), RRType::DS(), ZoneFinder::NXRRSET,
+             true, ConstRRsetPtr());
+}
+
 TEST_F(InMemoryZoneFinderTest, findAny) {
     EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_finder_.add(rr_a_)));
     EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_finder_.add(rr_ns_)));