Browse Source

[2282] cover the case of coexistence of DNAME and additional.

added one more test for that.
JINMEI Tatuya 12 years ago
parent
commit
e016cdf94c

+ 8 - 3
src/lib/datasrc/memory/zone_finder.cc

@@ -673,12 +673,17 @@ InMemoryZoneFinder::Context::findAdditional(
         return;
         return;
     }
     }
 
 
-    // Ignore data at a zone cut unless glue is allowed.
-    // TODO: DNAME case consideration (with test)
+    // Ignore data at a zone cut (due to subdomain delegation) unless glue is
+    // allowed.  Checking the node callback flag is a cheap way to detect
+    // zone cuts, but it includes DNAME delegation, in which case we should
+    // keep finding the additional records regardless of the 'GLUE_OK' flag.
+    // The last two conditions limit the case to delegation NS, i.e, the node
+    // has an NS and it's not the zone origin.
     const ZoneNode* node = node_result.node;
     const ZoneNode* node = node_result.node;
     if ((options & ZoneFinder::FIND_GLUE_OK) == 0 &&
     if ((options & ZoneFinder::FIND_GLUE_OK) == 0 &&
         node->getFlag(ZoneNode::FLAG_CALLBACK) &&
         node->getFlag(ZoneNode::FLAG_CALLBACK) &&
-        node != zone_data_->getOriginNode()) {
+        node != zone_data_->getOriginNode() &&
+        RdataSet::find(node->getData(), RRType::NS()) != NULL) {
         return;
         return;
     }
     }
 
 

+ 4 - 1
src/lib/datasrc/tests/testdata/contexttest.zone

@@ -1,7 +1,7 @@
 ;; test zone file used for ZoneFinderContext tests.
 ;; test zone file used for ZoneFinderContext tests.
 ;; RRSIGs are (obviouslly) faked ones for testing.
 ;; RRSIGs are (obviouslly) faked ones for testing.
 
 
-example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 67 3600 300 3600000 3600
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 71 3600 300 3600000 3600
 example.org.			      3600 IN NS	ns1.example.org.
 example.org.			      3600 IN NS	ns1.example.org.
 example.org.			      3600 IN NS	ns2.example.org.
 example.org.			      3600 IN NS	ns2.example.org.
 example.org.			      3600 IN MX	1 mx1.example.org.
 example.org.			      3600 IN MX	1 mx1.example.org.
@@ -71,6 +71,9 @@ a.*.emptywild.example.org.    3600 IN AAAA	2001:db8::2
 ;; expansion
 ;; expansion
 *.wildmx.example.org. 3600 IN MX 1 mx1.example.org.
 *.wildmx.example.org. 3600 IN MX 1 mx1.example.org.
 
 
+;; the owner name of additional for an answer RRset (MX) has DNAME
+dnamemx.example.org. 3600 IN MX 1 dname.example.org.
+
 ;; CNAME
 ;; CNAME
 alias.example.org. 3600 IN CNAME cname.example.org.
 alias.example.org. 3600 IN CNAME cname.example.org.
 
 

+ 12 - 0
src/lib/datasrc/tests/zone_finder_context_unittest.cc

@@ -235,6 +235,18 @@ TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithDname) {
                 result_sets_.begin(), result_sets_.end());
                 result_sets_.begin(), result_sets_.end());
 }
 }
 
 
+TEST_P(ZoneFinderContextTest, getAdditionalOnDname) {
+    // The additional name has a DNAME as well as the additional record.
+    // The existence of DNAME shouldn't hide the additional record.
+    ZoneFinderContextPtr ctx = finder_->find(Name("dnamemx.example.org"),
+                                             RRType::MX());
+    EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code);
+
+    ctx->getAdditional(REQUESTED_BOTH, result_sets_);
+    rrsetsCheck("dname.example.org. 3600 IN A 192.0.2.12\n",
+                result_sets_.begin(), result_sets_.end());
+}
+
 TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithEmptyName) {
 TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithEmptyName) {
     // One of NS names is at an empty non terminal node.  It shouldn't cause
     // One of NS names is at an empty non terminal node.  It shouldn't cause
     // any disruption.
     // any disruption.