Commit 1d6b96dd authored by chenzhengzhang's avatar chenzhengzhang
Browse files

Merge branch 'master' into trac699

parents 681b1839 ece21d1b
209. [func] jelte
Resolver now uses the NSAS when looking for a nameserver to
query for any specific zone. This also includes keeping track of
the RTT for that nameserver.
(Trac #495, git 76022a7e9f3ff339f0f9f10049aa85e5784d72c5)
208. [bug]* jelte
Resolver now answers REFUSED on queries that are not for class IN.
This includes the various CH TXT queries, which will be added
later.
(git 012f9e78dc611c72ea213f9bd6743172e1a2ca20)
207. [func] jelte
Resolver now starts listening on localhost:53 if no configuration
is set.
......
To build "configure" file:
autoreconf
If using git (not the tarball), build the "configure" file:
autoreconf --install
To then build from source:
./configure
......
......@@ -15,9 +15,9 @@ five year plan are described here:
This release includes the bind10 master process, b10-msgq message
bus, b10-auth authoritative DNS server (with SQLite3 and in-memory
backends), b10-resolver forwarding DNS server, b10-cmdctl remote
control daemon, b10-cfgmgr configuration manager, b10-xfrin AXFR
inbound service, b10-xfrout outgoing AXFR service, b10-zonemgr
backends), b10-resolver recursive or forwarding DNS server, b10-cmdctl
remote control daemon, b10-cfgmgr configuration manager, b10-xfrin
AXFR inbound service, b10-xfrout outgoing AXFR service, b10-zonemgr
secondary manager, b10-stats statistics collection and reporting
daemon, and a new libdns++ library for C++ with a python wrapper.
......
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT(bind10-devel, 20110224, bind10-dev@isc.org)
AC_INIT(bind10-devel, 20110322, bind10-dev@isc.org)
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
......
This diff is collapsed.
......@@ -20,6 +20,9 @@
.\" -----------------------------------------------------------------
.SH "NAME"
b10-cfgmgr \- Configuration manager
.SH "SYNOPSIS"
.HP \w'\fBb10\-cfgmgr\fR\ 'u
\fBb10\-cfgmgr\fR [\fB\-c\fR\fB\fIconfig\-filename\fR\fR] [\fB\-p\fR\fB\fIdata_path\fR\fR]
.SH "DESCRIPTION"
.PP
The
......@@ -43,8 +46,21 @@ The daemon may be cleanly stopped by sending the SIGTERM signal to the process\&
When it exits, it saves its current configuration to
/usr/local/var/bind10\-devel/b10\-config\&.db\&.
.SH "ARGUMENTS"
.PP
The daemon has no command line options\&. It ignores any arguments\&.
The arguments are as follows:
.PP
\fB\-c\fR\fIconfig\-filename\fR, \fB\-\-config\-filename\fR \fIconfig\-filename\fR
.RS 4
The configuration database filename to use\&. Can be either absolute or relative to data path\&.
.sp
Defaults to b10\-config\&.db
.RE
.PP
\fB\-p\fR\fIdata\-path\fR, \fB\-\-data\-path\fR \fIdata\-path\fR
.RS 4
The path where BIND 10 looks for files\&. The configuration file is looked for here, if it is relative\&. If it is absolute, the path is ignored\&.
.RE
.SH "FILES"
.PP
/usr/local/var/bind10\-devel/b10\-config\&.db
......
......@@ -84,10 +84,7 @@
<!-- TODO: does it periodically save configuration? -->
</para>
<para>
The daemon has no command line options. It ignores any arguments.
<!-- TODO: add a verbose or quiet switch so it is not so noisy -->
</para>
</refsect1>
<refsect1>
......
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
......@@ -117,7 +117,7 @@ class SendNonblock(unittest.TestCase):
Tests that the whole thing will not get blocked if someone does not read.
"""
def terminate_check(self, task, timeout = 10):
def terminate_check(self, task, timeout=30):
"""
Runs task in separate process (task is a function) and checks
it terminates sooner than timeout.
......@@ -194,7 +194,7 @@ class SendNonblock(unittest.TestCase):
length = len(data)
queue_pid = os.fork()
if queue_pid == 0:
signal.alarm(30)
signal.alarm(120)
msgq.setup_poller()
msgq.register_socket(queue)
msgq.run()
......
......@@ -457,6 +457,9 @@ Resolver::processMessage(const IOMessage& io_message,
} else if (qtype == RRType::IXFR()) {
makeErrorMessage(query_message, answer_message,
buffer, Rcode::NOTIMP());
} else if (question->getClass() != RRClass::IN()) {
makeErrorMessage(query_message, answer_message,
buffer, Rcode::REFUSED());
} else {
// The RecursiveQuery object will post the "resume" event to the
// DNSServer when an answer arrives, so we don't have to do it now.
......
# Copyright (C) 2010 CZ NIC
# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
#!@PYTHON@
# Copyright (C) 2010 Internet Systems Consortium.
# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
// Copyright (C) 2010 CZ NIC
// Copyed from other version of auth/asiolink.cc which is:
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
......
......@@ -144,6 +144,7 @@ class SimpleClient : public ServerStopper {
{
wait_for_response_timer_.reset(new deadline_timer(service));
received_data_ = new char[MAX_DATA_LEN];
received_data_len_ = 0;
wait_server_time_out_ = wait_server_time_out;
}
......
......@@ -21,6 +21,7 @@ EXTRA_DIST += data22_6.data
EXTRA_DIST += data22_7.data
EXTRA_DIST += data22_8.data
EXTRA_DIST += data22_9.data
EXTRA_DIST += data22_10.data
EXTRA_DIST += spec1.spec
EXTRA_DIST += spec2.spec
EXTRA_DIST += spec3.spec
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
......
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011 CZ NIC
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
......
......@@ -158,7 +158,7 @@ The symbols define the keys in the global message dictionary.
The namespace enclosing the symbols is set by the $NAMESPACE directive.
The "PREFIX_" part of the symbol name is the string defined in the $PREFIX
the argument to the directive. So "$PREFIX MSG_" would prefix the identifer
the argument to the directive. So "$PREFIX MSG_" would prefix the identifier
ABC with "MSG_" to give the symbol MSG_ABC. Similarly "$PREFIX E" would
prefix it with "E" to give the symbol EABC. If no $PREFIX is given, no
prefix appears (so the symbol in this example would be ABC).
......@@ -330,7 +330,7 @@ When logging events, make a distinction between events related to the server
and events related to DNS messages received. Caution needs to be exercised
with the latter as, if the logging is enabled in the normal course of events,
such logging could be a denial of service vector. For example, suppose that
the main authoritiative service logger were to log both zone loading and
the main authoritative service logger were to log both zone loading and
unloading as INFO and a warning message if it received an invalid packet. An
attacker could make the INFO messages unusable by flooding the server with
malformed packets.
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -38,7 +38,7 @@ extern std::string dprefix;
* places where logging should happen. When it is removed, compiler will do
* our work of finding the places.
*
* The only thing it does is printing the dprogram prefix, message and
* The only thing it does is printing the program prefix, message and
* a newline if denabled is true.
*
* There are no tests for this function, since it is only temporary and
......
......@@ -73,7 +73,7 @@ public:
/// deletion of the underlying log4cxx data structures when the logger is
/// deleted. Setting it false for externally-declared loggers inhibits
/// their deletion; so at program exit the memory is not reclaimed during
/// program rundown, only when the process is delected. Setting it true
/// program rundown, only when the process is selected. Setting it true
/// for loggers that will be deleted in the normal running of the program
/// enables their deletion - which causes no issues as the problem only
/// manifests itself during program rundown.
......
......@@ -21,7 +21,7 @@
/// appropriate).
/// b) Reads in the local message file is one has been supplied.
///
/// These functions will be replaced once the code has bneen written to obtain
/// These functions will be replaced once the code has been written to obtain
/// the logging parameters from the configuration database.
#include <algorithm>
......
......@@ -34,7 +34,7 @@ namespace log {
///
/// \param root Name of the root logger
/// \param severity Severity at which to log
/// \param dbglevel Debug severiy (ignored if "severity" is not "DEBUG")
/// \param dbglevel Debug severity (ignored if "severity" is not "DEBUG")
/// \param file Name of the local message file.
void initLogger(const std::string& root, isc::log::Severity severity,
int dbglevel, const char* file);
......
......@@ -109,5 +109,5 @@ MessageDictionary::globalDictionary() {
} // namspace log
} // namespace log
} // namespace isc
......@@ -186,7 +186,7 @@ MessageReader::parseNamespace(const vector<string>& tokens) {
// Process message. By the time this method is called, the line has been
// stripped of leading and trailing spaces, and we believe that it is a line
// defining a message. The first token on the line is convered to uppercase
// defining a message. The first token on the line is converted to uppercase
// and becomes the message ID; the rest of the line is the message text.
void
......
......@@ -37,12 +37,12 @@ DUPMSGID duplicate message ID (%s) in compiled code
DUPLNS duplicate $NAMESPACE directive found
+ When reading a message file, more than one $NAMESPACE directive was found. In
+ this version of the code, such a condition is regarded as an error and the
+ read will be abandonded.
+ read will be abandoned.
DUPLPRFX duplicate $PREFIX directive found
+ When reading a message file, more than one $PREFIX directive was found. In
+ this version of the code, such a condition is regarded as an error and the
+ read will be abandonded.
+ read will be abandoned.
IDNOTFND could not replace message for '%s': no such message identification
+ During start-up a local message file was read. A line with the listed
......@@ -53,7 +53,7 @@ IDNOTFND could not replace message for '%s': no such message identification
+ identification has been removed.
+
+ This message may appear a number of times in the file, once for every such
+ unknown mnessage identification.
+ unknown message identification.
MSGRDERR error reading from message file %s: %s
+ The specified error was encountered reading from the named message file.
......@@ -69,9 +69,9 @@ NSEXTRARG $NAMESPACE directive has too many arguments
NSINVARG $NAMESPACE directive has an invalid argument ('%s')
+ The $NAMESPACE argument should be a valid C++ namespace. The reader does a
+ cursory check on its validity, checking that the characters in the namspace
+ cursory check on its validity, checking that the characters in the namespace
+ are correct. The error is generated when the reader finds an invalid
+ character. (Valid are alphanumeric characters, underscroes and colons.)
+ character. (Valid are alphanumeric characters, underscores and colons.)
NOMSGTXT a line containing a message ID ('%s') and nothing else was found
+ Message definitions comprise lines starting with a message identification (a
......
......@@ -79,7 +79,7 @@ std::vector<std::string> tokens(const std::string& text,
///
/// Used in uppercase() to pass as an argument to std::transform(). The
/// function std::toupper() can't be used as it takes an "int" as its argument;
/// this confuses the template expansion mechanism because defererencing a
/// this confuses the template expansion mechanism because dereferencing a
/// string::iterator returns a char.
///
/// \param chr Character to be upper-cased.
......@@ -104,7 +104,7 @@ inline void uppercase(std::string& text) {
///
/// Used in lowercase() to pass as an argument to std::transform(). The
/// function std::tolower() can't be used as it takes an "int" as its argument;
/// this confuses the template expansion mechanism because defererencing a
/// this confuses the template expansion mechanism because dereferencing a
/// string::iterator returns a char.
///
/// \param chr Character to be lower-cased.
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
......@@ -174,6 +174,9 @@ NameserverEntry::updateAddressRTTAtIndex(uint32_t rtt, size_t index,
uint32_t old_rtt = addresses_[family][index].getRTT();
uint32_t new_rtt = (uint32_t)(old_rtt * UPDATE_RTT_ALPHA + rtt *
(1 - UPDATE_RTT_ALPHA));
if (new_rtt == 0) {
new_rtt = 1;
}
addresses_[family][index].setRTT(new_rtt);
}
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
# Copyright (C) 2009 Internet Systems Consortium.
# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
# Copyright (C) 2010 CZ NIC
# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
# Copyright (C) 2010 CZ NIC
# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
# Copyright (C) 2010 CZ NIC
# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
# Copyright (C) 2010 CZ NIC
# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
......
......@@ -27,6 +27,7 @@
#include <dns/question.h>
#include <dns/message.h>
#include <dns/opcode.h>
#include <dns/exceptions.h>
#include <resolve/resolve.h>
#include <cache/resolver_cache.h>
......@@ -280,6 +281,7 @@ private:
if (test_server_.second != 0) {
dlog("Sending upstream query (" + question_.toText() +
") to test server at " + test_server_.first);
gettimeofday(&current_ns_qsent_time, NULL);
++outstanding_events_;
IOFetch query(protocol, io_, question_,
test_server_.first,
......@@ -292,6 +294,7 @@ private:
dlog("Sending upstream query (" + question_.toText() +
") to " + upstream_->at(serverIndex).first);
++outstanding_events_;
gettimeofday(&current_ns_qsent_time, NULL);
IOFetch query(protocol, io_, question_,
upstream_->at(serverIndex).first,
upstream_->at(serverIndex).second, buffer_, this,
......@@ -607,34 +610,57 @@ public:
// Update the NSAS with the time it took
struct timeval cur_time;
gettimeofday(&cur_time, NULL);
uint32_t rtt;
if (cur_time.tv_sec >= current_ns_qsent_time.tv_sec ||
cur_time.tv_usec > current_ns_qsent_time.tv_usec) {
uint32_t rtt = 0;
// Only calculate RTT if it is positive
if (cur_time.tv_sec > current_ns_qsent_time.tv_sec ||
(cur_time.tv_sec == current_ns_qsent_time.tv_sec &&
cur_time.tv_usec > current_ns_qsent_time.tv_usec)) {
rtt = 1000 * (cur_time.tv_sec - current_ns_qsent_time.tv_sec);
rtt += (cur_time.tv_usec - current_ns_qsent_time.tv_usec) / 1000;
} else {
rtt = 1;
}
dlog("RTT: " + boost::lexical_cast<std::string>(rtt));
current_ns_address.updateRTT(rtt);
Message incoming(Message::PARSE);
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
incoming.fromWire(ibuf);
buffer_->clear();
if (recursive_mode() &&
incoming.getRcode() == Rcode::NOERROR()) {
done_ = handleRecursiveAnswer(incoming);
} else {
isc::resolve::copyResponseMessage(incoming, answer_message_);
done_ = true;
}
if (done_) {
callCallback(true);
stop();
try {
Message incoming(Message::PARSE);
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
incoming.fromWire(ibuf);
buffer_->clear();
if (recursive_mode() &&
incoming.getRcode() == Rcode::NOERROR()) {
done_ = handleRecursiveAnswer(incoming);
} else {
isc::resolve::copyResponseMessage(incoming, answer_message_);
done_ = true;
}
if (done_) {
callCallback(true);
stop();
}
} catch (const isc::dns::DNSProtocolError& dpe) {
dlog("DNS Protocol error in answer for " +
question_.toText() + " " +
question_.getType().toText() + ": " +
dpe.what());
// Right now, we treat this similar to timeouts
// (except we don't store RTT)
// We probably want to make this an integral part
// of the fetch data process. (TODO)
if (retries_--) {
dlog("Retrying");
send();
} else {
dlog("Giving up");
if (!callback_called_) {
makeSERVFAIL();
callCallback(true);
}
stop();
}
}
} else if (!done_ && retries_--) {
// Query timed out, but we have some retries, so send again
......
// Copyright (C) 2010 CZ NIC
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......
......@@ -107,8 +107,10 @@ public:
UDP_ROOT = 1, ///< Query root server over UDP
UDP_ORG = 2, ///< Query ORG server over UDP
TCP_ORG = 3, ///< Query ORG server over TCP
UDP_EXAMPLE_ORG = 4, ///< Query EXAMPLE.ORG server over UDP
COMPLETE = 5 ///< Query is complete
UDP_EXAMPLE_ORG_BAD = 4, ///< Query EXAMPLE.ORG server over UDP
///< (return malformed packet)
UDP_EXAMPLE_ORG = 5, ///< Query EXAMPLE.ORG server over UDP
COMPLETE = 6 ///< Query is complete
};
// Common stuff
......@@ -289,6 +291,10 @@ public:
Message msg(Message::RENDER);
setCommonMessage(msg, qid);
// In the case of UDP_EXAMPLE_ORG_BAD, we shall mangle the
// response
bool mangle_response = false;
// Set up state-dependent bits:
switch (expected_) {
case UDP_ROOT:
......@@ -309,6 +315,14 @@ public:
expected_ = TCP_ORG;
break;
case UDP_EXAMPLE_ORG_BAD:
// Return the answer to the question.
setAnswerWwwExampleOrg(msg);
// Mangle the response to enfore another query
mangle_response = true;
expected_ = UDP_EXAMPLE_ORG;
break;
case UDP_EXAMPLE_ORG:
// Return the answer to the question.
setAnswerWwwExampleOrg(msg);
......@@ -324,6 +338,12 @@ public:
MessageRenderer renderer(*udp_send_buffer_);
msg.toWire(renderer);
if (mangle_response) {
// mangle the packet a bit
// set additional to one more
udp_send_buffer_->writeUint8At(3, 11);
}
// Return a message back to the IOFetch object (after setting the
// expected length of data for the check in the send handler).
udp_length_ = udp_send_buffer_->getLength();
......@@ -454,7 +474,7 @@ public:
// readiness for the next read. (If any - at present, there is only
// one read in the test, although extensions to this test suite could
// change that.)
expected_ = UDP_EXAMPLE_ORG;
expected_ = UDP_EXAMPLE_ORG_BAD;
tcp_cumulative_ = 0;
// Unless we go through a callback loop we cannot simply use
......
......@@ -31,7 +31,7 @@ grep 192.0.2.1 dig.out.$n > /dev/null || status=1
if [ $status != 0 ]; then echo "I:failed"; fi
n=`expr $n + 1`
echo "I:Checking BIND 10 statistics after a pose ($n)"
echo "I:Checking BIND 10 statistics after a pause ($n)"
# wait for 2sec to make sure b10-stats gets the latest statistics.
# note that we set statistics-interval to 1.
sleep 2
......@@ -67,7 +67,7 @@ grep 192.0.2.1 dig.out.$n > /dev/null || status=1
if [ $status != 0 ]; then echo "I:failed"; fi
n=`expr $n + 1`
echo "I:Rechecking BIND 10 statistics after a pose ($n)"
echo "I:Rechecking BIND 10 statistics after a pause ($n)"
sleep 2
echo 'Stats show
' | $RUN_BINDCTL \
......