BIND 10 master, updated. 696cec5b0e99ebf65c3ea634abbc6114f1b92d8c Merge branch 'work/dname/query'
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Feb 12 10:46:28 UTC 2011
The branch, master has been updated
via 696cec5b0e99ebf65c3ea634abbc6114f1b92d8c (commit)
via 2c54e9c5f490b876eb59200cfcf9cc4623250bda (commit)
via 49e2c1ae796e46fca4f5c395a92387638bb828c6 (commit)
via 53f4afe16013ef6f97556d3b49d1bc56443dc08c (commit)
via 180015eada7cdc67f8756a7425f9023d884b19df (commit)
via f9a11dcba2da26e3a27a4be00461aea07aa60d85 (commit)
via a43d8d0ef4cd44d5e0ab9fa9fc746e6d1ff353e0 (commit)
via 495087240c7b5736999e3edca697eb8509068ca3 (commit)
via 073d75e7ab64ff107198181cbc9ef4482e83b681 (commit)
via 4fd542a1c095efee2afb61c440784cd3984803cc (commit)
via 5400e06818b54c363c6006395ea51567caa651b3 (commit)
via 746980b33112b63147744796663389e5e1c3144c (commit)
via 0b1f8cb6dfa5481cb67e43ee8c2f24fac97ec95d (commit)
via 0c760d178eecf3162e848074e3fe631d690cc77a (commit)
via c393ec92641b6699822ebacd1c3f4c68496f3316 (commit)
via e7251d0c587ee8a794e590fdcdd4fa07f6a19c1c (commit)
via f167a263da41987a76b76e8b71acb9620a0c89c5 (commit)
via c334da7773375a87b5e7154daabf132f945f154a (commit)
via 32ca390dad48d4d5c8bea98248bdfc62894f87ed (commit)
via f998d613872373c2fbf7088088d7464e79cc10c3 (commit)
via c5f4af2f749808f7e8b96dca09819f69bb094031 (commit)
via 8ddc37ac3b6229f03a1fc122ea3c1c8906cbd75b (commit)
via cac61e91646c344359a5b767d2f2042d05cc1d74 (commit)
via fb4ca10d60279cc2d7da663b912dcb189849d0da (commit)
via 59dd3fb61b265455b544407fcd8976a04f152af3 (commit)
via 65ef7a150b4562f2e80222afd7fb010cbd55ec43 (commit)
via 026a4104701791649673a74591007e1d50167cbe (commit)
from 9cf25c82920546461f63a87359a9ef1aa00bfc78 (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 696cec5b0e99ebf65c3ea634abbc6114f1b92d8c
Merge: 9cf25c82920546461f63a87359a9ef1aa00bfc78 2c54e9c5f490b876eb59200cfcf9cc4623250bda
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Feb 12 11:37:51 2011 +0100
Merge branch 'work/dname/query'
commit 2c54e9c5f490b876eb59200cfcf9cc4623250bda
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Feb 12 11:36:12 2011 +0100
[trac505] Make max_len const
commit 49e2c1ae796e46fca4f5c395a92387638bb828c6
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Feb 11 12:16:18 2011 +0100
[trac505] Another test
Checks that we don't reject synthesized name of the maximum length by
mistake.
commit 53f4afe16013ef6f97556d3b49d1bc56443dc08c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Feb 11 10:59:13 2011 +0100
[trac505] Update comment
commit 180015eada7cdc67f8756a7425f9023d884b19df
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Feb 11 10:54:11 2011 +0100
[trac505] Simplify length check condition
commit f9a11dcba2da26e3a27a4be00461aea07aa60d85
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Thu Feb 10 22:35:46 2011 -0800
[trac505] added some comments about dname.example.com for the mock zone.
commit a43d8d0ef4cd44d5e0ab9fa9fc746e6d1ff353e0
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Thu Feb 10 16:32:28 2011 -0800
[trac505] indentation fixes
commit 495087240c7b5736999e3edca697eb8509068ca3
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Thu Feb 10 16:25:30 2011 -0800
[trac505] consitified variables as much as possible.
note: qtype_is_any was originally const, and was temporarily changed to
mutable. it's now immutable again.
commit 073d75e7ab64ff107198181cbc9ef4482e83b681
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 10:25:48 2011 +0100
[trac505] FIXME: Replace assert
commit 4fd542a1c095efee2afb61c440784cd3984803cc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 10:25:27 2011 +0100
[trac505] Style: Brace position
commit 5400e06818b54c363c6006395ea51567caa651b3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 10:21:45 2011 +0100
[trac505] Check the length manually
commit 746980b33112b63147744796663389e5e1c3144c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 10:07:38 2011 +0100
[trac505] More comments
commit 0b1f8cb6dfa5481cb67e43ee8c2f24fac97ec95d
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Feb 9 15:56:24 2011 +0100
[trac505] Some more comments
commit 0c760d178eecf3162e848074e3fe631d690cc77a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Feb 9 15:52:33 2011 +0100
[trac505] No need for two different DNAMEs in test
We overflow the size of name by prolonging a name of full length by
little bit.
commit c393ec92641b6699822ebacd1c3f4c68496f3316
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Feb 9 15:43:00 2011 +0100
[trac505] Recover comment removed by mistake
commit e7251d0c587ee8a794e590fdcdd4fa07f6a19c1c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Feb 9 15:39:56 2011 +0100
[trac505] Split long line
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.
commit 32ca390dad48d4d5c8bea98248bdfc62894f87ed
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Feb 4 17:50:22 2011 +0100
[trac505] No authority section on long DNAME
It seems the RFC 2672 isn't too clear about it, but all checked
authoritative servers don't provide the authority section in case of
YXDOMAIN caused by too long synthesized name.
commit f998d613872373c2fbf7088088d7464e79cc10c3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 3 18:49:59 2011 +0100
[trac505] Don't fail on too long synthesized names
Return YXDOMAIN instead.
commit c5f4af2f749808f7e8b96dca09819f69bb094031
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 3 17:35:04 2011 +0100
[trac505] Test for synthesis resulting in too long name
commit 8ddc37ac3b6229f03a1fc122ea3c1c8906cbd75b
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 12:42:39 2011 +0100
[trac505] Fix missing CNAME on DNAME/ANY
commit cac61e91646c344359a5b767d2f2042d05cc1d74
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 12:37:36 2011 +0100
[trac505] Catch a bug
commit fb4ca10d60279cc2d7da663b912dcb189849d0da
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 12:32:19 2011 +0100
[trac505] DNAME handling and CNAME synthesis
commit 59dd3fb61b265455b544407fcd8976a04f152af3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 10:48:00 2011 +0100
[trac505] Tests for query processing of DNAME
commit 65ef7a150b4562f2e80222afd7fb010cbd55ec43
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 12:31:54 2011 +0100
[trac505] Update MockZone to return DNAME
commit 026a4104701791649673a74591007e1d50167cbe
Merge: 4265faedd3e14e2f4afccd664df07a4e09e3ae7f 8909387beb99136bc5ec22574515c84e8ef526da
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jan 28 10:22:11 2011 +0100
Merge branch 'master' into work/dname/query
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/query.cc | 59 ++++++++++--
src/bin/auth/tests/query_unittest.cc | 175 +++++++++++++++++++++++++++++++---
2 files changed, 212 insertions(+), 22 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc
index e85c31a..e936c97 100644
--- a/src/bin/auth/query.cc
+++ b/src/bin/auth/query.cc
@@ -141,13 +141,56 @@ 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);
- Zone::FindResult db_result =
- result.zone->find(qname_, qtype_, target.get());
+ const Zone::FindResult db_result(result.zone->find(qname_, qtype_,
+ target.get()));
switch (db_result.code) {
+ case Zone::DNAME: {
+ // First, put the dname into the answer
+ response_.addRRset(Message::SECTION_ANSWER,
+ boost::const_pointer_cast<RRset>(db_result.rrset));
+ /*
+ * Empty DNAME should never get in, as it is impossible to
+ * create one in master file.
+ *
+ * FIXME: Other way to prevent this should be done
+ */
+ assert(db_result.rrset->getRdataCount() > 0);
+ // Get the data of DNAME
+ const rdata::generic::DNAME& dname(
+ dynamic_cast<const rdata::generic::DNAME&>(
+ db_result.rrset->getRdataIterator()->getCurrent()));
+ // The yet unmatched prefix dname
+ const Name prefix(qname_.split(0, qname_.getLabelCount() -
+ db_result.rrset->getName().getLabelCount()));
+ // If we put it together, will it be too long?
+ // (The prefix contains trailing ., which will be removed
+ if (prefix.getLength() - Name::ROOT_NAME().getLength() +
+ dname.getDname().getLength() > Name::MAX_WIRE) {
+ /*
+ * In case the synthesized name is too long, section 4.1
+ * of RFC 2672 mandates we return YXDOMAIN.
+ */
+ response_.setRcode(Rcode::YXDOMAIN());
+ return;
+ }
+ // 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_, db_result.rrset->getClass(),
+ RRType::CNAME(), db_result.rrset->getTTL()));
+ // Construct the new target by replacing the end
+ cname->addRdata(rdata::generic::CNAME(qname_.split(0,
+ qname_.getLabelCount() -
+ db_result.rrset->getName().getLabelCount()).
+ concatenate(dname.getDname())));
+ response_.addRRset(Message::SECTION_ANSWER, cname);
+ break;
+ }
case Zone::CNAME:
/*
* We don't do chaining yet. Therefore handling a CNAME is
@@ -155,10 +198,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.
@@ -184,7 +230,6 @@ 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>(db_result.rrset));
getAdditional(*result.zone, *db_result.rrset);
@@ -196,12 +241,8 @@ Query::process() const {
break;
case Zone::NXRRSET:
// Just empty answer with SOA in authority section
- response_.setRcode(Rcode::NOERROR());
putSOA(*result.zone);
break;
- case Zone::DNAME:
- // TODO : replace qname, continue lookup
- break;
}
}
}
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index 3bf4142..2d3cf03 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -75,6 +75,17 @@ const char* const cname_nxdom_txt =
// CNAME Leading out of zone
const char* const cname_out_txt =
"cnameout.example.com. 3600 IN CNAME www.example.org.\n";
+// The DNAME to do tests against
+const char* const dname_txt =
+ "dname.example.com. 3600 IN DNAME "
+ "somethinglong.dnametarget.example.com.\n";
+// Some data at the dname node (allowed by RFC 2672)
+const char* const dname_a_txt =
+ "dname.example.com. 3600 IN A 192.0.2.5\n";
+// This is not inside the zone, this is created at runtime
+const char* const synthetized_cname_txt =
+ "www.dname.example.com. 3600 IN CNAME "
+ "www.somethinglong.dnametarget.example.com.\n";
// The rest of data won't be referenced from the test cases.
const char* const other_zone_rrs =
"cnamemailer.example.com. 3600 IN CNAME www.example.com.\n"
@@ -88,13 +99,16 @@ const char* const other_zone_rrs =
// behavior.
// For simplicity, most names are assumed to be "in zone"; there's only
// one zone cut at the point of name "delegation.example.com".
-// It doesn't handle empty non terminal nodes (if we need to test such cases
-// find() should have specialized code for it).
+// Another special name is "dname.example.com". Query names under this name
+// will result in DNAME.
+// This mock zone doesn't handle empty non terminal nodes (if we need to test
+// such cases find() should have specialized code for it).
class MockZone : public Zone {
public:
MockZone() :
origin_(Name("example.com")),
delegation_name_("delegation.example.com"),
+ dname_name_("dname.example.com"),
has_SOA_(true),
has_apex_NS_(true),
rrclass_(RRClass::IN())
@@ -102,7 +116,8 @@ public:
stringstream zone_stream;
zone_stream << soa_txt << zone_ns_txt << ns_addrs_txt <<
delegation_txt << mx_txt << www_a_txt << cname_txt <<
- cname_nxdom_txt << cname_out_txt << other_zone_rrs;
+ cname_nxdom_txt << cname_out_txt << dname_txt << dname_a_txt <<
+ other_zone_rrs;
masterLoad(zone_stream, origin_, rrclass_,
boost::bind(&MockZone::loadRRset, this, _1));
@@ -131,14 +146,20 @@ private:
if (rrset->getName() == delegation_name_ &&
rrset->getType() == RRType::NS()) {
delegation_rrset_ = rrset;
+ } else if (rrset->getName() == dname_name_ &&
+ rrset->getType() == RRType::DNAME()) {
+ dname_rrset_ = rrset;
}
}
const Name origin_;
+ // Names where we delegate somewhere else
const Name delegation_name_;
+ const Name dname_name_;
bool has_SOA_;
bool has_apex_NS_;
ConstRRsetPtr delegation_rrset_;
+ ConstRRsetPtr dname_rrset_;
const RRClass rrclass_;
};
@@ -160,6 +181,10 @@ MockZone::find(const Name& name, const RRType& type,
name.compare(delegation_name_).getRelation() ==
NameComparisonResult::SUBDOMAIN)) {
return (FindResult(DELEGATION, delegation_rrset_));
+ // And under DNAME
+ } else if (name.compare(dname_name_).getRelation() ==
+ NameComparisonResult::SUBDOMAIN) {
+ return (FindResult(DNAME, dname_rrset_));
}
// normal cases. names are searched for only per exact-match basis
@@ -176,8 +201,7 @@ MockZone::find(const Name& name, const RRType& type,
// 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++)
- {
+ found_rrset != found_domain->second.end(); found_rrset++) {
// Insert RRs under the domain name into target
target->addRRset(
boost::const_pointer_cast<RRset>(found_rrset->second));
@@ -443,8 +467,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) {
@@ -465,8 +489,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) {
@@ -488,8 +512,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) {
@@ -513,8 +537,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) {
@@ -526,4 +550,129 @@ TEST_F(QueryTest, explicitCNAME_OUT) {
cname_out_txt, zone_ns_txt, ns_addrs_txt);
}
+/*
+ * Test a query under a domain with DNAME. We should get a synthetized CNAME
+ * as well as the DNAME.
+ *
+ * TODO: Once we have CNAME chaining, check it works with synthetized CNAMEs
+ * as well. This includes tests pointing inside the zone, outside the zone,
+ * pointing to NXRRSET and NXDOMAIN cases (similarly as with CNAME).
+ */
+TEST_F(QueryTest, DNAME) {
+ Query(memory_datasrc, Name("www.dname.example.com"), RRType::A(),
+ response).process();
+
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
+ (string(dname_txt) + synthetized_cname_txt).c_str(),
+ NULL, NULL);
+}
+
+/*
+ * Ask an ANY query below a DNAME. Should return the DNAME and synthetized
+ * CNAME.
+ *
+ * ANY is handled specially sometimes. We check it is not the case with
+ * DNAME.
+ */
+TEST_F(QueryTest, DNAME_ANY) {
+ Query(memory_datasrc, Name("www.dname.example.com"), RRType::ANY(),
+ response).process();
+
+ 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.
+TEST_F(QueryTest, explicitDNAME) {
+ Query(memory_datasrc, Name("dname.example.com"), RRType::DNAME(),
+ response).process();
+
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
+ dname_txt, zone_ns_txt, ns_addrs_txt);
+}
+
+/*
+ * Request a RRset at the domain with DNAME. It should not synthetize
+ * the CNAME, it should return the RRset.
+ */
+TEST_F(QueryTest, DNAME_A) {
+ Query(memory_datasrc, Name("dname.example.com"), RRType::A(),
+ response).process();
+
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 1, 3, 3,
+ dname_a_txt, zone_ns_txt, ns_addrs_txt);
+}
+
+/*
+ * Request a RRset at the domain with DNAME that is not there (NXRRSET).
+ * It should not synthetize the CNAME.
+ */
+TEST_F(QueryTest, DNAME_NX_RRSET) {
+ EXPECT_NO_THROW(Query(memory_datasrc, Name("dname.example.com"),
+ RRType::TXT(), response).process());
+
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 0, 1, 0,
+ NULL, soa_txt, NULL, mock_zone->getOrigin());
+}
+
+/*
+ * Constructing the CNAME will result in a name that is too long. This,
+ * however, should not throw (and crash the server), but respond with
+ * YXDOMAIN.
+ */
+TEST_F(QueryTest, LongDNAME) {
+ // A name that is as long as it can be
+ Name longname(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "dname.example.com.");
+ EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
+ response).process());
+
+ responseCheck(response, Rcode::YXDOMAIN(), AA_FLAG, 1, 0, 0,
+ dname_txt, NULL, NULL);
+}
+
+/*
+ * Constructing the CNAME will result in a name of maximal length.
+ * This tests that we don't reject valid one by some kind of off by
+ * one mistake.
+ */
+TEST_F(QueryTest, MaxLenDNAME) {
+ Name longname(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
+ "dname.example.com.");
+ EXPECT_NO_THROW(Query(memory_datasrc, longname, RRType::A(),
+ response).process());
+
+ // Check the answer is OK
+ responseCheck(response, Rcode::NOERROR(), AA_FLAG, 2, 0, 0,
+ NULL, NULL, NULL);
+
+ // Check that the CNAME has the maximal length.
+ bool ok(false);
+ for (RRsetIterator i(response.beginSection(Message::SECTION_ANSWER));
+ i != response.endSection(Message::SECTION_ANSWER); ++ i) {
+ if ((*i)->getType() == RRType::CNAME()) {
+ ok = true;
+ RdataIteratorPtr ci((*i)->getRdataIterator());
+ ASSERT_FALSE(ci->isLast()) << "The CNAME is empty";
+ /*
+ * Does anybody have a clue why, if the Name::MAX_WIRE is put
+ * directly inside ASSERT_EQ, it fails to link and complains
+ * it is unresolved external?
+ */
+ const size_t max_len(Name::MAX_WIRE);
+ ASSERT_EQ(max_len, dynamic_cast<const rdata::generic::CNAME&>(
+ ci->getCurrent()).getCname().getLength());
+ }
+ }
+ EXPECT_TRUE(ok) << "The synthetized CNAME not found";
+}
+
}
More information about the bind10-changes
mailing list