Commit 87d58087 authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac499] Merge branch 'master' into trac499

Conflicts:
	src/lib/asiolink/Makefile.am
	src/lib/asiolink/io_fetch.cc
	src/lib/log/Makefile.am
parents 827babb0 290bbf2d
194. [bug] vorner
Solved a 100% CPU usage problem after switching addresses in b10-auth
(and possibly, but unconfirmed, in b10-resolver). It was caused by
repeated reads/accepts on closed socket (the bug was in the code for a
long time, recent changes made it show).
(Trac #657, git e0863720a874d75923ea66adcfbf5b2948efb10a)
193. [func]* jreed
Listen on the IPv6 (::) and IPv4 (0.0.0.0) wildcard addresses
for b10-auth. This returns to previous behavior prior to
change #184. Document the listen_on configuration in manual.
(Trac #649, git 65a77d8fde64d464c75917a1ab9b6b3f02640ca6)
192. [func]* jreed
Listen on standard domain port 53 for b10-auth and
b10-resolver.
(Trac #617, #618, git 137a6934a14cf0c5b5c065e910b8b364beb0973f)
191. [func] jinmei
Imported system test framework of BIND 9. It can be run by
'make systest' at the top source directory. Notes: currently it
doesn't work when built in a separate tree. It also requires
perl, an inherited dependency from the original framework.
Also, mainly for the purpose of tests, a new option "--pid-file"
was added to BoB, with which the boss process will dump its PID
to the specified file.
(Trac #606, git 6ac000df85625f5921e8895a1aafff5e4be3ba9c)
190. [func] jelte
Resolver now sets random qids on outgoing queries using
the boost::mt19937 prng.
(Trac #583, git 5222b51a047d8f2352bc9f92fd022baf1681ed81)
189. [bug] jreed
Do not install the log message compiler.
(Trac #634, git eb6441aca464980d00e3ff827cbf4195c5a7afc5)
......
SUBDIRS = doc src
SUBDIRS = doc src tests
USE_LCOV=@USE_LCOV@
LCOV=@LCOV@
GENHTML=@GENHTML@
......@@ -77,6 +77,11 @@ cppcheck:
--template '{file}:{line}: check_fail: {message} ({severity},{id})' \
src
# system tests
systest:
cd tests/system; \
sh $(abs_srcdir)/tests/system/runall.sh
#### include external sources in the distributed tarball:
EXTRA_DIST = ext/asio/README
EXTRA_DIST += ext/asio/asio/local/stream_protocol.hpp
......
......@@ -164,8 +164,6 @@ source tree:
(Which will use the modules and configurations also from the source
tree.)
The server will listen on port 5300 for DNS requests.
CONFIGURATION
Commands can be given through the bindctl tool.
......
......@@ -583,6 +583,12 @@ if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_DEV_POLL=1"
fi
#
# Perl is optional; it is used only by some of the system test scripts.
#
AC_PATH_PROGS(PERL, perl5 perl)
AC_SUBST(PERL)
AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
[regenerate man pages [default=no]])], enable_man=yes, enable_man=no)
......@@ -683,6 +689,8 @@ AC_CONFIG_FILES([Makefile
src/lib/cache/tests/Makefile
src/lib/server_common/Makefile
src/lib/server_common/tests/Makefile
tests/Makefile
tests/system/Makefile
])
AC_OUTPUT([doc/version.ent
src/bin/cfgmgr/b10-cfgmgr.py
......@@ -712,6 +720,7 @@ AC_OUTPUT([doc/version.ent
src/bin/stats/tests/stats_test
src/bin/bind10/bind10.py
src/bin/bind10/tests/bind10_test
src/bin/bind10/tests/bind10_test.py
src/bin/bind10/run_bind10.sh
src/bin/bindctl/run_bindctl.sh
src/bin/bindctl/bindctl-source.py
......@@ -739,6 +748,9 @@ AC_OUTPUT([doc/version.ent
src/lib/cc/session_config.h.pre
src/lib/cc/tests/session_unittests_config.h
src/lib/log/tests/run_time_init_test.sh
tests/system/conf.sh
tests/system/glue/setup.sh
tests/system/glue/nsx1/b10-config.db
], [
chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
chmod +x src/bin/xfrin/run_b10-xfrin.sh
......@@ -763,6 +775,7 @@ AC_OUTPUT([doc/version.ent
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
chmod +x tests/system/conf.sh
])
AC_OUTPUT
......
......@@ -336,14 +336,6 @@ var/
</simpara>
</note>
<note>
<simpara>
The development prototype of the b10-auth server listens on
0.0.0.0 (all interfaces) port 5300. (This is not the standard
domain service port.)
</simpara>
</note>
<para>
To quickly get started with BIND 10, follow these steps.
</para>
......@@ -397,7 +389,7 @@ var/
<listitem>
<para>Test it; for example:
<screen>$ <userinput>dig @127.0.0.1 -p 5300 -c CH -t TXT authors.bind</userinput></screen>
<screen>$ <userinput>dig @127.0.0.1 -c CH -t TXT authors.bind</userinput></screen>
</para>
</listitem>
......@@ -1044,11 +1036,6 @@ TODO
process.
</para>
<note><simpara>
This development prototype release listens on all interfaces
and the non-standard port 5300.
</simpara></note>
<section>
<title>Server Configurations</title>
......
......@@ -63,12 +63,12 @@
"item_optional": false,
"item_default": [
{
"address": "::1",
"port": 5300
"address": "::",
"port": 53
},
{
"address": "127.0.0.1",
"port": 5300
"address": "0.0.0.0",
"port": 53
}
],
"list_item_spec": {
......@@ -87,7 +87,7 @@
"item_name": "port",
"item_type": "integer",
"item_optional": false,
"item_default": 5300
"item_default": 53
}
]
}
......
......@@ -2,12 +2,12 @@
.\" Title: b10-auth
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: February 22, 2011
.\" Date: March 8, 2011
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "B10\-AUTH" "8" "February 22, 2011" "BIND10" "BIND10"
.TH "B10\-AUTH" "8" "March 8, 2011" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
......@@ -70,6 +70,18 @@ defines the path to the SQLite3 zone file when using the sqlite datasource\&. Th
/usr/local/var/bind10\-devel/zone\&.sqlite3\&.
.PP
\fIlisten_on\fR
is a list of addresses and ports for
\fBb10\-auth\fR
to listen on\&. The list items are the
\fIaddress\fR
string and
\fIport\fR
number\&. By default,
\fBb10\-auth\fR
listens on port 53 on the IPv6 (::) and IPv4 (0\&.0\&.0\&.0) wildcard addresses\&.
.PP
\fIdatasources\fR
configures data sources\&. The list items include:
\fItype\fR
......
......@@ -20,7 +20,7 @@
<refentry>
<refentryinfo>
<date>February 22, 2011</date>
<date>March 8, 2011</date>
</refentryinfo>
<refmeta>
......@@ -131,6 +131,15 @@
<filename>/usr/local/var/bind10-devel/zone.sqlite3</filename>.
</para>
<para>
<varname>listen_on</varname> is a list of addresses and ports for
<command>b10-auth</command> to listen on.
The list items are the <varname>address</varname> string
and <varname>port</varname> number.
By default, <command>b10-auth</command> listens on port 53
on the IPv6 (::) and IPv4 (0.0.0.0) wildcard addresses.
</para>
<para>
<varname>datasources</varname> configures data sources.
The list items include:
......
......@@ -122,7 +122,13 @@ main(int argc, char* argv[]) {
ModuleCCSession* config_session = NULL;
string xfrout_socket_path;
if (getenv("B10_FROM_BUILD") != NULL) {
xfrout_socket_path = string(getenv("B10_FROM_BUILD")) + "/auth_xfrout_conn";
if (getenv("B10_FROM_SOURCE_LOCALSTATEDIR")) {
xfrout_socket_path = string("B10_FROM_SOURCE_LOCALSTATEDIR") +
"/auth_xfrout_conn";
} else {
xfrout_socket_path = string(getenv("B10_FROM_BUILD")) +
"/auth_xfrout_conn";
}
} else {
xfrout_socket_path = UNIX_SOCKET_FILE;
}
......
......@@ -785,6 +785,35 @@ def process_rename(option, opt_str, value, parser):
"""Function that renames the process if it is requested by a option."""
isc.util.process.rename(value)
def dump_pid(pid_file):
"""
Dump the PID of the current process to the specified file. If the given
file is None this function does nothing. If the file already exists,
the existing content will be removed. If a system error happens in
creating or writing to the file, the corresponding exception will be
propagated to the caller.
"""
if pid_file is None:
return
f = open(pid_file, "w")
f.write('%d\n' % os.getpid())
f.close()
def unlink_pid_file(pid_file):
"""
Remove the given file, which is basically expected to be the PID file
created by dump_pid(). The specified may or may not exist; if it
doesn't this function does nothing. Other system level errors in removing
the file will be propagated as the corresponding exception.
"""
if pid_file is None:
return
try:
os.unlink(pid_file)
except OSError as error:
if error.errno is not errno.ENOENT:
raise
def main():
global options
global boss_of_bind
......@@ -805,6 +834,9 @@ def main():
parser.add_option("--pretty-name", type="string", action="callback",
callback=process_rename,
help="Set the process name (displayed in ps, top, ...)")
parser.add_option("--pid-file", dest="pid_file", type="string",
default=None,
help="file to dump the PID of the BIND 10 process")
(options, args) = parser.parse_args()
if args:
parser.print_help()
......@@ -865,6 +897,7 @@ def main():
sys.stderr.write("[bind10] Error on startup: %s\n" % startup_result)
sys.exit(1)
sys.stdout.write("[bind10] BIND 10 started\n")
dump_pid(options.pid_file)
# send "bind10.boot_time" to b10-stats
time.sleep(1) # wait a second
......@@ -918,6 +951,7 @@ def main():
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
boss_of_bind.shutdown()
sys.stdout.write("[bind10] BIND 10 exiting\n");
unlink_pid_file(options.pid_file)
sys.exit(0)
if __name__ == "__main__":
......
from bind10 import ProcessInfo, BoB
from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file
# XXX: environment tests are currently disabled, due to the preprocessor
# setup that we have now complicating the environment
......@@ -48,7 +48,7 @@ class TestProcessInfo(unittest.TestCase):
# 'FOO': 'BAR' })
def test_setting_null_stdout(self):
pi = ProcessInfo('Test Process', [ '/bin/echo', 'foo' ],
pi = ProcessInfo('Test Process', [ '/bin/echo', 'foo' ],
dev_null_stdout=True)
os.dup2(self.old_stdout, sys.stdout.fileno())
self.assertEqual(pi.dev_null_stdout, True)
......@@ -412,5 +412,52 @@ class TestStartStopProcessesBob(unittest.TestCase):
bob.config_handler({'start_auth': True, 'start_resolver': True})
class TestPIDFile(unittest.TestCase):
def setUp(self):
self.pid_file = '@builddir@' + os.sep + 'bind10.pid'
if os.path.exists(self.pid_file):
os.unlink(self.pid_file)
def tearDown(self):
if os.path.exists(self.pid_file):
os.unlink(self.pid_file)
def check_pid_file(self):
# dump PID to the file, and confirm the content is correct
dump_pid(self.pid_file)
my_pid = os.getpid()
self.assertEqual(my_pid, int(open(self.pid_file, "r").read()))
def test_dump_pid(self):
self.check_pid_file()
# make sure any existing content will be removed
open(self.pid_file, "w").write('dummy data\n')
self.check_pid_file()
def test_unlink_pid_file_notexist(self):
dummy_data = 'dummy_data\n'
open(self.pid_file, "w").write(dummy_data)
unlink_pid_file("no_such_pid_file")
# the file specified for unlink_pid_file doesn't exist,
# and the original content of the file should be intact.
self.assertEqual(dummy_data, open(self.pid_file, "r").read())
def test_dump_pid_with_none(self):
# Check the behavior of dump_pid() and unlink_pid_file() with None.
# This should be no-op.
dump_pid(None)
self.assertFalse(os.path.exists(self.pid_file))
dummy_data = 'dummy_data\n'
open(self.pid_file, "w").write(dummy_data)
unlink_pid_file(None)
self.assertEqual(dummy_data, open(self.pid_file, "r").read())
def test_dump_pid_failure(self):
# the attempt to open file will fail, which should result in exception.
self.assertRaises(IOError, dump_pid,
'nonexistent_dir' + os.sep + 'bind10.pid')
if __name__ == '__main__':
unittest.main()
......@@ -26,10 +26,18 @@ import os
isc.util.process.rename()
# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
# installed on the system
# from a directory relative to the value of that variable, or, if defined,
# relative to the value of B10_FROM_SOURCE_LOCALSTATEDIR. Otherwise
# we use the ones installed on the system.
# B10_FROM_SOURCE_LOCALSTATEDIR is specifically intended to be used for
# tests where we want to use variuos types of configuration within the test
# environment. (We may want to make it even more generic so that the path is
# passed from the boss process)
if "B10_FROM_SOURCE" in os.environ:
DATA_PATH = os.environ["B10_FROM_SOURCE"]
if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
DATA_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
else:
DATA_PATH = os.environ["B10_FROM_SOURCE"]
else:
PREFIX = "@prefix@"
DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
......
......@@ -74,7 +74,7 @@ to listen on\&. The list items are the
\fIaddress\fR
string and
\fIport\fR
number\&. The defaults are address ::1 port 5300 and address 127\&.0\&.0\&.1 port 5300\&.
number\&. The defaults are address ::1 port 53 and address 127\&.0\&.0\&.1 port 53\&.
.PP
\fIretries\fR
......
......@@ -141,8 +141,9 @@ once that is merged you can for instance do 'config add Resolver/forward_address
<command>b10-resolver</command> to listen on.
The list items are the <varname>address</varname> string
and <varname>port</varname> number.
The defaults are address ::1 port 5300 and
address 127.0.0.1 port 5300.
The defaults are address ::1 port 53 and
address 127.0.0.1 port 53.
<!-- TODO: but defaults are not used, Trac #518 -->
</para>
<para>
......
......@@ -56,7 +56,6 @@ using namespace asiolink;
namespace {
// Default port current 5300 for testing purposes
static const string PROGRAM = "Resolver";
IOService io_service;
......
......@@ -86,11 +86,11 @@
"item_default": [
{
"address": "::1",
"port": 5300
"port": 53
},
{
"address": "127.0.0.1",
"port": 5300
"port": 53
}
],
"list_item_spec": {
......@@ -109,7 +109,7 @@
"item_name": "port",
"item_type": "integer",
"item_optional": false,
"item_default": 5300
"item_default": 53
}
]
}
......
......@@ -50,7 +50,11 @@ isc.util.process.rename()
if "B10_FROM_BUILD" in os.environ:
SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/xfrout"
AUTH_SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/auth"
UNIX_SOCKET_FILE= os.environ["B10_FROM_BUILD"] + "/auth_xfrout_conn"
if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
UNIX_SOCKET_FILE = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"] + \
"/auth_xfrout_conn"
else:
UNIX_SOCKET_FILE = os.environ["B10_FROM_BUILD"] + "/auth_xfrout_conn"
else:
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
......
......@@ -29,6 +29,7 @@ libasiolink_la_SOURCES += io_fetch.cc io_fetch.h
libasiolink_la_SOURCES += io_message.h
libasiolink_la_SOURCES += io_service.cc io_service.h
libasiolink_la_SOURCES += io_socket.cc io_socket.h
libasiolink_la_SOURCES += qid_gen.cc qid_gen.h
libasiolink_la_SOURCES += recursive_query.cc recursive_query.h
libasiolink_la_SOURCES += simple_callback.h
libasiolink_la_SOURCES += tcp_endpoint.h
......
......@@ -28,6 +28,8 @@
#include <dns/rcode.h>
#include <log/logger.h>
#include <asiolink/qid_gen.h>
#include <asio.hpp>
#include <asio/deadline_timer.hpp>
......@@ -178,9 +180,7 @@ IOFetch::operator()(asio::error_code ec, size_t length) {
/// declarations.
{
Message msg(Message::RENDER);
// TODO: replace with boost::random or some other suitable PRNG
msg.setQid(0);
msg.setQid(QidGenerator::getInstance().generateQid());
msg.setOpcode(Opcode::QUERY());
msg.setRcode(Rcode::NOERROR());
msg.setHeaderFlag(Message::HEADERFLAG_RD);
......
// Copyright (C) 2011 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 notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// qid_gen defines a generator for query id's
//
// We probably want to merge this with the weighted random in the nsas
// (and other parts where we need randomness, perhaps another thing
// for a general libutil?)
#include <asiolink/qid_gen.h>
#include <sys/time.h>
namespace {
asiolink::QidGenerator qid_generator_instance;
}
namespace asiolink {
QidGenerator&
QidGenerator::getInstance() {
return (qid_generator_instance);
}
QidGenerator::QidGenerator() : dist_(0, 65535),
vgen_(generator_, dist_)
{
seed();
}
void
QidGenerator::seed() {
struct timeval tv;
gettimeofday(&tv, 0);
generator_.seed((tv.tv_sec * 1000000) + tv.tv_usec);
}
isc::dns::qid_t
QidGenerator::generateQid() {
return (vgen_());
}
} // namespace asiolink
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment