BIND 10 master, updated. 5d03cd4b844bf1288032ee9a148aef5077a167f3 [trac503] Small test cleanup
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 26 12:50:27 UTC 2011
The branch, master has been updated
via 5d03cd4b844bf1288032ee9a148aef5077a167f3 (commit)
via c8e84e56caeb809f91c7823ae1c4e9aa30e49c57 (commit)
via 239c9694953dcd1dc1ffdd60b7205fca5fdd651c (commit)
from 5823a2ff954e0965048c5d4cc33314d9bb2ae637 (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 5d03cd4b844bf1288032ee9a148aef5077a167f3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Jan 26 12:40:40 2011 +0100
[trac503] Small test cleanup
* Fixed a comment
* Modified condition in MockZone to match the one in MemoryZone.
commit c8e84e56caeb809f91c7823ae1c4e9aa30e49c57
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date: Wed Jan 26 17:36:02 2011 +0800
[trac503] Avoid creating unnecessary RRsetList
commit 239c9694953dcd1dc1ffdd60b7205fca5fdd651c
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date: Wed Jan 26 14:44:38 2011 +0800
implement ANY query logic
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/query.cc | 25 +++++++++++++----
src/bin/auth/tests/query_unittest.cc | 49 ++++++++++++++++++++++++++-------
2 files changed, 57 insertions(+), 17 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc
index 4ecc75e..e270500 100644
--- a/src/bin/auth/query.cc
+++ b/src/bin/auth/query.cc
@@ -122,6 +122,8 @@ Query::getAuthAdditional(const Zone& zone) const {
void
Query::process() const {
bool keep_doing = true;
+ const bool qtype_is_any = (qtype_ == RRType::ANY());
+
response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
const MemoryDataSrc::FindResult result =
memory_datasrc_.findZone(qname_);
@@ -141,20 +143,31 @@ Query::process() const {
response_.setHeaderFlag(Message::HEADERFLAG_AA);
while (keep_doing) {
keep_doing = false;
- Zone::FindResult db_result = result.zone->find(qname_, qtype_);
+ std::auto_ptr<RRsetList> target(qtype_is_any ? new RRsetList : NULL);
+ Zone::FindResult db_result =
+ result.zone->find(qname_, qtype_, target.get());
+
switch (db_result.code) {
case Zone::SUCCESS:
response_.setRcode(Rcode::NOERROR());
- response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(db_result.rrset));
- // Handle additional for answer section
- getAdditional(*result.zone, *db_result.rrset);
+ if (qtype_is_any) {
+ // If quety type is ANY, insert all RRs under the domain
+ // into answer section.
+ BOOST_FOREACH(RRsetPtr rrset, *target) {
+ response_.addRRset(Message::SECTION_ANSWER, rrset);
+ }
+ } else {
+ response_.addRRset(Message::SECTION_ANSWER,
+ boost::const_pointer_cast<RRset>(db_result.rrset));
+ // 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()))
+ (qtype_ != RRType::NS() && !qtype_is_any))
{
getAuthAdditional(*result.zone);
}
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index 45fa08b..6ea0ac3 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -59,10 +59,10 @@ const char* const ns_addrs_txt =
"glue.delegation.example.com. 3600 IN AAAA 2001:db8::53\n"
"noglue.example.com. 3600 IN A 192.0.2.53\n";
const char* const delegation_txt =
- "delegation.example.com. 3600 IN NS glue.delegation.example.com.\n"
- "delegation.example.com. 3600 IN NS noglue.example.com.\n"
- "delegation.example.com. 3600 IN NS cname.example.com.\n"
- "delegation.example.com. 3600 IN NS example.org.\n";
+ "delegation.example.com. 3600 IN NS glue.delegation.example.com.\n"
+ "delegation.example.com. 3600 IN NS noglue.example.com.\n"
+ "delegation.example.com. 3600 IN NS cname.example.com.\n"
+ "delegation.example.com. 3600 IN NS example.org.\n";
const char* const mx_txt =
"mx.example.com. 3600 IN MX 10 www.example.com.\n"
"mx.example.com. 3600 IN MX 20 mailer.example.org.\n"
@@ -166,16 +166,14 @@ MockZone::find(const Name& name, const RRType& type,
return (FindResult(SUCCESS, found_rrset->second));
}
- // If not found but the qtype is ANY, return the first RRset
- if (!found_domain->second.empty() && type == RRType::ANY()) {
+ // If not found but we have a target, fill it with all RRsets here
+ if (!found_domain->second.empty() && target != NULL) {
for (found_rrset = found_domain->second.begin();
found_rrset != found_domain->second.end(); found_rrset++)
{
// Insert RRs under the domain name into target
- if (target) {
- target->addRRset(
- boost::const_pointer_cast<RRset>(found_rrset->second));
- }
+ target->addRRset(
+ boost::const_pointer_cast<RRset>(found_rrset->second));
}
return (FindResult(SUCCESS, found_domain->second.begin()->second));
}
@@ -238,7 +236,8 @@ responseCheck(Message& response, const isc::dns::Rcode& rcode,
if (expected_answer != NULL) {
rrsetsCheck(expected_answer,
response.beginSection(Message::SECTION_ANSWER),
- response.endSection(Message::SECTION_ANSWER));
+ response.endSection(Message::SECTION_ANSWER),
+ check_origin);
}
if (expected_authority != NULL) {
rrsetsCheck(expected_authority,
@@ -292,6 +291,7 @@ TEST_F(QueryTest, apexNSMatch) {
zone_ns_txt, NULL, ns_addrs_txt);
}
+// test type any query logic
TEST_F(QueryTest, exactAnyMatch) {
// find match rrset, omit additional data which has already been provided
// in the answer section from the additional.
@@ -305,6 +305,33 @@ TEST_F(QueryTest, exactAnyMatch) {
"glue.delegation.example.com. 3600 IN AAAA 2001:db8::53\n");
}
+TEST_F(QueryTest, apexAnyMatch) {
+ // find match rrset, omit additional data which has already been provided
+ // in the answer section from the additional.
+ EXPECT_NO_THROW(Query(memory_datasrc, Name("example.com"),
+ RRType::ANY(), response).process());
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 4, 0, 0,
+ "example.com. 3600 IN SOA . . 0 0 0 0 0\n"
+ "example.com. 3600 IN NS glue.delegation.example.com.\n"
+ "example.com. 3600 IN NS noglue.example.com.\n"
+ "example.com. 3600 IN NS example.net.\n",
+ NULL, NULL, mock_zone->getOrigin());
+}
+
+TEST_F(QueryTest, glueANYMatch) {
+ EXPECT_NO_THROW(Query(memory_datasrc, Name("delegation.example.com"),
+ RRType::ANY(), response).process());
+ responseCheck(response, Rcode::NOERROR(), 0, 0, 4, 3,
+ NULL, delegation_txt, ns_addrs_txt);
+}
+
+TEST_F(QueryTest, nodomainANY) {
+ EXPECT_NO_THROW(Query(memory_datasrc, Name("nxdomain.example.com"),
+ RRType::ANY(), response).process());
+ responseCheck(response, Rcode::NXDOMAIN(), AA_FLAG, 0, 1, 0,
+ NULL, soa_txt, NULL, mock_zone->getOrigin());
+}
+
// 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.
More information about the bind10-changes
mailing list