BIND 10 trac2218_2, updated. 730fd2f2de14300227720977b581c421088dfec7 [2218] Make tree lookups slightly faster in findNSEC3()
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Sep 26 14:22:50 UTC 2012
The branch, trac2218_2 has been updated
via 730fd2f2de14300227720977b581c421088dfec7 (commit)
via 55f7ce059f925a531c9f0fe9adad18c1a941dec6 (commit)
from 42dc5ad3e7eed5f53d2d38b6683b7a9b427c1a1d (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 730fd2f2de14300227720977b581c421088dfec7
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Sep 26 19:52:16 2012 +0530
[2218] Make tree lookups slightly faster in findNSEC3()
commit 55f7ce059f925a531c9f0fe9adad18c1a941dec6
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Sep 26 19:51:34 2012 +0530
[2218] Add a copy constructor for DomainTreeNodeChain
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory/domaintree.h | 11 ++++-
.../datasrc/memory/tests/domaintree_unittest.cc | 9 +++++
src/lib/datasrc/memory/zone_finder.cc | 42 +++++++++++++++-----
3 files changed, 51 insertions(+), 11 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index acc5e2b..b15eb38 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -697,8 +697,17 @@ public:
isc::dns::NameComparisonResult::EQUAL)
{}
+ DomainTreeNodeChain(const DomainTreeNodeChain<T>& other) :
+ level_count_(other.level_count_),
+ last_compared_(other.last_compared_),
+ last_comparison_(other.last_comparison_)
+ {
+ for (size_t i = 0; i < level_count_; i++) {
+ nodes_[i] = other.nodes_[i];
+ }
+ }
+
private:
- DomainTreeNodeChain(const DomainTreeNodeChain<T>&);
DomainTreeNodeChain<T>& operator=(const DomainTreeNodeChain<T>&);
//@}
diff --git a/src/lib/datasrc/memory/tests/domaintree_unittest.cc b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
index 0a29d7f..029bc5d 100644
--- a/src/lib/datasrc/memory/tests/domaintree_unittest.cc
+++ b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
@@ -596,6 +596,10 @@ TEST_F(DomainTreeTest, chainLevel) {
// by default there should be no level in the chain.
EXPECT_EQ(0, chain.getLevelCount());
+ // Copy should be consistent
+ TestDomainTreeNodeChain chain2(chain);
+ EXPECT_EQ(chain.getLevelCount(), chain2.getLevelCount());
+
// insert one node to the tree and find it. there should be exactly
// one level in the chain.
TreeHolder tree_holder(mem_sgmt_, TestDomainTree::create(mem_sgmt_, true));
@@ -607,6 +611,11 @@ TEST_F(DomainTreeTest, chainLevel) {
tree.find(node_name, &cdtnode, chain));
EXPECT_EQ(1, chain.getLevelCount());
+ // Copy should be consistent
+ TestDomainTreeNodeChain chain3(chain);
+ EXPECT_EQ(chain.getLevelCount(), chain3.getLevelCount());
+ EXPECT_EQ(chain.getAbsoluteName(), chain3.getAbsoluteName());
+
// Check the name of the found node (should have '.' as both non-absolute
// and absolute name
EXPECT_EQ(".", cdtnode->getLabels().toText());
diff --git a/src/lib/datasrc/memory/zone_finder.cc b/src/lib/datasrc/memory/zone_finder.cc
index f796fd4..17e9612 100644
--- a/src/lib/datasrc/memory/zone_finder.cc
+++ b/src/lib/datasrc/memory/zone_finder.cc
@@ -617,10 +617,14 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_FINDNSEC3).arg(name).
arg(recursive ? "recursive" : "non-recursive");
+ Name origin(getOrigin());
+ const LabelSequence origin_ls(origin);
+ const LabelSequence name_ls(name);
+
if (!zone_data_.isNSEC3Signed()) {
isc_throw(DataSourceError,
"findNSEC3 attempt for non NSEC3 signed zone: " <<
- getOrigin() << "/" << getClass());
+ origin_ls << "/" << getClass());
}
const NSEC3Data* nsec3_data = zone_data_.getNSEC3Data();
@@ -632,23 +636,36 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
if (tree.getNodeCount() == 0) {
isc_throw(DataSourceError,
"findNSEC3 attempt but zone has no NSEC3 RRs: " <<
- getOrigin() << "/" << getClass());
+ origin_ls << "/" << getClass());
}
- const NameComparisonResult cmp_result = name.compare(getOrigin());
+ const NameComparisonResult cmp_result = name_ls.compare(origin_ls);
if (cmp_result.getRelation() != NameComparisonResult::EQUAL &&
cmp_result.getRelation() != NameComparisonResult::SUBDOMAIN) {
isc_throw(OutOfZone, "findNSEC3 attempt for out-of-zone name: "
- << name << ", zone: " << getOrigin() << "/"
+ << name_ls << ", zone: " << origin_ls << "/"
<< getClass());
}
// Convenient shortcuts
- const unsigned int olabels = getOrigin().getLabelCount();
+ const unsigned int olabels = origin.getLabelCount();
const unsigned int qlabels = name.getLabelCount();
// placeholder of the next closer proof
const ZoneNode* covering_node(NULL);
- ZoneChain chain;
+
+ // Now we'll first look up the origin node and initialize orig_chain
+ // with it.
+ ZoneChain orig_chain;
+ ZoneNode* node(NULL);
+ ZoneTree::Result result =
+ tree.find<void*>(origin_ls, &node, orig_chain, NULL, NULL);
+ if (result != ZoneTree::EXACTMATCH) {
+ // If the origin node doesn't exist, simply fail.
+ isc_throw(DataSourceError,
+ "findNSEC3 attempt but zone has no NSEC3 RRs: " <<
+ origin_ls << "/" << getClass());
+ }
+
const boost::scoped_ptr<NSEC3Hash> hash
(NSEC3Hash::create(nsec3_data->hashalg,
nsec3_data->iterations,
@@ -666,11 +683,16 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_FINDNSEC3_TRYHASH).
arg(name).arg(labels).arg(hlabel);
- ZoneNode* node(NULL);
- chain.clear();
- const ZoneTree::Result result =
- tree.find(Name(hlabel).concatenate(getOrigin()), &node, chain);
+ node = NULL;
+ ZoneChain chain(orig_chain);
+
+ // Now, make a label sequence relative to the origin.
+ const Name hlabel_name(hlabel);
+ LabelSequence hlabel_ls(hlabel_name);
+ hlabel_ls.stripRight(1);
+ // Find hlabel relative to the orig_chain.
+ result = tree.find<void*>(hlabel_ls, &node, chain, NULL, NULL);
if (result == ZoneTree::EXACTMATCH) {
// We found an exact match.
ConstRRsetPtr closest = createNSEC3RRset(node, getClass());
More information about the bind10-changes
mailing list