BIND 10 trac493, updated. 8c136625d1e2556c7c8280917a1f18370794ce76 Merge branch 'trac493' of ssh://bind10.isc.org/var/bind10/git/bind10 into trac493

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Mar 3 08:02:30 UTC 2011


The branch, trac493 has been updated
       via  8c136625d1e2556c7c8280917a1f18370794ce76 (commit)
       via  af0eb33e4d57c842f692b653d783e028250264dc (commit)
      from  6ed6d55c1e9908ce49d4ba2584c9d647c23908ba (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 8c136625d1e2556c7c8280917a1f18370794ce76
Merge: af0eb33e4d57c842f692b653d783e028250264dc 6ed6d55c1e9908ce49d4ba2584c9d647c23908ba
Author: Ocean Wang <wanghaidong at cnnic.cn>
Date:   Thu Mar 3 16:02:05 2011 +0800

    Merge branch 'trac493' of ssh://bind10.isc.org/var/bind10/git/bind10 into trac493

commit af0eb33e4d57c842f692b653d783e028250264dc
Author: Ocean Wang <wanghaidong at cnnic.cn>
Date:   Thu Mar 3 16:01:10 2011 +0800

    [trac493] Check whether the message can be cached before create the message
    entry

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

Summary of changes:
 src/lib/cache/Makefile.am      |    1 +
 src/lib/cache/message_cache.cc |   14 ++++++++--
 src/lib/cache/message_entry.cc |   55 ++++-----------------------------------
 src/lib/cache/message_entry.h  |   14 ----------
 4 files changed, 18 insertions(+), 66 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/cache/Makefile.am b/src/lib/cache/Makefile.am
index 264aca6..107fc9a 100644
--- a/src/lib/cache/Makefile.am
+++ b/src/lib/cache/Makefile.am
@@ -29,5 +29,6 @@ libcache_la_SOURCES  += rrset_entry.h rrset_entry.cc
 libcache_la_SOURCES  += cache_entry_key.h cache_entry_key.cc
 libcache_la_SOURCES  += rrset_copy.h rrset_copy.cc
 libcache_la_SOURCES  += local_zone_data.h local_zone_data.cc
+libcache_la_SOURCES  += message_utility.h message_utility.cc
 
 CLEANFILES = *.gcno *.gcda
diff --git a/src/lib/cache/message_cache.cc b/src/lib/cache/message_cache.cc
index 1b70519..bcca66d 100644
--- a/src/lib/cache/message_cache.cc
+++ b/src/lib/cache/message_cache.cc
@@ -20,14 +20,16 @@
 #include <nsas/hash_table.h>
 #include <nsas/hash_deleter.h>
 #include "message_cache.h"
+#include "message_utility.h"
 #include "cache_entry_key.h"
 
+namespace isc {
+namespace cache {
+
 using namespace isc::nsas;
 using namespace isc::dns;
 using namespace std;
-
-namespace isc {
-namespace cache {
+using namespace MessageUtility;
 
 MessageCache::MessageCache(boost::shared_ptr<RRsetCache> rrset_cache,
     uint32_t cache_size, uint16_t message_class, boost::shared_ptr<RRsetCache> negative_soa_cache):
@@ -58,6 +60,12 @@ MessageCache::lookup(const isc::dns::Name& qname,
 
 bool
 MessageCache::update(const Message& msg) {
+    // If the message is a negative response, but no SOA record is found in
+    // the authority section, the message cannot be cached
+    if (isNegativeResponse(msg) && !hasTheRecordInAuthoritySection(msg, RRType::SOA())){
+        return (false);
+    }
+
     QuestionIterator iter = msg.beginQuestion();
     std::string entry_name = genCacheEntryName((*iter)->getName(), (*iter)->getType());
     HashKey entry_key = HashKey(entry_name, RRClass(message_class_));
diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc
index 9e82a9d..400caf6 100644
--- a/src/lib/cache/message_entry.cc
+++ b/src/lib/cache/message_entry.cc
@@ -18,9 +18,9 @@
 
 #include <limits>
 #include <dns/message.h>
-#include <dns/rcode.h>
 #include <nsas/nsas_entry.h>
 #include "message_entry.h"
+#include "message_utility.h"
 #include "rrset_cache.h"
 
 using namespace isc::dns;
@@ -274,60 +274,17 @@ MessageEntry::initMessageEntry(const isc::dns::Message& msg) {
     query_class_ = (*iter)->getClass().getCode();
 
     uint32_t min_ttl = MAX_UINT32;
-    if (!isNegativeResponse(msg)){
-        parseSection(msg, Message::SECTION_ANSWER, min_ttl, answer_count_);
+
+    parseSection(msg, Message::SECTION_ANSWER, min_ttl, answer_count_);
+    if (!MessageUtility::isNegativeResponse(msg)){
         parseSection(msg, Message::SECTION_AUTHORITY, min_ttl, authority_count_);
-        parseSection(msg, Message::SECTION_ADDITIONAL, min_ttl, additional_count_);
     } else {
-        // For negative response, if no soa RRset is found in authority 
-        // section, don't cache it
-        if (!hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
-            return;
-        }
-
         parseNegativeResponseAuthoritySection(msg, min_ttl, authority_count_);
-        parseSection(msg, Message::SECTION_ANSWER, min_ttl, answer_count_);
-        parseSection(msg, Message::SECTION_ADDITIONAL, min_ttl, additional_count_);
-
-    }
-    expire_time_ = time(NULL) + min_ttl;
-}
-
-bool
-MessageEntry::isNegativeResponse(const isc::dns::Message& msg)
-{
-    if (msg.getRcode() == Rcode::NXDOMAIN()) {
-        return (true);
-    } else if (msg.getRcode() == Rcode::NOERROR()) {
-        // no data in the answer section
-        if (msg.getRRCount(Message::SECTION_ANSWER) == 0) {
-            // NODATA type 1/ type 2 (ref sec2.2 of RFC2308) 
-            if (hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
-                return (true);
-            } else if (!hasTheRecordInAuthoritySection(msg, RRType::NS())) { // NODATA type 3 (sec2.2 of RFC2308)
-                return (true);
-            }
-        }
     }
+    parseSection(msg, Message::SECTION_ADDITIONAL, min_ttl, additional_count_);
 
-    return (false);
-}
-
-bool
-MessageEntry::hasTheRecordInAuthoritySection(const isc::dns::Message& msg, const isc::dns::RRType& type)
-{
-    for (RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
-            iter != msg.endSection(Message::SECTION_AUTHORITY);
-            ++iter) {
-        RRsetPtr rrset_ptr = *iter;
-        if (rrset_ptr->getType() == type) {
-            return (true);
-        }
-    }
-    return (false);
+    expire_time_ = time(NULL) + min_ttl;
 }
 
 } // namespace cache
 } // namespace isc
-
-
diff --git a/src/lib/cache/message_entry.h b/src/lib/cache/message_entry.h
index 0bef94a..7db02a4 100644
--- a/src/lib/cache/message_entry.h
+++ b/src/lib/cache/message_entry.h
@@ -168,20 +168,6 @@ protected:
     //@}
 
 private:
-    /// \brief Check whetehr the message is a negative response
-    ///        (NXDOMAIN or NOERROR_NODATA)
-    ///
-    /// \param msg The response message
-    bool isNegativeResponse(const isc::dns::Message& msg);
-
-    /// \brief Check whether there is some type of record in
-    ///        Authority section
-    ///
-    /// \param msg The response message to be checked
-    /// \param type The RR type that need to check
-    bool hasTheRecordInAuthoritySection(const isc::dns::Message& msg,
-                                        const isc::dns::RRType& type);
-
     std::string entry_name_; // The name for this entry(name + type)
     HashKey* hash_key_ptr_;  // the key for messag entry in hash table.
 




More information about the bind10-changes mailing list