BIND 10 trac1608, updated. a8c1ced88d2e49827f5082555e335e209fd32ef8 [1608] added more note about AdditionalNodeInfo visibility.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Mar 12 21:50:49 UTC 2012


The branch, trac1608 has been updated
       via  a8c1ced88d2e49827f5082555e335e209fd32ef8 (commit)
       via  2cc4d39e5c74092c2fda2d9be3682b432243099b (commit)
       via  ae873233be8b119b0495b98d843fada53949ab58 (commit)
       via  62a3bb1472df7765c40525dfe9c07ab949fa4a72 (commit)
      from  bf8e9e937a158253853013a6f316573d3b53e3ee (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a8c1ced88d2e49827f5082555e335e209fd32ef8
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Mar 12 14:50:25 2012 -0700

    [1608] added more note about AdditionalNodeInfo visibility.

commit 2cc4d39e5c74092c2fda2d9be3682b432243099b
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Mar 12 14:45:42 2012 -0700

    [1608] noted in doc that getAdditional() only returns in-zone data (+ glue).

commit ae873233be8b119b0495b98d843fada53949ab58
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Mar 12 14:35:31 2012 -0700

    [1608] moved app-level RBNode flags to a single "private" namespace.
    
    It will make it less susceptible to assignment collisions.

commit 62a3bb1472df7765c40525dfe9c07ab949fa4a72
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Mar 12 14:10:15 2012 -0700

    [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.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory_datasrc.cc                  |   39 +++++++++++++++-----
 src/lib/datasrc/rbnode_rrset.h                     |   21 ++++++++++-
 src/lib/datasrc/tests/testdata/contexttest.zone    |    6 +++-
 .../datasrc/tests/zone_finder_context_unittest.cc  |   13 +++++++
 src/lib/datasrc/zone.h                             |    7 ++++
 5 files changed, 74 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 03b6eaf..477baa5 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -75,13 +75,25 @@ typedef boost::shared_ptr<Domain> DomainPtr;
 typedef RBTree<Domain> DomainTree;
 typedef RBNode<Domain> DomainNode;
 
+// In the following dedicated namespace we define a few application-specific
+// RBNode flags.  We use a separate namespace so we can consolidate the
+// definition in a single place, which would hopefully reduce the risk of
+// collisions.
+// (Note: it's within an unnamed namespace, so effectively private.)
+namespace domain_flag {
+// This flag indicates the node is at a "wildcard level" (in short, it means
+// one of the node's immediate child is a wildcard).  See addWildcards()
+// for more details.
+const DomainNode::Flags WILD = DomainNode::FLAG_USER1;
+
 // This flag is used for additional record shortcut.  If a node has this
 // flag, it's under a zone cut for a delegation to a child zone.
 // Note: for a statically built zone this information is stable, but if we
 // change the implementation to be dynamically modifiable, it may not be
 // realistic to keep this flag update for all affected nodes, and we may
 // have to reconsider the mechanism.
-const DomainNode::Flags DOMAINFLAG_GLUE = DomainNode::FLAG_USER2;
+const DomainNode::Flags GLUE = DomainNode::FLAG_USER2;
+};
 
 // Separate storage for NSEC3 RRs (and their RRSIGs).  It's an STL map
 // from string to the NSEC3 RRset.  The map key is the first label
@@ -286,6 +298,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 {
@@ -369,7 +390,7 @@ private:
             if (additional.node_->isEmpty()) {
                 continue;
             }
-            if (!glue_ok && additional.node_->getFlag(DOMAINFLAG_GLUE)) {
+            if (!glue_ok && additional.node_->getFlag(domain_flag::GLUE)) {
                 continue;
             }
             BOOST_FOREACH(const RRType& rrtype, requested_types) {
@@ -395,8 +416,6 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
         zone_data_(new ZoneData(origin_))
     {}
 
-    static const DomainNode::Flags DOMAINFLAG_WILD = DomainNode::FLAG_USER1;
-
     // Information about the zone
     RRClass zone_class_;
     Name origin_;
@@ -435,7 +454,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
                                                          &node));
                 assert(result == DomainTree::SUCCESS ||
                        result == DomainTree::ALREADYEXISTS);
-                node->setFlag(DOMAINFLAG_WILD);
+                node->setFlag(domain_flag::WILD);
 
                 // Ensure a separate level exists for the wildcard name.
                 // Note: for 'name' itself we do this later anyway, but the
@@ -934,7 +953,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);
         }
@@ -1031,7 +1052,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
                  * not match according to 4.3.3 of RFC 1034 (the query name
                  * is known to exist).
                  */
-                if (node->getFlag(DOMAINFLAG_WILD)) {
+                if (node->getFlag(domain_flag::WILD)) {
                     /* Should we cancel this match?
                      *
                      * If we compare with some node and get a common ancestor,
@@ -1068,7 +1089,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
                     DomainTree::Result result =
                         zone_data_->domains_.find(wildcard, &node);
                     /*
-                     * Otherwise, why would the DOMAINFLAG_WILD be there if
+                     * Otherwise, why would the domain_flag::WILD be there if
                      * there was no wildcard under it?
                      */
                     assert(result == DomainTree::EXACTMATCH);
@@ -1350,7 +1371,7 @@ addAdditional(RBNodeRRset* rrset, ZoneData* zone_data) {
                  node->getData()->find(RRType::NS()) !=
                  node->getData()->end())) {
                 // The node is under or at a zone cut; mark it as a glue.
-                node->setFlag(DOMAINFLAG_GLUE);
+                node->setFlag(domain_flag::GLUE);
             }
             // Note that node may be empty.  We should keep it in the list
             // in case we dynamically update the tree and it becomes non empty
diff --git a/src/lib/datasrc/rbnode_rrset.h b/src/lib/datasrc/rbnode_rrset.h
index c630761..f687919 100644
--- a/src/lib/datasrc/rbnode_rrset.h
+++ b/src/lib/datasrc/rbnode_rrset.h
@@ -37,8 +37,12 @@ namespace internal {
 struct RBNodeRRsetImpl;
 
 // Forward declaration of an opaque data type defined and used within the
-// implementation.  This is public only because it needs to be used outside
-// of the \c RBNodeRRset class, but conceptually this is a private type.
+// implementation.  This is public only because it needs to be used within
+// the in-memory data source implementation, but conceptually this is a
+// private type for the in-memory data source implementation.
+// Note that the definition of the structure is still hidden within the
+// implementation, so, basically, a normal application should never be able
+// to use it directly even if it peeks into the "internal" namespace.
 struct AdditionalNodeInfo;
 
 /// \brief Special RRset for optimizing memory datasource requirement
@@ -181,6 +185,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.
diff --git a/src/lib/datasrc/tests/testdata/contexttest.zone b/src/lib/datasrc/tests/testdata/contexttest.zone
index c9d2859..425866a 100644
--- a/src/lib/datasrc/tests/testdata/contexttest.zone
+++ b/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.
 
diff --git a/src/lib/datasrc/tests/zone_finder_context_unittest.cc b/src/lib/datasrc/tests/zone_finder_context_unittest.cc
index 5ce96ab..9134307 100644
--- a/src/lib/datasrc/tests/zone_finder_context_unittest.cc
+++ b/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.
diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h
index 361a03a..c705279 100644
--- a/src/lib/datasrc/zone.h
+++ b/src/lib/datasrc/zone.h
@@ -252,6 +252,13 @@ public:
         /// call resulted in SUCCESS or DELEGATION.  Otherwise this method
         /// does nothing.
         ///
+        /// \note The additional RRsets returned via method are limited to
+        /// ones contained in the zone which the corresponding find/findAll
+        /// call searched (possibly including glues under a zone cut where
+        /// they are applicable).  If the caller needs to get out-of-zone
+        /// additional RRsets, it needs to explicitly finds them by
+        /// identifying the corresponding zone and calls \c find() for it.
+        ///
         /// \param requested_types A vector of RR types for desired additional
         ///  RRsets.
         /// \param result A vector to which any found additional RRsets are



More information about the bind10-changes mailing list