BIND 10 trac2435, updated. c16bfe0dc892c2bd34e88daa12120202bcf9e3eb [2435] Handle find() with RRClass that may not be found

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jan 9 05:44:03 UTC 2013


The branch, trac2435 has been updated
       via  c16bfe0dc892c2bd34e88daa12120202bcf9e3eb (commit)
      from  6c0febf6e8ca20b9d585d5b5577ee2989464fad0 (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 c16bfe0dc892c2bd34e88daa12120202bcf9e3eb
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jan 9 11:04:40 2013 +0530

    [2435] Handle find() with RRClass that may not be found

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

Summary of changes:
 src/lib/datasrc/rrset_collection.cc        |   11 ++++++++---
 src/lib/datasrc/rrset_collection.h         |    7 +++++--
 src/lib/datasrc/tests/database_unittest.cc |    8 +++++++-
 3 files changed, 20 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/rrset_collection.cc b/src/lib/datasrc/rrset_collection.cc
index 51fa97c..e4cfd88 100644
--- a/src/lib/datasrc/rrset_collection.cc
+++ b/src/lib/datasrc/rrset_collection.cc
@@ -23,11 +23,16 @@ namespace datasrc {
 
 ConstRRsetPtr
 RRsetCollection::find(const isc::dns::Name& name,
-                      const isc::dns::RRClass&,
+                      const isc::dns::RRClass& rrclass,
                       const isc::dns::RRType& rrtype) const
 {
-    // TODO: RRClass needs to be checked here to see if it is as
-    // expected.
+    if (rrclass != rrclass_) {
+        // We could throw an exception here, but RRsetCollection is
+        // expected to support an arbitrary collection of RRsets, and it
+        // can be queried just as arbitrarily. So we just return nothing
+        // here.
+        return (ConstRRsetPtr());
+    }
 
     ZoneFinder& finder = updater_->getFinder();
     ZoneFinderContextPtr result =
diff --git a/src/lib/datasrc/rrset_collection.h b/src/lib/datasrc/rrset_collection.h
index 6ad494a..afe1199 100644
--- a/src/lib/datasrc/rrset_collection.h
+++ b/src/lib/datasrc/rrset_collection.h
@@ -33,8 +33,10 @@ public:
     /// destroyed by the client.
     ///
     /// \param updater The ZoneUpdater to wrap around.
-    RRsetCollection(ZoneUpdaterPtr updater) :
-        updater_(updater)
+    /// \param rrclass The RRClass of the records in the zone.
+    RRsetCollection(ZoneUpdaterPtr updater, const isc::dns::RRClass& rrclass) :
+        updater_(updater),
+        rrclass_(rrclass)
     {}
 
     /// \brief Destructor
@@ -56,6 +58,7 @@ public:
 
 private:
     ZoneUpdaterPtr updater_;
+    isc::dns::RRClass rrclass_;
 
 protected:
     // TODO: RRsetCollectionBase::Iter is not implemented and the
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 3df02cf..39729f8 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -4162,7 +4162,8 @@ class RRsetCollectionTest : public DatabaseClientTest<ACCESSOR_TYPE> {
 public:
     RRsetCollectionTest() :
         DatabaseClientTest<ACCESSOR_TYPE>(),
-        collection(this->client_->getUpdater(this->zname_, false))
+        collection(this->client_->getUpdater(this->zname_, false),
+                   this->qclass_)
     {}
 
     RRsetCollection collection;
@@ -4192,6 +4193,11 @@ TYPED_TEST(RRsetCollectionTest, find) {
     rrset = this->collection.find(Name("www.example.org"), this->qclass_,
                                   RRType::AAAA());
     EXPECT_TRUE(rrset);
+
+    // www.example.org with AAAA does not exist in RRClass::CH()
+    rrset = this->collection.find(Name("www.example.org"), RRClass::CH(),
+                                  RRType::AAAA());
+    EXPECT_FALSE(rrset);
 }
 
 TYPED_TEST(RRsetCollectionTest, iteratorTest) {



More information about the bind10-changes mailing list