Commit bbb0031f authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac554] Merge branch 'master' into trac554

Conflicts:
	src/lib/asiolink/Makefile.am
	src/lib/asiolink/asiolink.cc
	src/lib/asiolink/internal/udpdns.h
	src/lib/asiolink/tests/udp_query_unittest.cc
	src/lib/asiolink/udpdns.cc
parents ad91697c 0cc21b60
166. [func] jelte
The resolver now sends back a SERVFAIL when there is a client
timeout (timeout_client config setting), but it will not stop
resolving (until there is a lookup timeout or a result).
(Trac #497 and #489, git af0e5cd93bebb27cb5c4457f7759d12c8bf953a6)
165. [func] jelte
The resolver now handles CNAMEs, it will follow them, and include
them in the answer. The maximum length of CNAME chains that is
supported is 16.
(Trac #497, git af0e5cd93bebb27cb5c4457f7759d12c8bf953a6)
164. [bug] y-aharen
IntervalTimer: Modified the interface to accept interval in
milliseconds. It shortens the time of the tests of IntervalTimer.
(Trac #452, git c9f6acc81e24c4b8f0eb351123dc7b43f64e0914)
163. [func] vorner
The pimpl design pattern is used in UDPServer, with a shared pointer. This
makes it smaller to copy (which is done a lot as a sideeffect of being
coroutine) and speeds applications of this class (notably b10-auth) up by
around 10%.
(Trac #537, git 94cb95b1d508541201fc064302ba836164d3cbe6)
162. [func] stephen
Added C++ logging, allowing logging at different severities.
Code specifies the message to be logged via a symbol, and the
logging code picks up the message from an in-built dictionary.
The contents of the dictionary can be replaced at run-time by
locale-specific messages. A message compiler program is provided
to create message header files and supply the default messages.
(Trac #438, git 7b1606cea7af15dc71f5ec1d70d958b00aa98af7)
161. [func] stephen
Added ResponseScrubber class to examine response from
a server and to remove out-of-bailiwick RRsets. Also
does cross-section checks to ensure consistency.
(Trac #496, git b9296ca023cc9e76cda48a7eeebb0119166592c5)
160. [func] jelte
Updated the resolver to take 3 different timeout values;
timeout_query for outstanding queries we sent while resolving
......
......@@ -363,6 +363,57 @@ if test "$lcov" != "no"; then
fi
AC_SUBST(USE_LCOV)
# Configure log4cxx header and library path
#
# If explicitly specified, use it.
AC_ARG_WITH([log4cxx],
AC_HELP_STRING([--with-log4cxx=PATH],
[specify directory where log4cxx is installed]),
[
log4cxx_include_path="${withval}/include";
log4cxx_library_path="${withval}/lib"
])
# This is an urgent fix to avoid regression due to log4cxx on some
# platforms. It should be cleaned up with a better fix.
if test "X$with_log4cxx" != "Xno"; then
# If not specified, try some common paths. These default to
# /usr/include and /usr/lib if not found
if test -z "$with_log4cxx"; then
log4cxxdirs="/usr/local /usr/pkg /opt /opt/local"
for d in $log4cxxdirs
do
if test -d $d/include/log4cxx; then
log4cxx_include_path=$d/include
log4cxx_library_path=$d/lib
break
fi
done
fi
CPPFLAGS_SAVES="$CPPFLAGS"
if test "${log4cxx_include_path}" ; then
LOG4CXX_INCLUDES="-I${log4cxx_include_path}"
CPPFLAGS="$CPPFLAGS $LOG4CXX_INCLUDES"
fi
AC_CHECK_HEADER([log4cxx/logger.h],, AC_MSG_ERROR([Missing log4cxx header files.]))
CPPFLAGS="$CPPFLAGS_SAVES"
AC_SUBST(LOG4CXX_INCLUDES)
LOG4CXX_LDFLAGS="-llog4cxx";
if test "${log4cxx_library_path}"; then
LOG4CXX_LDFLAGS="-L${log4cxx_library_path} -llog4cxx"
fi
AC_SUBST(LOG4CXX_LDFLAGS)
# The following two lines are part of the urgent fix, and should be cleaned
# up with a better fix.
fi
AM_CONDITIONAL(USE_LOG4CXX, test "X${with_log4cxx}" != "Xno")
#
# Configure Boost header path
#
......@@ -522,6 +573,9 @@ AC_SUBST(MULTITHREADING_FLAG)
#
CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/asio"
#
# Use our 'coroutine' header from ext
CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine"
#
# Disable threads: Currently we don't use them.
CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_THREADS=1"
#
......@@ -615,8 +669,6 @@ AC_CONFIG_FILES([Makefile
src/lib/Makefile
src/lib/asiolink/Makefile
src/lib/asiolink/tests/Makefile
src/lib/asiolink/internal/Makefile
src/lib/asiolink/internal/tests/Makefile
src/lib/bench/Makefile
src/lib/bench/example/Makefile
src/lib/bench/tests/Makefile
......@@ -652,6 +704,10 @@ AC_CONFIG_FILES([Makefile
src/lib/datasrc/tests/Makefile
src/lib/xfr/Makefile
src/lib/log/Makefile
src/lib/log/compiler/Makefile
src/lib/log/tests/Makefile
src/lib/resolve/Makefile
src/lib/resolve/tests/Makefile
src/lib/testutils/Makefile
src/lib/testutils/testdata/Makefile
src/lib/nsas/Makefile
......@@ -711,6 +767,7 @@ AC_OUTPUT([doc/version.ent
src/lib/dns/tests/testdata/gen-wiredata.py
src/lib/cc/session_config.h.pre
src/lib/cc/tests/session_unittests_config.h
src/lib/log/tests/run_time_init_test.sh
], [
chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
chmod +x src/bin/xfrin/run_b10-xfrin.sh
......@@ -734,6 +791,7 @@ AC_OUTPUT([doc/version.ent
chmod +x src/bin/msgq/tests/msgq_test
chmod +x src/lib/dns/gen-rdatacode.py
chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
chmod +x src/lib/log/tests/run_time_init_test.sh
])
AC_OUTPUT
......@@ -761,6 +819,8 @@ dnl includes too
${PYTHON_LDFLAGS}
${PYTHON_LIB}
Boost: ${BOOST_INCLUDES}
log4cxx: ${LOG4CXX_INCLUDES}
${LOG4CXX_LDFLAGS}
SQLite: $SQLITE_CFLAGS
$SQLITE_LIBS
......
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>BIND 10 Guide</title><link rel="stylesheet" href="./bind10-guide.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><meta name="description" content="BIND 10 is a Domain Name System (DNS) suite managed by Internet Systems Consortium (ISC). It includes DNS libraries and modular components for controlling authoritative and recursive DNS servers. This is the reference guide for BIND 10 version 20101201. The most up-to-date version of this document, along with other documents for BIND 10, can be found at ."></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="BIND 10 Guide"><div class="titlepage"><div><div><h1 class="title"><a name="id1168230298903"></a>BIND 10 Guide</h1></div><div><h2 class="subtitle">Administrator Reference for BIND 10</h2></div><div><p class="releaseinfo">This is the reference guide for BIND 10 version
20101201.</p></div><div><p class="copyright">Copyright © 2010 Internet Systems Consortium, Inc.</p></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>BIND 10 is a Domain Name System (DNS) suite managed by
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>BIND 10 Guide</title><link rel="stylesheet" href="./bind10-guide.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><meta name="description" content="BIND 10 is a Domain Name System (DNS) suite managed by Internet Systems Consortium (ISC). It includes DNS libraries and modular components for controlling authoritative and recursive DNS servers. This is the reference guide for BIND 10 version 20110120. The most up-to-date version of this document, along with other documents for BIND 10, can be found at ."></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="BIND 10 Guide"><div class="titlepage"><div><div><h1 class="title"><a name="id1168230298903"></a>BIND 10 Guide</h1></div><div><h2 class="subtitle">Administrator Reference for BIND 10</h2></div><div><p class="releaseinfo">This is the reference guide for BIND 10 version
20110120.</p></div><div><p class="copyright">Copyright © 2010 Internet Systems Consortium, Inc.</p></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>BIND 10 is a Domain Name System (DNS) suite managed by
Internet Systems Consortium (ISC). It includes DNS libraries
and modular components for controlling authoritative and
recursive DNS servers.
</p><p>
This is the reference guide for BIND 10 version 20101201.
This is the reference guide for BIND 10 version 20110120.
The most up-to-date version of this document, along with
other documents for BIND 10, can be found at <a class="ulink" href="http://bind10.isc.org/docs" target="_top">http://bind10.isc.org/docs</a>. </p></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="#intro">1. Introduction</a></span></dt><dd><dl><dt><span class="section"><a href="#id1168230299042">Supported Platforms</a></span></dt><dt><span class="section"><a href="#id1168230299068">Required Software</a></span></dt><dt><span class="section"><a href="#starting_stopping">Starting and Stopping the Server</a></span></dt><dt><span class="section"><a href="#managing_once_running">Managing BIND 10</a></span></dt></dl></dd><dt><span class="chapter"><a href="#installation">2. Installation</a></span></dt><dd><dl><dt><span class="section"><a href="#id1168230284843">Building Requirements</a></span></dt><dt><span class="section"><a href="#quickstart">Quick start</a></span></dt><dt><span class="section"><a href="#install">Installation from source</a></span></dt><dd><dl><dt><span class="section"><a href="#id1168230285029">Download Tar File</a></span></dt><dt><span class="section"><a href="#id1168230285048">Retrieve from Git</a></span></dt><dt><span class="section"><a href="#id1168230285109">Configure before the build</a></span></dt><dt><span class="section"><a href="#id1168230285206">Build</a></span></dt><dt><span class="section"><a href="#id1168230285222">Install</a></span></dt><dt><span class="section"><a href="#id1168230285245">Install Hierarchy</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#bind10">3. Starting BIND10 with <span class="command"><strong>bind10</strong></span></a></span></dt><dd><dl><dt><span class="section"><a href="#start">Starting BIND 10</a></span></dt></dl></dd><dt><span class="chapter"><a href="#msgq">4. Command channel</a></span></dt><dt><span class="chapter"><a href="#cfgmgr">5. Configuration manager</a></span></dt><dt><span class="chapter"><a href="#cmdctl">6. Remote control daemon</a></span></dt><dd><dl><dt><span class="section"><a href="#cmdctl.spec">Configuration specification for b10-cmdctl</a></span></dt></dl></dd><dt><span class="chapter"><a href="#bindctl">7. Control and configure user interface</a></span></dt><dt><span class="chapter"><a href="#authserver">8. Authoritative Server</a></span></dt><dd><dl><dt><span class="section"><a href="#id1168230285821">Server Configurations</a></span></dt><dt><span class="section"><a href="#id1168230285886">Data Source Backends</a></span></dt><dt><span class="section"><a href="#id1168230285917">Loading Master Zones Files</a></span></dt></dl></dd><dt><span class="chapter"><a href="#xfrin">9. Incoming Zone Transfers</a></span></dt><dt><span class="chapter"><a href="#xfrout">10. Outbound Zone Transfers</a></span></dt><dt><span class="chapter"><a href="#zonemgr">11. Secondary Manager</a></span></dt><dt><span class="chapter"><a href="#resolverserver">12. Recursive Name Server</a></span></dt><dt><span class="chapter"><a href="#statistics">13. Statistics</a></span></dt></dl></div><div class="chapter" title="Chapter 1. Introduction"><div class="titlepage"><div><div><h2 class="title"><a name="intro"></a>Chapter 1. Introduction</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id1168230299042">Supported Platforms</a></span></dt><dt><span class="section"><a href="#id1168230299068">Required Software</a></span></dt><dt><span class="section"><a href="#starting_stopping">Starting and Stopping the Server</a></span></dt><dt><span class="section"><a href="#managing_once_running">Managing BIND 10</a></span></dt></dl></div><p>
BIND is the popular implementation of a DNS server, developer
......@@ -13,7 +13,7 @@
and provides a modular environment for serving and maintaining DNS.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
This guide covers the experimental prototype of
BIND 10 version 20101201.
BIND 10 version 20110120.
</p></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
BIND 10 provides a EDNS0- and DNSSEC-capable
authoritative DNS server and a forwarding DNS server.
......
......@@ -982,6 +982,8 @@ accounts_file
<para>
The control commands are:
print_settings
<!-- TODO: remove that -->
shutdown
</para>
<!-- TODO -->
......
......@@ -354,7 +354,7 @@ AuthSrv::setMemoryDataSrc(const isc::dns::RRClass& rrclass,
uint32_t
AuthSrv::getStatisticsTimerInterval() const {
return (impl_->statistics_timer_.getInterval());
return (impl_->statistics_timer_.getInterval() / 1000);
}
void
......@@ -362,11 +362,17 @@ AuthSrv::setStatisticsTimerInterval(uint32_t interval) {
if (interval == impl_->statistics_timer_.getInterval()) {
return;
}
if (interval > 86400) {
// It can't occur since the value is checked in
// statisticsIntervalConfig::build().
isc_throw(InvalidParameter, "Too long interval: " << interval);
}
if (interval == 0) {
impl_->statistics_timer_.cancel();
} else {
impl_->statistics_timer_.setupTimer(
boost::bind(&AuthSrv::submitStatistics, this), interval);
impl_->statistics_timer_.setup(boost::bind(&AuthSrv::submitStatistics,
this),
interval * 1000);
}
if (impl_->verbose_mode_) {
if (interval == 0) {
......
......@@ -318,7 +318,8 @@ public:
/// If the specified value is non 0, the \c AuthSrv object will submit
/// its statistics to the statistics module every \c interval seconds.
/// If it's 0, and \c AuthSrv currently submits statistics, the submission
/// will be disabled.
/// will be disabled. \c interval must be equal to or shorter than 86400
/// seconds (1 day).
///
/// This method should normally not throw an exception; however, its
/// underlying library routines may involve resource allocation, and
......
......@@ -134,7 +134,7 @@
<listitem><para>
The port number it listens on.
The default is 5300.</para>
<note><simpara>The Y1 prototype runs on all interfaces
<note><simpara>This prototype runs on all interfaces
and on this nonstandard port.</simpara></note>
</listitem>
</varlistentry>
......
......@@ -20,5 +20,6 @@ query_bench_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la
query_bench_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
query_bench_LDADD += $(top_builddir)/src/lib/cc/libcc.la
query_bench_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
query_bench_LDADD += $(top_builddir)/src/lib/log/liblog.la
query_bench_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
query_bench_LDADD += $(SQLITE_LIBS)
......@@ -179,9 +179,14 @@ public:
virtual void build(ConstElementPtr config_value) {
const int32_t config_interval = config_value->intValue();
if (config_interval < 0) {
isc_throw(AuthConfigError, "negative statistics-interval value: "
isc_throw(AuthConfigError, "Negative statistics interval value: "
<< config_interval);
}
if (config_interval > 86400) {
isc_throw(AuthConfigError, "Statistics interval value "
<< config_interval
<< " must be equal to or shorter than 86400");
}
interval_ = config_interval;
}
virtual void commit() {
......
......@@ -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;
}
}
}
......
......@@ -44,6 +44,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
endif
noinst_PROGRAMS = $(TESTS)
......@@ -98,7 +98,7 @@ AuthConmmandTest::stopServer() {
TEST_F(AuthConmmandTest, shutdown) {
asiolink::IntervalTimer itimer(server.getIOService());
itimer.setupTimer(boost::bind(&AuthConmmandTest::stopServer, this), 1);
itimer.setup(boost::bind(&AuthConmmandTest::stopServer, this), 1);
server.getIOService().run();
EXPECT_EQ(0, rcode);
}
......
......@@ -365,5 +365,9 @@ TEST_F(StatisticsIntervalConfigTest, badInterval) {
EXPECT_THROW(parser->build(Element::fromJSON("2.5")),
isc::data::TypeError);
EXPECT_THROW(parser->build(Element::fromJSON("-1")), AuthConfigError);
// bounds check: interval value must be equal to or shorter than
// 86400 seconds (1 day)
EXPECT_NO_THROW(parser->build(Element::fromJSON("86400")));
EXPECT_THROW(parser->build(Element::fromJSON("86401")), AuthConfigError);
}
}
......@@ -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());
}
/*