BIND 10 trac595, updated. 86355ec5ded2f1988dc466f8844360c78e8454a7 [trac595] Refactor the code according Jelte's review.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Feb 28 06:42:38 UTC 2011


The branch, trac595 has been updated
       via  86355ec5ded2f1988dc466f8844360c78e8454a7 (commit)
      from  d3b169adf97f9c5a4990400e54562d644016fdaf (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 86355ec5ded2f1988dc466f8844360c78e8454a7
Author: zhanglikun <zhanglikun at cnnic.cn>
Date:   Mon Feb 28 14:42:28 2011 +0800

    [trac595] Refactor the code according Jelte's review.

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

Summary of changes:
 src/lib/cache/message_entry.cc |   48 ++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc
index 5f42ed5..fb59916 100644
--- a/src/lib/cache/message_entry.cc
+++ b/src/lib/cache/message_entry.cc
@@ -26,9 +26,13 @@ using namespace std;
 // Put file scope functions in unnamed namespace.
 namespace {
 
-// Get the deepest owner name of DNAME record for the given query name.
+// Get the shortest existing ancestor which is the owner name of
+// one DNAME record for the given query name.
+// Note: there maybe multiple DNAME records(DNAME chain) in answer section,
+// in most case they are in order, but the code can't depends on it, it has to
+// find the starter by iterating the DNAME chain.
 Name
-getDeepestDNAMEOwner(const Message& message, const Name& query_name) {
+getDNAMEChainStarter(const Message& message, const Name& query_name) {
     Name dname = query_name;
     RRsetIterator rrset_iter = message.beginSection(Message::SECTION_ANSWER);
     while(rrset_iter != message.endSection(Message::SECTION_ANSWER)) {
@@ -45,23 +49,6 @@ getDeepestDNAMEOwner(const Message& message, const Name& query_name) {
     return (dname);
 }
 
-// Check whether answer section in given message has non-authoritative rrsets.
-bool
-answerHasNonAuthRecord(const Message& message, const Name& query_name) {
-    RRsetIterator rrset_iter = message.beginSection(Message::SECTION_ANSWER);
-    while(rrset_iter != message.endSection(Message::SECTION_ANSWER)) {
-        // Here, only check CNAME is enough. If there is
-        // cname record whose ower name is same with query name, answer
-        // section may has non-authoritative rrsets.
-        if ((*rrset_iter)->getType() == RRType::CNAME() &&
-            (*rrset_iter)->getName() == query_name) {
-            return (true);
-        }
-        ++rrset_iter;
-    }
-    return (false);
-}
-
 } // End of unnamed namespace
 
 namespace isc {
@@ -173,17 +160,32 @@ MessageEntry::getRRsetTrustLevel(const Message& message,
                 // from it are authoritative, any other records in answer
                 // section are non-authoritative.
                 QuestionIterator quest_iter = message.beginQuestion();
+                // Make sure question section is not empty.
+                assert( quest_iter != message.endQuestion());
+
                 const Name& query_name = (*quest_iter)->getName();
                 const RRType& type = rrset->getType();
                 const Name& name = rrset->getName();
                 if ((type == RRType::CNAME() && name == query_name) ||
                     (type == RRType::DNAME() &&
-                     name == getDeepestDNAMEOwner(message, query_name))) {
+                     name == getDNAMEChainStarter(message, query_name))) {
                     return (RRSET_TRUST_ANSWER_AA);
-                } else if (answerHasNonAuthRecord(message, query_name)) {
-                    return (RRSET_TRUST_ANSWER_NONAA);
+                } else {
+                    // If there is one CNAME record whose ower name is same with
+                    // query name in answer section, the left records in answer
+                    // section are non-authoritative, except the starter of DNAME
+                    // chain(only checking CNAME is enough, because if the CNAME
+                    // record is synchronized from one DNAME record, that DNAME
+                    // record must be the starter of DNAME chain).
+                    RRsetIterator iter = message.beginSection(Message::SECTION_ANSWER);
+                    while(iter != message.endSection(Message::SECTION_ANSWER)) {
+                        if ((*iter)->getType() == RRType::CNAME() &&
+                             (*iter)->getName() == query_name) {
+                            return (RRSET_TRUST_ANSWER_NONAA);
+                        }
+                        ++iter;
+                    }
                 }
-
                 return (RRSET_TRUST_ANSWER_AA);
             } else {
                 return (RRSET_TRUST_ANSWER_NONAA);




More information about the bind10-changes mailing list