Browse Source

[1608] make sure RBNodeRRset due to wildcard expansion have additional info.

also added a new unittest case to confirm this.  This change should also fix
failure in the NSEC3 lettuce test.
JINMEI Tatuya 13 years ago
parent
commit
62a3bb1472

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

@@ -286,6 +286,15 @@ RBNodeRRset::getAdditionalNodes() const {
     return (impl_->additionals_.get());
 }
 
+void
+RBNodeRRset::copyAdditionalNodes(RBNodeRRset& dst) const {
+    if (impl_->additionals_) {
+        dst.impl_->additionals_.reset(
+            new vector<AdditionalNodeInfo>(impl_->additionals_->begin(),
+                                           impl_->additionals_->end()));
+    }
+}
+
 } // end of internal
 
 namespace {
@@ -934,7 +943,9 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
                     result_base->addRRsig(result_sig);
                 }
             }
-            return (RBNodeRRsetPtr(new RBNodeRRset(result_base)));
+            RBNodeRRsetPtr result(new RBNodeRRset(result_base));
+            rrset->copyAdditionalNodes(*result);
+            return (result);
         } else {
             return (rrset);
         }

+ 13 - 0
src/lib/datasrc/rbnode_rrset.h

@@ -181,6 +181,19 @@ public:
     /// NULL if no additional nodes are associated to this RRset.
     const std::vector<AdditionalNodeInfo>* getAdditionalNodes() const;
 
+    /// \brief Copy the list of additional RB nodes to another RRset.
+    ///
+    /// This method copies the internal list (an STL vector in the actual
+    /// implementation) of additional RB nodes for this RRset to another
+    /// \c RBNodeRRset object.  The copy destination is generally expected to
+    /// be newly created and have an empty list, but this method does not
+    /// check the condition.  If the destination already has a non empty list,
+    /// the existing entries will be lost.
+    ///
+    /// \param dst The \c RBNodeRRset object to which the additional
+    /// RB node list is to be copied.
+    void copyAdditionalNodes(RBNodeRRset& dst) const;
+
     /// \brief Return underlying RRset pointer
     ///
     /// ... mainly for testing.

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

@@ -1,7 +1,7 @@
 ;; test zone file used for ZoneFinderContext tests.
 ;; RRSIGs are (obviouslly) faked ones for testing.
 
-example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 55 3600 300 3600000 3600
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 56 3600 300 3600000 3600
 example.org.			      3600 IN NS	ns1.example.org.
 example.org.			      3600 IN NS	ns2.example.org.
 example.org.			      3600 IN MX	1 mx1.example.org.
@@ -61,6 +61,10 @@ bar.ns.empty.example.org.     3600 IN A		192.0.2.14
 e.example.org. 	      	      3600 IN NS	ns.wild.example.org.
 *.wild.example.org.	      3600 IN A		192.0.2.15
 
+;; additional for an answer RRset (MX) as a result of wildcard
+;; expansion
+*.wildmx.example.org. 3600 IN MX 1 mx1.example.org.
+
 ;; CNAME
 alias.example.org. 3600 IN CNAME cname.example.org.
 

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

@@ -276,6 +276,19 @@ TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithWild) {
                 result_sets_.begin(), result_sets_.end());
 }
 
+TEST_P(ZoneFinderContextTest, getAdditionalDelegationForWild) {
+    // additional for an answer RRset (MX) as a result of wildcard expansion.
+    // note the difference from the previous test.  in this case wildcard
+    // applies to the owner name of the answer, not the owner name of the
+    // additional.
+    ZoneFinderContextPtr ctx = finder_->find(Name("mx.wildmx.example.org"),
+                                             RRType::MX());
+    EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code);
+    ctx->getAdditional(REQUESTED_BOTH, result_sets_);
+    rrsetsCheck("mx1.example.org. 3600 IN A 192.0.2.10\n",
+                result_sets_.begin(), result_sets_.end());
+}
+
 TEST_P(ZoneFinderContextTest, getAdditionalMX) {
     // Similar to the previous cases, but for MX addresses.  The test zone
     // contains MX name under a zone cut.  Its address shouldn't be returned.