BIND 10 trac505, updated. f167a263da41987a76b76e8b71acb9620a0c89c5 [trac505] No authority with CNAME/DNAME

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Feb 8 17:15:35 UTC 2011


The branch, trac505 has been updated
       via  f167a263da41987a76b76e8b71acb9620a0c89c5 (commit)
       via  c334da7773375a87b5e7154daabf132f945f154a (commit)
      from  32ca390dad48d4d5c8bea98248bdfc62894f87ed (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 f167a263da41987a76b76e8b71acb9620a0c89c5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Feb 8 18:08:00 2011 +0100

    [trac505] No authority with CNAME/DNAME

commit c334da7773375a87b5e7154daabf132f945f154a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Feb 8 17:28:04 2011 +0100

    [trac505] Tests: no authority with CNAME/DNAME
    
    As agreed, we don't provide the authority section for the original
    DNAME/CNAME, only for the last target. As we don't chain, we don't
    provide it at all.

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

Summary of changes:
 src/bin/auth/query.cc                |   52 ++++++++++++---------------------
 src/bin/auth/tests/query_unittest.cc |   29 +++++++++----------
 2 files changed, 33 insertions(+), 48 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc
index d7018b1..6b8e492 100644
--- a/src/bin/auth/query.cc
+++ b/src/bin/auth/query.cc
@@ -141,54 +141,40 @@ Query::process() const {
 
     // Found a zone which is the nearest ancestor to QNAME, set the AA bit
     response_.setHeaderFlag(Message::HEADERFLAG_AA);
+    response_.setRcode(Rcode::NOERROR());
     while (keep_doing) {
         keep_doing = false;
         std::auto_ptr<RRsetList> target(qtype_is_any ? new RRsetList : NULL);
-        /*
-         * We use the rrset, not db_result.rrset because we might replace
-         * it while synthetizing the CNAME out of DNAME. The db_result is
-         * imutable, so we have a different variable.
-         */
         Zone::FindResult db_result(result.zone->find(qname_, qtype_,
             target.get()));
-        ConstRRsetPtr rrset(db_result.rrset);
 
         switch (db_result.code) {
             case Zone::DNAME: {
                 // First, put the dname into the answer
                 response_.addRRset(Message::SECTION_ANSWER,
-                    boost::const_pointer_cast<RRset>(rrset));
-                /*
-                 * We synthetize CNAME out of it, replace the rrset and let
-                 * the CNAME case handle it (including future chaining).
-                 * Therefore, we just fall trough to it.
-                 */
+                    boost::const_pointer_cast<RRset>(db_result.rrset));
                 /*
                  * Empty DNAME should never get in, as it is impossible to
                  * create one in master file.
                  */
-                assert(rrset->getRdataCount() > 0);
+                assert(db_result.rrset->getRdataCount() > 0);
                 // Get the data of DNAME
                 const rdata::generic::DNAME& dname(
                     dynamic_cast<const rdata::generic::DNAME&>(
-                    rrset->getRdataIterator()->getCurrent()));
+                    db_result.rrset->getRdataIterator()->getCurrent()));
                 // The new CNAME we are creating (it will be unsigned even
                 // with DNSSEC, the DNAME is signed and it can be validated
                 // by that)
-                RRsetPtr cname(new RRset(qname_, rrset->getClass(),
-                    RRType::CNAME(), rrset->getTTL()));
+                RRsetPtr cname(new RRset(qname_, db_result.rrset->getClass(),
+                    RRType::CNAME(), db_result.rrset->getTTL()));
                 try {
                     // Construct the new target by replacing the end
                     cname->addRdata(rdata::generic::CNAME(qname_.split(0,
                         qname_.getLabelCount() -
-                        rrset->getName().getLabelCount()).concatenate(
-                        dname.getDname())));
-                    rrset = cname;
-                    // If this was ANY, act as it wasn't, because we put the
-                    // CNAME into rrset, not to target and there's nothing else.
-                    // TODO: This might need to be changed when CNAME gets
-                    // chaining.
-                    qtype_is_any = false;
+                        db_result.rrset->getName().getLabelCount()).
+                        concatenate(dname.getDname())));
+                    response_.addRRset(Message::SECTION_ANSWER, cname);
+                    break;
                 }
                 /*
                  * In case the synthetized name is too long, section 4.1 of RFC 2672
@@ -198,7 +184,6 @@ Query::process() const {
                     response_.setRcode(Rcode::YXDOMAIN());
                     return;
                 }
-                // No break; here, fall trough.
             }
             case Zone::CNAME:
                 /*
@@ -207,10 +192,13 @@ Query::process() const {
                  * what we expected. It means no exceptions in ANY or NS
                  * on the origin (though CNAME in origin is probably
                  * forbidden anyway).
+                 *
+                 * So, just put it there.
                  */
-                // No break; here, fall trough.
+                response_.addRRset(Message::SECTION_ANSWER,
+                    boost::const_pointer_cast<RRset>(db_result.rrset));
+                break;
             case Zone::SUCCESS:
-                response_.setRcode(Rcode::NOERROR());
                 if (qtype_is_any) {
                     // If quety type is ANY, insert all RRs under the domain
                     // into answer section.
@@ -219,9 +207,9 @@ Query::process() const {
                     }
                 } else {
                     response_.addRRset(Message::SECTION_ANSWER,
-                        boost::const_pointer_cast<RRset>(rrset));
+                        boost::const_pointer_cast<RRset>(db_result.rrset));
                     // Handle additional for answer section
-                    getAdditional(*result.zone, *rrset);
+                    getAdditional(*result.zone, *db_result.rrset);
                 }
                 // If apex NS records haven't been provided in the answer
                 // section, insert apex NS records into the authority section
@@ -236,10 +224,9 @@ Query::process() const {
                 break;
             case Zone::DELEGATION:
                 response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
-                response_.setRcode(Rcode::NOERROR());
                 response_.addRRset(Message::SECTION_AUTHORITY,
-                    boost::const_pointer_cast<RRset>(rrset));
-                getAdditional(*result.zone, *rrset);
+                    boost::const_pointer_cast<RRset>(db_result.rrset));
+                getAdditional(*result.zone, *db_result.rrset);
                 break;
             case Zone::NXDOMAIN:
                 // Just empty answer with SOA in authority section
@@ -248,7 +235,6 @@ Query::process() const {
                 break;
             case Zone::NXRRSET:
                 // Just empty answer with SOA in authority section
-                response_.setRcode(Rcode::NOERROR());
                 putSOA(*result.zone);
                 break;
         }
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index 90ddbda..1c1869e 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -481,8 +481,8 @@ TEST_F(QueryTest, CNAME) {
     Query(memory_datasrc, Name("cname.example.com"), RRType::A(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
-        cname_txt, zone_ns_txt, ns_addrs_txt);
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
+        cname_txt, NULL, NULL);
 }
 
 TEST_F(QueryTest, explicitCNAME) {
@@ -503,8 +503,8 @@ TEST_F(QueryTest, CNAME_NX_RRSET) {
     Query(memory_datasrc, Name("cname.example.com"), RRType::TXT(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
-        cname_txt, zone_ns_txt, ns_addrs_txt);
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
+        cname_txt, NULL, NULL);
 }
 
 TEST_F(QueryTest, explicitCNAME_NX_RRSET) {
@@ -526,8 +526,8 @@ TEST_F(QueryTest, CNAME_NX_DOMAIN) {
     Query(memory_datasrc, Name("cnamenxdom.example.com"), RRType::A(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
-        cname_nxdom_txt, zone_ns_txt, ns_addrs_txt);
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
+        cname_nxdom_txt, NULL, NULL);
 }
 
 TEST_F(QueryTest, explicitCNAME_NX_DOMAIN) {
@@ -551,8 +551,8 @@ TEST_F(QueryTest, CNAME_OUT) {
     Query(memory_datasrc, Name("cnameout.example.com"), RRType::A(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
-        cname_out_txt, zone_ns_txt, ns_addrs_txt);
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 0, 0,
+        cname_out_txt, NULL, NULL);
 }
 
 TEST_F(QueryTest, explicitCNAME_OUT) {
@@ -576,25 +576,24 @@ TEST_F(QueryTest, DNAME) {
     Query(memory_datasrc, Name("www.dname.example.com"), RRType::A(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 3, 3,
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
         (string(dname_txt) + synthetized_cname_txt).c_str(),
-        zone_ns_txt, ns_addrs_txt);
+        NULL, NULL);
 }
 
 /*
  * Ask an ANY query below a DNAME. Should return the DNAME and synthetized
  * CNAME.
  *
- * This is added because the original version didn't include the CNAME at
- * all.
+ * This is added because the original implementation had a bug and didn't
+ * include the CNAME at all.
  */
 TEST_F(QueryTest, DNAME_ANY) {
     Query(memory_datasrc, Name("www.dname.example.com"), RRType::ANY(),
         response).process();
 
-    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 3, 3,
-        (string(dname_txt) + synthetized_cname_txt).c_str(),
-        zone_ns_txt, ns_addrs_txt);
+    responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
+        (string(dname_txt) + synthetized_cname_txt).c_str(), NULL, NULL);
 }
 
 // Test when we ask for DNAME explicitly, it does no synthetizing.




More information about the bind10-changes mailing list