Browse Source

Merge branch 'master' into trac699

chenzhengzhang 14 years ago
parent
commit
1d6b96dd3f
44 changed files with 181 additions and 116 deletions
  1. 12 0
      ChangeLog
  2. 2 2
      INSTALL
  3. 3 3
      README
  4. 1 1
      configure.ac
  5. 36 40
      doc/guide/bind10-guide.html
  6. 17 1
      src/bin/cfgmgr/b10-cfgmgr.8
  7. 0 3
      src/bin/cfgmgr/b10-cfgmgr.xml
  8. 0 1
      src/bin/cmdctl/cmdctl.py.in
  9. 2 2
      src/bin/msgq/tests/msgq_test.py
  10. 3 0
      src/bin/resolver/resolver.cc
  11. 1 1
      src/bin/tests/process_rename_test.py.in
  12. 0 1
      src/bin/xfrin/xfrin.py.in
  13. 0 1
      src/bin/xfrout/xfrout.py.in
  14. 0 1
      src/bin/zonemgr/zonemgr.py.in
  15. 0 2
      src/lib/asiolink/io_socket.cc
  16. 1 0
      src/lib/asiolink/tests/dns_server_unittest.cc
  17. 1 0
      src/lib/config/tests/testdata/Makefile.am
  18. 0 1
      src/lib/datasrc/result.h
  19. 0 1
      src/lib/datasrc/tests/memory_datasrc_unittest.cc
  20. 0 1
      src/lib/datasrc/zone.h
  21. 2 2
      src/lib/log/README
  22. 1 1
      src/lib/log/dummylog.cc
  23. 2 2
      src/lib/log/dummylog.h
  24. 1 1
      src/lib/log/logger.h
  25. 1 1
      src/lib/log/logger_support.cc
  26. 1 1
      src/lib/log/logger_support.h
  27. 1 1
      src/lib/log/message_dictionary.cc
  28. 1 1
      src/lib/log/message_reader.cc
  29. 5 5
      src/lib/log/messagedef.mes
  30. 2 2
      src/lib/log/strutil.h
  31. 1 1
      src/lib/nsas/fetchable.h
  32. 1 1
      src/lib/nsas/nameserver_address.cc
  33. 3 0
      src/lib/nsas/nameserver_entry.cc
  34. 1 1
      src/lib/nsas/tests/fetchable_unittest.cc
  35. 1 1
      src/lib/nsas/zone_entry.cc
  36. 0 1
      src/lib/python/isc/config/ccsession.py
  37. 1 1
      src/lib/python/isc/net/parse.py
  38. 1 1
      src/lib/python/isc/net/tests/parse_test.py
  39. 1 1
      src/lib/python/isc/util/process.py
  40. 1 1
      src/lib/python/isc/util/tests/process_test.py
  41. 48 22
      src/lib/resolve/recursive_query.cc
  42. 1 1
      src/lib/resolve/resolver_interface.h
  43. 23 3
      src/lib/resolve/tests/recursive_query_unittest_2.cc
  44. 2 2
      tests/system/bindctl/tests.sh

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+  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.

+ 2 - 2
INSTALL

@@ -1,5 +1,5 @@
-To build "configure" file:
-    autoreconf
+If using git (not the tarball), build the "configure" file:
+    autoreconf --install
 
 To then build from source:
     ./configure

+ 3 - 3
README

@@ -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.
 

+ 1 - 1
configure.ac

@@ -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])

File diff suppressed because it is too large
+ 36 - 40
doc/guide/bind10-guide.html


+ 17 - 1
src/bin/cfgmgr/b10-cfgmgr.8

@@ -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

+ 0 - 3
src/bin/cfgmgr/b10-cfgmgr.xml

@@ -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>

+ 0 - 1
src/bin/cmdctl/cmdctl.py.in

@@ -1,7 +1,6 @@
 #!@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

+ 2 - 2
src/bin/msgq/tests/msgq_test.py

@@ -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()

+ 3 - 0
src/bin/resolver/resolver.cc

@@ -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.

+ 1 - 1
src/bin/tests/process_rename_test.py.in

@@ -1,4 +1,4 @@
-# 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

+ 0 - 1
src/bin/xfrin/xfrin.py.in

@@ -1,7 +1,6 @@
 #!@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

+ 0 - 1
src/bin/xfrout/xfrout.py.in

@@ -1,7 +1,6 @@
 #!@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

+ 0 - 1
src/bin/zonemgr/zonemgr.py.in

@@ -1,7 +1,6 @@
 #!@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

+ 0 - 2
src/lib/asiolink/io_socket.cc

@@ -1,5 +1,3 @@
-// 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

+ 1 - 0
src/lib/asiolink/tests/dns_server_unittest.cc

@@ -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;
     }
 

+ 1 - 0
src/lib/config/tests/testdata/Makefile.am

@@ -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

+ 0 - 1
src/lib/datasrc/result.h

@@ -1,4 +1,3 @@
-// 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

+ 0 - 1
src/lib/datasrc/tests/memory_datasrc_unittest.cc

@@ -1,5 +1,4 @@
 // 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

+ 0 - 1
src/lib/datasrc/zone.h

@@ -1,4 +1,3 @@
-// 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

+ 2 - 2
src/lib/log/README

@@ -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.

+ 1 - 1
src/lib/log/dummylog.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 2
src/lib/log/dummylog.h

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/log/logger.h

@@ -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.

+ 1 - 1
src/lib/log/logger_support.cc

@@ -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>

+ 1 - 1
src/lib/log/logger_support.h

@@ -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);

+ 1 - 1
src/lib/log/message_dictionary.cc

@@ -109,5 +109,5 @@ MessageDictionary::globalDictionary() {
 
 
 
-} // namspace log
+} // namespace log
 } // namespace isc

+ 1 - 1
src/lib/log/message_reader.cc

@@ -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

+ 5 - 5
src/lib/log/messagedef.mes

@@ -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

+ 2 - 2
src/lib/log/strutil.h

@@ -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.

+ 1 - 1
src/lib/nsas/fetchable.h

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/nsas/nameserver_address.cc

@@ -1,4 +1,4 @@
-// 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

+ 3 - 0
src/lib/nsas/nameserver_entry.cc

@@ -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);
 }
 

+ 1 - 1
src/lib/nsas/tests/fetchable_unittest.cc

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/nsas/zone_entry.cc

@@ -1,4 +1,4 @@
-// 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

+ 0 - 1
src/lib/python/isc/config/ccsession.py

@@ -1,5 +1,4 @@
 # 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

+ 1 - 1
src/lib/python/isc/net/parse.py

@@ -1,4 +1,4 @@
-# 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

+ 1 - 1
src/lib/python/isc/net/tests/parse_test.py

@@ -1,4 +1,4 @@
-# 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

+ 1 - 1
src/lib/python/isc/util/process.py

@@ -1,4 +1,4 @@
-# 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

+ 1 - 1
src/lib/python/isc/util/tests/process_test.py

@@ -1,4 +1,4 @@
-# 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

+ 48 - 22
src/lib/resolve/recursive_query.cc

@@ -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

+ 1 - 1
src/lib/resolve/resolver_interface.h

@@ -1,4 +1,4 @@
-// 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

+ 23 - 3
src/lib/resolve/tests/recursive_query_unittest_2.cc

@@ -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

+ 2 - 2
tests/system/bindctl/tests.sh

@@ -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 \