[svn] commit: r2280 - in /branches/trac75/src/lib/datasrc: data_source.cc tests/datasrc_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jun 25 03:13:21 UTC 2010


Author: each
Date: Fri Jun 25 03:13:20 2010
New Revision: 2280

Log:
Negative wildcard answers didn't always include the SOA record
in the authority section.

Modified:
    branches/trac75/src/lib/datasrc/data_source.cc
    branches/trac75/src/lib/datasrc/tests/datasrc_unittest.cc

Modified: branches/trac75/src/lib/datasrc/data_source.cc
==============================================================================
--- branches/trac75/src/lib/datasrc/data_source.cc (original)
+++ branches/trac75/src/lib/datasrc/data_source.cc Fri Jun 25 03:13:20 2010
@@ -442,6 +442,7 @@
     RRsetList wild;
     const Name star("*");
     bool cname = false;
+    bool nxrrset = false;
 
     for (int i = 1; i <= diff; ++i) {
         const Name& wname(star.concatenate(task->qname.split(i)));
@@ -464,13 +465,14 @@
             } else if ((newtask.flags & DataSrc::TYPE_NOT_FOUND) != 0) {
                 task->flags &= ~DataSrc::NAME_NOT_FOUND;
                 task->flags |= DataSrc::TYPE_NOT_FOUND;
+                nxrrset = true;
                 break;
             }
         }
     }
 
     // A wildcard was found.
-    if (found) {
+    if (found || nxrrset) {
         // Prove the nonexistence of the name we were looking for
         if (q.wantDnssec()) {
             result = proveNX(q, task, ds, *zonename, true);
@@ -479,7 +481,9 @@
                 return (DataSrc::ERROR);
             }
         }
-
+   }
+
+   if (found) {
         // Add the data to the answer section (but with the name changed to
         // match the qname), and then continue as if this were a normal
         // answer: if a CNAME, chase the target, otherwise add authority.
@@ -490,7 +494,7 @@
                 m.addRRset(Section::ANSWER(), rrset, q.wantDnssec());
                 chaseCname(q, task, rrset);
             }
-        } else {
+        } else if (!nxrrset) {
             BOOST_FOREACH (RRsetPtr rrset, wild) {
                 rrset->setName(task->qname);
                 m.addRRset(Section::ANSWER(), rrset, q.wantDnssec());
@@ -697,16 +701,17 @@
             // NXDOMAIN, and also add the previous NSEC to the authority
             // section.  For TYPE_NOT_FOUND, do not set an error rcode,
             // and send the current NSEC in the authority section.
-            if (task->state == QueryTask::GETANSWER) {
+            if (task->state == QueryTask::GETANSWER ||
+                task->state == QueryTask::FOLLOWCNAME) {
                 if ((task->flags & NAME_NOT_FOUND) != 0) {
                     m.setRcode(Rcode::NXDOMAIN());
                 }
-
-                result = addSOA(q, zonename, datasource);
-                if (result != SUCCESS) {
-                    m.setRcode(Rcode::SERVFAIL());
-                    return;
-                }
+            }
+
+            result = addSOA(q, zonename, datasource);
+            if (result != SUCCESS) {
+                m.setRcode(Rcode::SERVFAIL());
+                return;
             }
 
             Name nsecname(task->qname);

Modified: branches/trac75/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- branches/trac75/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ branches/trac75/src/lib/datasrc/tests/datasrc_unittest.cc Fri Jun 25 03:13:20 2010
@@ -306,7 +306,7 @@
     // Check that a query for a data type not covered by the wildcard
     // returns NOERROR
     readAndProcessQuery("q_wild_aaaa");
-    headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 2, 0);
+    headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 4, 0);
 }
 
 TEST_F(DataSrcTest, WildcardCname) {
@@ -381,7 +381,7 @@
     // A wildcard containing a CNAME whose target does not include
     // data of this type.
     readAndProcessQuery("q_wild2_aaaa");
-    headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 0);
+    headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 6, 0);
 
     RRsetIterator rit = msg.beginSection(Section::ANSWER());
     RRsetPtr rrset = *rit;
@@ -399,6 +399,13 @@
     rrset = *rit;
     EXPECT_EQ(Name("*.wild2.example.com"), rrset->getName());
     EXPECT_EQ(RRType::NSEC(), rrset->getType());
+    EXPECT_EQ(RRClass::IN(), rrset->getClass());
+    ++rit;
+    ++rit;
+
+    rrset = *rit;
+    EXPECT_EQ(Name("example.com"), rrset->getName());
+    EXPECT_EQ(RRType::SOA(), rrset->getType());
     EXPECT_EQ(RRClass::IN(), rrset->getClass());
     ++rit;
     ++rit;
@@ -412,7 +419,7 @@
 TEST_F(DataSrcTest, WildcardCnameNxdomain) {
     // A wildcard containing a CNAME whose target does not exist
     readAndProcessQuery("q_wild3_a");
-    headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 6, 0);
+    headerCheck(msg, Rcode::NXDOMAIN(), true, true, true, 2, 8, 0);
 
     RRsetIterator rit = msg.beginSection(Section::ANSWER());
     RRsetPtr rrset = *rit;
@@ -430,6 +437,13 @@
     rrset = *rit;
     EXPECT_EQ(Name("*.wild3.example.com"), rrset->getName());
     EXPECT_EQ(RRType::NSEC(), rrset->getType());
+    EXPECT_EQ(RRClass::IN(), rrset->getClass());
+    ++rit;
+    ++rit;
+
+    rrset = *rit;
+    EXPECT_EQ(Name("example.com"), rrset->getName());
+    EXPECT_EQ(RRType::SOA(), rrset->getType());
     EXPECT_EQ(RRClass::IN(), rrset->getClass());
     ++rit;
     ++rit;




More information about the bind10-changes mailing list