BIND 10 trac534, updated. a0f8c9ee2bf78af6d95293a4d802e0205a4429c3 [trac534] Test a rare case of DNAME under NS

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Feb 1 10:04:35 UTC 2011


The branch, trac534 has been updated
       via  a0f8c9ee2bf78af6d95293a4d802e0205a4429c3 (commit)
       via  3372c331452e94681b82b708d11dd0f93c945153 (commit)
       via  311eb1ae0574c5f981937ae41614ff0fad034c9a (commit)
      from  950ffa229928d24ba8ebd74c5945e4cf0facf539 (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 a0f8c9ee2bf78af6d95293a4d802e0205a4429c3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Feb 1 10:59:45 2011 +0100

    [trac534] Test a rare case of DNAME under NS
    
    And fix a bug why it didn't work (a check or nested zonecuts prevented
    detection of DNAME).

commit 3372c331452e94681b82b708d11dd0f93c945153
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Feb 1 10:11:14 2011 +0100

    [trac534] Create the origin at zone creation
    
    No need to check every time this added domain isn't origin, we create
    one at creation of zone and keep it.

commit 311eb1ae0574c5f981937ae41614ff0fad034c9a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Feb 1 09:59:37 2011 +0100

    [trac534] Comment explaining variables

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

Summary of changes:
 src/lib/datasrc/memory_datasrc.cc                |   40 ++++++++++++++++-----
 src/lib/datasrc/tests/memory_datasrc_unittest.cc |   22 +++++++++++-
 2 files changed, 50 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 5d0fdde..96ce7a3 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -36,7 +36,12 @@ struct MemoryZone::MemoryZoneImpl {
     // Constructor
     MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
         zone_class_(zone_class), origin_(origin), origin_data_(NULL)
-    {}
+    {
+        // We create the node for origin (it needs to exist anyway in future)
+        domains_.insert(origin, &origin_data_);
+        DomainPtr origin_domain(new Domain);
+        origin_data_->setData(origin_domain);
+    }
 
     // Some type aliases
     /*
@@ -158,9 +163,6 @@ struct MemoryZone::MemoryZoneImpl {
         if (node->isEmpty()) {
             domain.reset(new Domain);
             node->setData(domain);
-            if (origin_data_ == NULL && name == origin_) {
-                origin_data_ = node;
-            }
         } else { // Get existing one
             domain = node->getData();
         }
@@ -229,12 +231,6 @@ struct MemoryZone::MemoryZoneImpl {
     // A callback called from possible zone cut nodes and nodes with DNAME.
     // This will be passed from the \c find() method to \c RBTree::find().
     static bool cutCallback(const DomainNode& node, FindState* state) {
-        // We perform callback check only for the highest zone cut in the
-        // rare case of nested zone cuts.
-        if (state->zonecut_node_ != NULL) {
-            return (false);
-        }
-
         // We need to look for DNAME first, there's allowed case where
         // DNAME and NS coexist in the apex. DNAME is the one to notice,
         // the NS is authoritative, not delegation (corner case explicitly
@@ -257,6 +253,12 @@ struct MemoryZone::MemoryZoneImpl {
         const Domain::const_iterator foundNS(node.getData()->find(
             RRType::NS()));
         if (foundNS != node.getData()->end()) {
+            // We perform callback check only for the highest zone cut in the
+            // rare case of nested zone cuts.
+            if (state->zonecut_node_ != NULL) {
+                return (false);
+            }
+
             // BIND 9 checks if this node is not the origin.  That's probably
             // because it can support multiple versions for dynamic updates
             // and IXFR, and it's possible that the callback is called at
@@ -290,6 +292,24 @@ struct MemoryZone::MemoryZoneImpl {
         FindState state(options);
         switch (domains_.find(name, &node, cutCallback, &state)) {
             case DomainTree::PARTIALMATCH:
+                /*
+                 * In fact, we could use a single variable instead of
+                 * dname_node_ and zonecut_node_. But then we would need
+                 * to distinquish these two cases by something else and
+                 * it seemed little more confusing to me when I wrote it.
+                 *
+                 * Usually at most one of them will be something else than
+                 * NULL (it might happen both are NULL, in which case we
+                 * consider it NOT FOUND). There's one corner case when
+                 * both might be something else than NULL and it is in case
+                 * there's a DNAME under a zone cut and we search in
+                 * glue OK mode ‒ in that case we don't stop on the domain
+                 * with NS and ignore it for the answer, but it gets set
+                 * anyway. Then we find the DNAME and we need to act by it,
+                 * therefore we first check for DNAME and then for NS. In
+                 * all other cases it doesn't matter, as at last one of them
+                 * is NULL.
+                 */
                 if (state.dname_node_ != NULL) {
                     // We were traversing a DNAME node (and wanted to go
                     // lower below it), so return the DNAME
diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
index 3307690..be71e7f 100644
--- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc
+++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
@@ -153,6 +153,7 @@ public:
         child_glue_name_("ns.child.example.org"),
         grandchild_ns_name_("grand.child.example.org"),
         grandchild_glue_name_("ns.grand.child.example.org"),
+        child_dname_name_("dname.child.example.org"),
         zone_(class_, origin_),
         rr_out_(new RRset(Name("example.com"), class_, RRType::A(),
             RRTTL(300))),
@@ -175,13 +176,16 @@ public:
         rr_grandchild_ns_(new RRset(grandchild_ns_name_, class_, RRType::NS(),
                                     RRTTL(300))),
         rr_grandchild_glue_(new RRset(grandchild_glue_name_, class_,
-                                      RRType::AAAA(), RRTTL(300)))
+                                      RRType::AAAA(), RRTTL(300))),
+        rr_child_dname_(new RRset(child_dname_name_, class_, RRType::DNAME(),
+            RRTTL(300)))
     {
     }
     // Some data to test with
     const RRClass class_;
     const Name origin_, ns_name_, cname_name_, dname_name_, child_ns_name_,
-        child_glue_name_, grandchild_ns_name_, grandchild_glue_name_;
+        child_glue_name_, grandchild_ns_name_, grandchild_glue_name_,
+        child_dname_name_;
     // The zone to torture by tests
     MemoryZone zone_;
 
@@ -212,6 +216,7 @@ public:
     ConstRRsetPtr rr_child_glue_; // glue RR of the child domain
     ConstRRsetPtr rr_grandchild_ns_; // NS below a zone cut (unusual)
     ConstRRsetPtr rr_grandchild_glue_; // glue RR below a deeper zone cut
+    ConstRRsetPtr rr_child_dname_; // A DNAME under NS
 
     /**
      * \brief Test one find query to the zone.
@@ -392,6 +397,19 @@ TEST_F(MemoryZoneTest, findAtDNAME) {
     findTest(dname_name_, RRType::TXT(), Zone::NXRRSET, true);
 }
 
+// Try searching something that is both under NS and DNAME, without and with
+// GLUE_OK mode (it should stop at the NS and DNAME respectively).
+TEST_F(MemoryZoneTest, DNAMEUnderNS) {
+    zone_.add(rr_child_ns_);
+    zone_.add(rr_child_dname_);
+
+    Name lowName("below.dname.child.example.org.");
+
+    findTest(lowName, RRType::A(), Zone::DELEGATION, true, rr_child_ns_);
+    findTest(lowName, RRType::A(), Zone::DNAME, true, rr_child_dname_, NULL,
+        NULL, Zone::FIND_GLUE_OK);
+}
+
 // Test adding child zones and zone cut handling
 TEST_F(MemoryZoneTest, delegationNS) {
     // add in-zone data




More information about the bind10-changes mailing list