BIND 10 trac1535, updated. 65b293e59954c95c245f44691f5c82fdcd6579c9 [1535] renamed OutOfZoneFind to OutOfZone
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Mar 30 15:46:26 UTC 2012
The branch, trac1535 has been updated
via 65b293e59954c95c245f44691f5c82fdcd6579c9 (commit)
via 532aa507e57aaa8c406cd4cc537058de6fcb5a88 (commit)
from ce81fab6415ae7f50ed29c201162e912d41eb50d (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 65b293e59954c95c245f44691f5c82fdcd6579c9
Author: Jelte Jansen <jelte at isc.org>
Date: Fri Mar 30 17:45:45 2012 +0200
[1535] renamed OutOfZoneFind to OutOfZone
And remove the memory-datasrc specific one
commit 532aa507e57aaa8c406cd4cc537058de6fcb5a88
Author: Jelte Jansen <jelte at isc.org>
Date: Fri Mar 30 16:54:01 2012 +0200
[1535] address review comments
- removed superfluous toText() calls in out-of-zone exception creation
- moved in-memory out-of-zone check to be part of findNode instead of separate check in find()
- added out-of-zone check to addAdditional lookup (and don't lookup unless in zone)
- removed FIND_DEFAULT parameters in unit tests (they are default values)
- change notify_out sqlite test data to have out-of-zone-but-known NS target
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.cc | 3 +-
src/lib/datasrc/memory_datasrc.cc | 29 +++++++++-------
src/lib/datasrc/memory_datasrc.h | 10 -----
src/lib/datasrc/tests/database_unittest.cc | 36 +++++++++-----------
src/lib/datasrc/tests/memory_datasrc_unittest.cc | 20 ++++-------
src/lib/datasrc/zone.h | 12 ++++---
src/lib/python/isc/datasrc/datasrc.cc | 9 ++---
src/lib/python/isc/datasrc/finder_python.cc | 5 +--
src/lib/python/isc/datasrc/tests/datasrc_test.py | 4 +-
.../python/isc/notify/tests/testdata/test.sqlite3 | Bin 13312 -> 13312 bytes
10 files changed, 55 insertions(+), 73 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index 85958f3..a6637b9 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -865,8 +865,7 @@ DatabaseClient::Finder::findInternal(const Name& name, const RRType& type,
name.compare(getOrigin()).getRelation();
if (reln != NameComparisonResult::SUBDOMAIN &&
reln != NameComparisonResult::EQUAL) {
- isc_throw(OutOfZoneFind, name.toText() << " not in " <<
- getOrigin().toText());
+ isc_throw(OutOfZone, name.toText() << " not in " << getOrigin());
}
// First, go through all superdomains from the origin down, searching for
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 17c22df..09d694d 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -362,8 +362,7 @@ ZoneData::findNode(const Name& name, ZoneFinder::FindOptions options) const {
if (result == DomainTree::EXACTMATCH) {
return (ResultType(ZoneFinder::SUCCESS, node, state.rrset_,
zonecut_flag));
- }
- if (result == DomainTree::PARTIALMATCH) {
+ } else if (result == DomainTree::PARTIALMATCH) {
assert(node != NULL);
if (state.dname_node_ != NULL) { // DNAME
LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_DNAME_FOUND).
@@ -408,10 +407,15 @@ ZoneData::findNode(const Name& name, ZoneFinder::FindOptions options) const {
FindNodeResult::FIND_WILDCARD |
zonecut_flag));
}
+ // Nothing really matched.
+ LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NOT_FOUND).arg(name);
+ return (ResultType(ZoneFinder::NXDOMAIN, node, state.rrset_));
+ } else {
+ // If the name is neither an exact or partial match, it is
+ // out of bailiwick, which is considered an error.
+ isc_throw(OutOfZone, name.toText() << " not in " <<
+ origin_data_->getName());
}
- // Nothing really matched. The name may even be out-of-bailiwick.
- LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NOT_FOUND).arg(name);
- return (ResultType(ZoneFinder::NXDOMAIN, node, state.rrset_));
}
} // unnamed namespace
@@ -1202,14 +1206,6 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_FIND).arg(name).
arg(type);
- const NameComparisonResult::NameRelation reln =
- name.compare(origin_).getRelation();
- if (reln != NameComparisonResult::SUBDOMAIN &&
- reln != NameComparisonResult::EQUAL) {
- isc_throw(OutOfZoneFind, name.toText() <<
- " not in " << origin_.toText());
- }
-
// Get the node. All other cases than an exact match are handled
// in findNode(). We simply construct a result structure and return.
const ZoneData::FindNodeResult node_result =
@@ -1459,6 +1455,13 @@ addAdditional(RBNodeRRset* rrset, ZoneData* zone_data,
const Name& name = getAdditionalName(rrset->getType(),
rdata_iterator->getCurrent());
+ // if the name is not in or below this zone, skip it
+ const NameComparisonResult::NameRelation reln =
+ name.compare(zone_data->origin_data_->getName()).getRelation();
+ if (reln != NameComparisonResult::SUBDOMAIN &&
+ reln != NameComparisonResult::EQUAL) {
+ continue;
+ }
const ZoneData::FindMutableNodeResult result =
zone_data->findNode<ZoneData::FindMutableNodeResult>(
name, ZoneFinder::FIND_GLUE_OK);
diff --git a/src/lib/datasrc/memory_datasrc.h b/src/lib/datasrc/memory_datasrc.h
index fbeb2c3..fdb3786 100644
--- a/src/lib/datasrc/memory_datasrc.h
+++ b/src/lib/datasrc/memory_datasrc.h
@@ -125,16 +125,6 @@ public:
/// exists).
result::Result add(const isc::dns::ConstRRsetPtr& rrset);
- /// \brief RRSet out of zone exception.
- ///
- /// This is thrown if addition of an RRset that doesn't belong under the
- /// zone's origin is requested.
- struct OutOfZone : public InvalidParameter {
- OutOfZone(const char* file, size_t line, const char* what) :
- InvalidParameter(file, line, what)
- { }
- };
-
/// \brief RRset is NULL exception.
///
/// This is thrown if the provided RRset parameter is NULL.
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index c30aa5c..af64f58 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -1872,36 +1872,33 @@ TYPED_TEST(DatabaseClientTest, find) {
}
TYPED_TEST(DatabaseClientTest, findOutOfZone) {
- // If the query name is out-of-zone it should result in NXDOMAIN
+ // If the query name is out-of-zone it should result in an exception
boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
vector<ConstRRsetPtr> target;
// Superdomain
- EXPECT_THROW(finder->find(Name("org"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
- EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZone);
+ EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZone);
// sharing a common ancestor
- EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_),
+ OutOfZone);
EXPECT_THROW(finder->findAll(Name("noexample.org"), target),
- OutOfZoneFind);
+ OutOfZone);
// totally unrelated domain, smaller number of labels
- EXPECT_THROW(finder->find(Name("com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
- EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZone);
+ EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZone);
// totally unrelated domain, same number of labels
- EXPECT_THROW(finder->find(Name("example.com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
- EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("example.com"), this->qtype_), OutOfZone);
+ EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZone);
// totally unrelated domain, larger number of labels
- EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_),
+ OutOfZone);
EXPECT_THROW(finder->findAll(Name("more.example.com"), target),
- OutOfZoneFind);
+ OutOfZone);
}
TYPED_TEST(DatabaseClientTest, findDelegation) {
@@ -2829,14 +2826,13 @@ TYPED_TEST(DatabaseClientTest, addDeviantRR) {
this->expected_rdatas_.clear();
this->expected_rdatas_.push_back("192.0.2.100");
{
- // Note: find() rejects out-of-zone query name with NXDOMAIN
+ // Note: find() rejects out-of-zone query name with an exception
// regardless of whether adding the RR succeeded, so this check
// actually doesn't confirm it.
SCOPED_TRACE("add out-of-zone RR");
EXPECT_THROW(this->updater_->getFinder().find(Name("example.com"),
- this->qtype_,
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ this->qtype_),
+ OutOfZone);
}
}
diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
index dc1f099..925f01f 100644
--- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc
+++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
@@ -672,7 +672,7 @@ TEST_F(InMemoryZoneFinderTest, constructor) {
*/
TEST_F(InMemoryZoneFinderTest, add) {
// This one does not belong to this zone
- EXPECT_THROW(zone_finder_.add(rr_out_), InMemoryZoneFinder::OutOfZone);
+ EXPECT_THROW(zone_finder_.add(rr_out_), OutOfZone);
// Test null pointer
EXPECT_THROW(zone_finder_.add(ConstRRsetPtr()),
InMemoryZoneFinder::NullRRset);
@@ -901,7 +901,7 @@ TEST_F(InMemoryZoneFinderTest, findAny) {
// out zone name
EXPECT_THROW(findAllTest(Name("example.com"), ZoneFinder::NXDOMAIN,
vector<ConstRRsetPtr>()),
- OutOfZoneFind);
+ OutOfZone);
expected_sets.clear();
expected_sets.push_back(rr_child_glue_);
@@ -998,8 +998,8 @@ InMemoryZoneFinderTest::findCheck(ZoneFinder::FindResultFlags expected_flags) {
// These domains don't exist (and one is out of the zone)
findTest(Name("nothere.example.org"), RRType::A(), ZoneFinder::NXDOMAIN,
true, ConstRRsetPtr(), expected_flags);
- EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A(),
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()),
+ OutOfZone);
}
TEST_F(InMemoryZoneFinderTest, find) {
@@ -1054,9 +1054,7 @@ InMemoryZoneFinderTest::emptyNodeCheck(
// Note: basically we don't expect such a query to be performed (the common
// operation is to identify the best matching zone first then perform
// search it), but we shouldn't be confused even in the unexpected case.
- EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A(),
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()), OutOfZone);
}
TEST_F(InMemoryZoneFinderTest, emptyNode) {
@@ -1514,16 +1512,12 @@ TEST_F(InMemoryZoneFinderTest, swap) {
EXPECT_EQ(RRClass::CH(), finder1.getClass());
EXPECT_EQ(RRClass::IN(), finder2.getClass());
// make sure the zone data is swapped, too
- EXPECT_THROW(finder1.find(origin_, RRType::NS(),
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ EXPECT_THROW(finder1.find(origin_, RRType::NS()), OutOfZone);
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder1);
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder2);
- EXPECT_THROW(finder2.find(other_origin, RRType::TXT(),
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ EXPECT_THROW(finder2.find(other_origin, RRType::TXT()), OutOfZone);
}
TEST_F(InMemoryZoneFinderTest, getFileName) {
diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h
index b1c4825..2b8a2a0 100644
--- a/src/lib/datasrc/zone.h
+++ b/src/lib/datasrc/zone.h
@@ -27,11 +27,13 @@
namespace isc {
namespace datasrc {
-/// \brief Thrown when ZoneFinder::find() is called for out-of-zone data
+/// \brief Out of zone exception
///
-class OutOfZoneFind : public Exception {
+/// This is thrown when a method is called for a name or RRset which
+/// is not in or below the zone.
+class OutOfZone : public Exception {
public:
- OutOfZoneFind(const char* file, size_t line, const char* what) :
+ OutOfZone(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
@@ -474,8 +476,8 @@ public:
///
/// \exception std::bad_alloc Memory allocation such as for constructing
/// the resulting RRset fails
- /// \throw OutOfZoneFind The Name \c name is outside of the origin
- /// of the zone of this ZoneFinder.
+ /// \throw OutOfZone The Name \c name is outside of the origin of the
+ /// zone of this ZoneFinder.
/// \exception DataSourceError Derived class specific exception, e.g.
/// when encountering a bad zone configuration or database connection
/// failure. Although these are considered rare, exceptional events,
diff --git a/src/lib/python/isc/datasrc/datasrc.cc b/src/lib/python/isc/datasrc/datasrc.cc
index 75a3bd0..af6c21e 100644
--- a/src/lib/python/isc/datasrc/datasrc.cc
+++ b/src/lib/python/isc/datasrc/datasrc.cc
@@ -233,7 +233,7 @@ initModulePart_ZoneJournalReader(PyObject* mod) {
}
PyObject* po_DataSourceError;
-PyObject* po_OutOfZoneFind;
+PyObject* po_OutOfZone;
PyObject* po_NotImplemented;
PyModuleDef iscDataSrc = {
@@ -288,10 +288,9 @@ PyInit_datasrc(void) {
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
NULL);
PyObjectContainer(po_DataSourceError).installToModule(mod, "Error");
- po_OutOfZoneFind = PyErr_NewException("isc.datasrc.OutOfZoneFind",
- NULL, NULL);
- PyObjectContainer(po_OutOfZoneFind).installToModule(mod,
- "OutOfZoneFind");
+ po_OutOfZone = PyErr_NewException("isc.datasrc.OutOfZone", NULL,
+ NULL);
+ PyObjectContainer(po_OutOfZone).installToModule(mod, "OutOfZone");
po_NotImplemented = PyErr_NewException("isc.datasrc.NotImplemented",
NULL, NULL);
PyObjectContainer(po_NotImplemented).installToModule(mod,
diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc
index 84967d9..ed05fdb 100644
--- a/src/lib/python/isc/datasrc/finder_python.cc
+++ b/src/lib/python/isc/datasrc/finder_python.cc
@@ -97,9 +97,8 @@ PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args) {
} else {
return (Py_BuildValue("IOI", r, Py_None, result_flags));
}
- } catch (const OutOfZoneFind& oozf) {
- PyErr_SetString(getDataSourceException("OutOfZoneFind"),
- oozf.what());
+ } catch (const OutOfZone& ooz) {
+ PyErr_SetString(getDataSourceException("OutOfZone"), ooz.what());
return (NULL);
} catch (const DataSourceError& dse) {
PyErr_SetString(getDataSourceException("Error"), dse.what());
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index f12339b..983b8c2 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -380,9 +380,9 @@ class DataSrcClient(unittest.TestCase):
self.assertEqual(None, rrset)
- self.assertRaises(isc.datasrc.OutOfZoneFind, finder.find,
+ self.assertRaises(isc.datasrc.OutOfZone, finder.find,
isc.dns.Name("www.some.other.domain"),
- isc.dns.RRType.A(), finder.FIND_DEFAULT)
+ isc.dns.RRType.A())
result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
isc.dns.RRType.TXT(),
diff --git a/src/lib/python/isc/notify/tests/testdata/test.sqlite3 b/src/lib/python/isc/notify/tests/testdata/test.sqlite3
index 366514b..1606064 100644
Binary files a/src/lib/python/isc/notify/tests/testdata/test.sqlite3 and b/src/lib/python/isc/notify/tests/testdata/test.sqlite3 differ
More information about the bind10-changes
mailing list