BIND 10 trac2435, updated. 5200f31617133fc3700b802a7299efbc3a980ec5 [2435] Check ZoneFinder find() result and return accordingly

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jan 10 12:28:13 UTC 2013


The branch, trac2435 has been updated
       via  5200f31617133fc3700b802a7299efbc3a980ec5 (commit)
       via  ecfc245797cd10313557991c778e686fa1f19b37 (commit)
      from  79cfa55b6202c07cbba0b0db6532ca2dff9e2a9c (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 5200f31617133fc3700b802a7299efbc3a980ec5
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jan 10 17:27:30 2013 +0530

    [2435] Check ZoneFinder find() result and return accordingly

commit ecfc245797cd10313557991c778e686fa1f19b37
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jan 10 15:50:36 2013 +0530

    [2435] Remove redundant class definition

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

Summary of changes:
 src/lib/datasrc/database.cc                |   12 ++++++-
 src/lib/datasrc/tests/database_unittest.cc |   52 +++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 13 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index 8257c21..5c7bab5 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -1418,7 +1418,17 @@ public:
             ZoneFinderContextPtr result =
                 finder.find(name, rrtype,
                             ZoneFinder::NO_WILDCARD | ZoneFinder::FIND_GLUE_OK);
-            return (result->rrset);
+            // We return the result rrset only if the result code is
+            // SUCCESS. We return empty if CNAME, DNAME, DELEGATION,
+            // etc. are returned by the ZoneFinder.
+            //
+            // Note that in the case that the queried type itself is
+            // CNAME, then the finder will return SUCCESS.
+            if (result->code == ZoneFinder::SUCCESS) {
+                return (result->rrset);
+            } else {
+                return (ConstRRsetPtr());
+            }
         } catch (const OutOfZone&) {
             // As RRsetCollection is an arbitrary set of RRsets, in case
             // the searched name is out of zone, we return nothing
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 297fd4c..134fda3 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -2184,6 +2184,12 @@ TYPED_TEST(DatabaseClientTest, findDelegation) {
                this->rrttl_, ZoneFinder::DNAME, this->expected_rdatas_,
                this->expected_sig_rdatas_, ZoneFinder::RESULT_DEFAULT,
                isc::dns::Name("dname.example.org."));
+    // below.dname.example.org. has an A record
+    doFindTest(*finder, isc::dns::Name("below.dname.example.org."),
+               isc::dns::RRType::A(), isc::dns::RRType::DNAME(),
+               this->rrttl_, ZoneFinder::DNAME, this->expected_rdatas_,
+               this->expected_sig_rdatas_, ZoneFinder::RESULT_DEFAULT,
+               isc::dns::Name("dname.example.org."));
     doFindTest(*finder, isc::dns::Name("really.deep.below.dname.example.org."),
                isc::dns::RRType::AAAA(), isc::dns::RRType::DNAME(),
                this->rrttl_, ZoneFinder::DNAME, this->expected_rdatas_,
@@ -4199,10 +4205,42 @@ TYPED_TEST(RRsetCollectionTest, find) {
                                    RRType::AAAA());
     EXPECT_FALSE(rrset);
 
-    // Out of zone find()s must not throw.
+    // Out-of-zone find()s must not throw.
     rrset = this->collection->find(Name("www.example.com"), this->qclass_,
                                    RRType::A());
     EXPECT_FALSE(rrset);
+
+    // "cname.example.org." with type CNAME should return the CNAME RRset
+    rrset = this->collection->find(Name("cname.example.org"), this->qclass_,
+                                   RRType::CNAME());
+    ASSERT_TRUE(rrset);
+    EXPECT_EQ(RRType::CNAME(), rrset->getType());
+    EXPECT_EQ(Name("cname.example.org"), rrset->getName());
+
+    // "cname.example.org." with type A should return nothing
+    rrset = this->collection->find(Name("cname.example.org"), this->qclass_,
+                                   RRType::A());
+    EXPECT_FALSE(rrset);
+
+    // "dname.example.org." with type DNAME should return the DNAME RRset
+    rrset = this->collection->find(Name("dname.example.org"), this->qclass_,
+                                   RRType::DNAME());
+    ASSERT_TRUE(rrset);
+    EXPECT_EQ(RRType::DNAME(), rrset->getType());
+    EXPECT_EQ(Name("dname.example.org"), rrset->getName());
+
+    // "below.dname.example.org." with type AAAA should return nothing
+    rrset = this->collection->find(Name("below.dname.example.org"),
+                                   this->qclass_, RRType::AAAA());
+    EXPECT_FALSE(rrset);
+
+    // TODO: "below.dname.example.org." with type A does not return the
+    // record (see top of file). It needs to be checked if this is what
+    // we want.
+    rrset = this->collection->find(Name("below.dname.example.org"),
+                                   this->qclass_, RRType::A());
+    // Is this correct behavior?
+    EXPECT_FALSE(rrset);
 }
 
 TYPED_TEST(RRsetCollectionTest, iteratorTest) {
@@ -4211,17 +4249,7 @@ TYPED_TEST(RRsetCollectionTest, iteratorTest) {
     EXPECT_THROW(this->collection->end(), isc::NotImplemented);
 }
 
-class MockRRsetCollectionTest : public DatabaseClientTest<MockAccessor> {
-public:
-    MockRRsetCollectionTest() :
-        DatabaseClientTest<MockAccessor>(),
-        updater(this->client_->getUpdater(this->zname_, false)),
-        collection(updater->getRRsetCollection())
-    {}
-
-    ZoneUpdaterPtr updater;
-    RRsetCollectionPtr collection;
-};
+typedef RRsetCollectionTest<MockAccessor> MockRRsetCollectionTest;
 
 TEST_F(MockRRsetCollectionTest, findError) {
     // A test using the MockAccessor for checking that FindError is



More information about the bind10-changes mailing list