[svn] commit: r4164 - in /branches/trac475/src/bin/auth: query.cc tests/query_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jan 5 11:00:32 UTC 2011


Author: chenzhengzhang
Date: Wed Jan  5 11:00:32 2011
New Revision: 4164

Log:
omit authority data which has already been provided in the answer section from the authority section.

Modified:
    branches/trac475/src/bin/auth/query.cc
    branches/trac475/src/bin/auth/tests/query_unittest.cc

Modified: branches/trac475/src/bin/auth/query.cc
==============================================================================
--- branches/trac475/src/bin/auth/query.cc (original)
+++ branches/trac475/src/bin/auth/query.cc Wed Jan  5 11:00:32 2011
@@ -106,7 +106,8 @@
                 zone.getOrigin().toText());
     } else {
         response_.addRRset(Message::SECTION_AUTHORITY,
-                boost::const_pointer_cast<RRset>(ns_result.rrset));
+            boost::const_pointer_cast<RRset>(ns_result.rrset));
+        // Handle additional for authority section
         getAdditional(zone, *ns_result.rrset);
     }
 }
@@ -139,13 +140,23 @@
                 response_.setRcode(Rcode::NOERROR());
                 response_.addRRset(Message::SECTION_ANSWER,
                     boost::const_pointer_cast<RRset>(db_result.rrset));
-                getAuthAdditional(*result.zone);
+                // Handle additional for answer section
+                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
+                // and AAAA/A RRS of each of the NS RDATA into the additional
+                // section.
+                if (qname_ != result.zone->getOrigin() ||
+                    (qtype_ != RRType::NS() && qtype_ != RRType::ANY()))
+                {
+                    getAuthAdditional(*result.zone);
+                }
                 break;
             case Zone::DELEGATION:
                 response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
                 response_.setRcode(Rcode::NOERROR());
                 response_.addRRset(Message::SECTION_AUTHORITY,
-                            boost::const_pointer_cast<RRset>(db_result.rrset));
+                    boost::const_pointer_cast<RRset>(db_result.rrset));
                 getAdditional(*result.zone, *db_result.rrset);
                 break;
             case Zone::NXDOMAIN:

Modified: branches/trac475/src/bin/auth/tests/query_unittest.cc
==============================================================================
--- branches/trac475/src/bin/auth/tests/query_unittest.cc (original)
+++ branches/trac475/src/bin/auth/tests/query_unittest.cc Wed Jan  5 11:00:32 2011
@@ -228,6 +228,32 @@
                                   RRClass::IN(), RRType::A()));
 }
 
+TEST_F(QueryTest, apexNSMatch) {
+    // find match rrset, omit authority data which has already been provided
+    // in the answer section from the authority section.
+    memory_datasrc.addZone(ZonePtr(new MockZone()));
+    const Name apex_name(Name("example.com"));
+    Query apex_ns_query(memory_datasrc, apex_name, RRType::NS(), response);
+    EXPECT_NO_THROW(apex_ns_query.process());
+    EXPECT_TRUE(response.getHeaderFlag(Message::HEADERFLAG_AA));
+    EXPECT_EQ(Rcode::NOERROR(), response.getRcode());
+    EXPECT_TRUE(response.hasRRset(Message::SECTION_ANSWER,
+                                  Name("example.com"), RRClass::IN(),
+                                  RRType::NS()));
+    EXPECT_FALSE(response.hasRRset(Message::SECTION_AUTHORITY,
+                                  Name("example.com"), RRClass::IN(),
+                                  RRType::NS()));
+    EXPECT_TRUE(response.hasRRset(Message::SECTION_ADDITIONAL,
+                                  Name("glue.ns.example.com"),
+                                  RRClass::IN(), RRType::A()));
+    EXPECT_TRUE(response.hasRRset(Message::SECTION_ADDITIONAL,
+                                  Name("glue.ns.example.com"),
+                                  RRClass::IN(), RRType::AAAA()));
+    EXPECT_TRUE(response.hasRRset(Message::SECTION_ADDITIONAL,
+                                  Name("noglue.example.com"),
+                                  RRClass::IN(), RRType::A()));
+}
+
 TEST_F(QueryTest, exactAnyMatch) {
     // find match rrset, omit additional data which has already been provided
     // in the answer section from the additional.
@@ -254,11 +280,11 @@
                                   RRClass::IN(), RRType::A()));
 }
 
-// This tests that when we need to look up Zone's apex NS records for 
+// This tests that when we need to look up Zone's apex NS records for
 // authoritative answer, and there is no apex NS records. It should
 // throw in that case.
 TEST_F(QueryTest, noApexNS) {
-    // Add a zone without apex NS records 
+    // Add a zone without apex NS records
     memory_datasrc.addZone(ZonePtr(new MockZone(true, false)));
     const Name noglue_name(Name("noglue.example.com"));
     Query noglue_query(memory_datasrc, noglue_name, qtype, response);




More information about the bind10-changes mailing list