BIND 10 trac2218_2, updated. 6a0721cb9647ea09a7ca40174dee6de870829cc5 [2218] some small fixes to the revised nsec3hash implementation.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Sep 26 16:49:20 UTC 2012


The branch, trac2218_2 has been updated
       via  6a0721cb9647ea09a7ca40174dee6de870829cc5 (commit)
       via  4735853efc9554536e607a3431631348ea2d0c49 (commit)
       via  f9a376ab22abb84377f24846f66b49c58469fe17 (commit)
       via  f569d3269831e8ad74e8f5c4d2e84d38e524c979 (commit)
      from  c7060ccf5e4ec41ee12e08e66f410fe14199c545 (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 6a0721cb9647ea09a7ca40174dee6de870829cc5
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Sep 26 09:47:58 2012 -0700

    [2218] some small fixes to the revised nsec3hash implementation.
    
    - now salt_data_ is not a vector, some of the empty check isn't necessary
    - on the other hand, we need to do it in creat()
    - we don't need to do null check before free
    - and some style fixes

commit 4735853efc9554536e607a3431631348ea2d0c49
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Sep 26 09:40:59 2012 -0700

    [2218] a small optimization: avoid using getOrigin(), which is expensive.
    
    creating labelsequence for the origin node should be normally faster.
    also do some constify.

commit f9a376ab22abb84377f24846f66b49c58469fe17
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Sep 26 09:23:55 2012 -0700

    [2218] (trivial) documentation for DomainTreeNodeChain copy ctor.

commit f569d3269831e8ad74e8f5c4d2e84d38e524c979
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Sep 26 09:21:04 2012 -0700

    [2218] style fix: combine two short lines

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

Summary of changes:
 src/lib/datasrc/memory/domaintree.h                |    3 +++
 .../datasrc/memory/tests/domaintree_unittest.cc    |    3 +--
 src/lib/datasrc/memory/zone_finder.cc              |    9 +++++----
 src/lib/dns/nsec3hash.cc                           |   19 +++++++++----------
 4 files changed, 18 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index b15eb38..b87a8cc 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -697,6 +697,9 @@ public:
                                          isc::dns::NameComparisonResult::EQUAL)
     {}
 
+    /// \brief Copy constructor.
+    ///
+    /// \exception None
     DomainTreeNodeChain(const DomainTreeNodeChain<T>& other) :
         level_count_(other.level_count_),
 	last_compared_(other.last_compared_),
diff --git a/src/lib/datasrc/memory/tests/domaintree_unittest.cc b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
index 029bc5d..cb16e02 100644
--- a/src/lib/datasrc/memory/tests/domaintree_unittest.cc
+++ b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
@@ -996,8 +996,7 @@ TEST_F(DomainTreeTest, largestNode) {
     TreeHolder empty_tree_holder
         (mem_sgmt_, TestDomainTree::create(mem_sgmt_));
     TestDomainTree& empty_tree(*empty_tree_holder.get());
-    EXPECT_EQ(static_cast<void*>(NULL),
-              empty_tree.largestNode());
+    EXPECT_EQ(static_cast<void*>(NULL), empty_tree.largestNode());
 }
 
 TEST_F(DomainTreeTest, nextNodeError) {
diff --git a/src/lib/datasrc/memory/zone_finder.cc b/src/lib/datasrc/memory/zone_finder.cc
index cbe79da..08b740c 100644
--- a/src/lib/datasrc/memory/zone_finder.cc
+++ b/src/lib/datasrc/memory/zone_finder.cc
@@ -617,8 +617,9 @@ 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);
+    uint8_t labels_buf[LabelSequence::MAX_SERIALIZED_LENGTH];
+    const LabelSequence origin_ls(zone_data_.getOriginNode()->
+                                  getAbsoluteLabels(labels_buf));
     const LabelSequence name_ls(name);
 
     if (!zone_data_.isNSEC3Signed()) {
@@ -648,7 +649,7 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
     }
 
     // Convenient shortcuts
-    const unsigned int olabels = origin.getLabelCount();
+    const unsigned int olabels = origin_ls.getLabelCount();
     const unsigned int qlabels = name.getLabelCount();
     // placeholder of the next closer proof
     const ZoneNode* covering_node(NULL);
@@ -656,7 +657,7 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
     // Now we'll first look up the origin node and initialize orig_chain
     // with it.
     ZoneChain orig_chain;
-    ZoneNode* node(NULL);
+    const ZoneNode* node(NULL);
     ZoneTree::Result result =
          tree.find<void*>(origin_ls, &node, orig_chain, NULL, NULL);
     if (result != ZoneTree::EXACTMATCH) {
diff --git a/src/lib/dns/nsec3hash.cc b/src/lib/dns/nsec3hash.cc
index 42046c6..eb440ac 100644
--- a/src/lib/dns/nsec3hash.cc
+++ b/src/lib/dns/nsec3hash.cc
@@ -16,6 +16,7 @@
 
 #include <cassert>
 #include <cstring>
+#include <cstdlib>
 #include <string>
 #include <vector>
 
@@ -78,11 +79,8 @@ public:
         SHA1Reset(&sha1_ctx_);
     }
 
-    ~NSEC3HashRFC5155()
-    {
-        if (salt_data_ != NULL) {
-            free(salt_data_);
-        }
+    ~NSEC3HashRFC5155() {
+        std::free(salt_data_);
     }
 
     virtual std::string calculate(const Name& name) const;
@@ -126,15 +124,14 @@ NSEC3HashRFC5155::calculate(const Name& name) const {
     name_copy.downcase();
     name_copy.toWire(obuf_);
 
-    const uint8_t* const salt = (salt_length_ > 0) ? salt_data_ : NULL;
     uint8_t* const digest = &digest_[0];
     assert(digest_.size() == SHA1_HASHSIZE);
 
     iterateSHA1(&sha1_ctx_, static_cast<const uint8_t*>(obuf_.getData()),
-                obuf_.getLength(), salt, salt_length_, digest);
+                obuf_.getLength(), salt_data_, salt_length_, digest);
     for (unsigned int n = 0; n < iterations_; ++n) {
         iterateSHA1(&sha1_ctx_, digest, SHA1_HASHSIZE,
-                    salt, salt_length_, digest);
+                    salt_data_, salt_length_, digest);
     }
 
     return (encodeBase32Hex(digest_));
@@ -204,14 +201,16 @@ NSEC3Hash*
 DefaultNSEC3HashCreator::create(const generic::NSEC3PARAM& param) const {
     const vector<uint8_t>& salt = param.getSalt();
     return (new NSEC3HashRFC5155(param.getHashalg(), param.getIterations(),
-                                 &salt[0], salt.size()));
+                                 salt.empty() ? NULL : &salt[0],
+                                 salt.size()));
 }
 
 NSEC3Hash*
 DefaultNSEC3HashCreator::create(const generic::NSEC3& nsec3) const {
     const vector<uint8_t>& salt = nsec3.getSalt();
     return (new NSEC3HashRFC5155(nsec3.getHashalg(), nsec3.getIterations(),
-                                 &salt[0], salt.size()));
+                                 salt.empty() ? NULL : &salt[0],
+                                 salt.size()));
 }
 
 NSEC3Hash*



More information about the bind10-changes mailing list