Commit 315d2846 authored by Stephen Morris's avatar Stephen Morris
Browse files

[2467] Merge branch 'master' into trac2467

parents 55dd0805 7ece6fb6
611. [func] naokikambe
Added Xfrin statistics items such as the number of successful
transfers. These are per-zone type counters. Their values can be
obtained with zone names by invoking "Stats show Xfrin" via bindctl
while Xfrin is running.
(Trac #2252, git e1a0ea8ef5c51b9b25afa111fbfe9347afbe5413)
bind10-1.0.0beta2 released on May 3, 2013
610. [bug] muks
When the sqlite3 program is not available on the system (in
PATH), we no longer attempt to run some tests which depend
on it.
(Trac #1909, git f85b274b85b57a094d33ca06dfbe12ae67bb47df)
609. [bug] jinmei
Handled some rare error cases in DNS server classes correctly.
This fix specifically solves occasional crash of b10-auth due to
errors caused by TCP DNS clients. Also, as a result of cleanups
with the fix, b10-auth should now be a little bit faster in
handling UDP queries: in some local experiments it ran about 5%
(Trac #2903, git 6d3e0f4b36a754248f8a03a29e2c36aef644cdcc)
608. [bug] jinmei
b10-cmdctl: fixed a hangup problem on receiving the shutdown
command from bindctl. Note, however, that cmdctl is defined as
a "needed" module by default, so shutting down cmdctl would cause
shutdown of the entire BIND 10 system anyway, and is therefore
still not very useful in practice.
(Trac #2712, git fa392e8eb391a17d30550d4b290c975710651d98)
607. [bug] jinmei
Worked around some unit test regressions on FreeBSD 9.1 due to
a binary compatibility issue between standard and system
libraries (
While not all tests still pass, main BIND 10 programs should
generally work correctly. Still, there can be odd run time
behavior such as abrupt crash instead of graceful shutdown
when some fatal event happens, so it's generally discouraged to
use BIND 10 on FreeBSD 9.1 RELEASE. According to the above
bug report for FreeBSD, it seems upgrading or downgrading the
FreeBSD version will solve this problem.
(Trac #2887, git 69dfb4544d9ded3c10cffbbfd573ae05fdeb771f)
606. [bug] jinmei
b10-xfrout now correctly stops sending notify requests once it
receives a valid response. It previously handled it as if the
requests are timed out and resent it a few times in a short
(Trac #2879, git 4c45f29f28ae766a9f7dc3142859f1d0000284e1)
605. [bug] tmark
Modified perfdhcp to calculate the times displayed for packet sent
and received as time elapsed since perfdhcp process start time.
Previously these were times since the start of the epoch.
However the large numbers involved caused loss of precision
in the calculation of the test statistics.
(Trac #2785, git e9556924dcd1cf285dc358c47d65ed7c413e02cf)
604. [func] marcin
libdhcp++: abstracted methods which open sockets and send/receive
DHCP4 packets to a separate class. Other classes will be derived
from it to implement OS-specific methods of DHCPv4 packets filtering.
The primary purpose for this change is to add support for Direct
DHCPv4 response to a client which doesn't have an address yet on
different OSes.
(Trac #991, git 33ffc9a750cd3fb34158ef676aab6b05df0302e2)
603. [func] tmark
The directory in which the b10-dchp4 and b10-dhcp6 server id files has
been changed from the local state directory (set by the "configure"
--localstatedir switch) to the "bind10" subdirectory of it. After an
upgrade, server id files in the former location will be orphaned and
should be manually removed.
(Trac #2770, git a622140d411b3f07a68a1451e19df36118a80650)
602. [bug] tmark
Perdhcp will now exit gracefully if the command line argument for IP version
(-4 or -6) does not match the command line argument given for the server.
Prior to this perfdhcp would core when given an IP version of -6 but a valid
IPv4 address for server.
Perfdhcp will now exit gracefully if the command line argument for
IP version (-4 or -6) does not match the command line argument
given for the server. Prior to this perfdhcp would core when given
an IP version of -6 but a valid IPv4 address for server.
(Trac #2784, git 96b66c0c79dccf9a0206a45916b9b23fe9b94f74)
601. [bug]* jinmei, vorner
The "delete record" interface of the database based data source
was extended do that the parameter includes reversed name in
was extended so that the parameter includes reversed name in
addition to the actual name. This may help the underlying
accessor implementation if reversed names are more convenient
for the delete operation. This was the case for the SQLite3
......@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4macros -I examples/m4 ${ACLOCAL_FLAGS}
# ^^^^^^^^ This has to be the first line and cannot come later in this
# due to some bork in some versions of autotools.
SUBDIRS = compatcheck doc . src tests
SUBDIRS = compatcheck doc . src tests m4macros
......@@ -46,7 +46,7 @@ endif
@if [ $(USE_LCOV) = yes ] ; then \
$(LCOV) --directory . --zerocounters; \
rm -rf coverage/; \
rm -rf $(abs_top_srcdir)/coverage-cpp-html/; \
else \
echo "C++ code coverage not enabled at configuration time." ; \
echo "Use: ./configure --with-lcov" ; \
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(bind10, 20130221,
AC_INIT(bind10, 20130503,
# serial-tests is not available in automake version before 1.13. In
# automake 1.13 and higher, AM_PROG_INSTALL is undefined, so we'll check
......@@ -388,8 +388,6 @@ In this case we will continue, but naming of python processes will not work.])
# TODO: check for module
# (g++ only check)
# Python 3.2 has an unused parameter in one of its headers. This
# has been reported, but not fixed as of yet, so we check if we need
......@@ -884,6 +882,17 @@ if test "$BOOST_NUMERIC_CAST_WOULDFAIL" = "yes" -a X"$werror_ok" = X1 -a $CLANGP
AC_MSG_ERROR([Failed to compile a required header file. If you are using FreeBSD and Boost installed via ports, retry with specifying --without-werror. See the ChangeLog entry for Trac no. 1991 for more details.])
[Build with Boost shared memory support; for large scale authoritative DNS servers]),
if test X$use_shared_memory = Xyes -a "$BOOST_MAPPED_FILE_WOULDFAIL" = "yes"; then
AC_MSG_ERROR([Boost shared memory does not compile on this system. If you don't need it (most normal users won't) build without it by rerunning this script with --without-shared-memory; using a different compiler or a different version of Boost may also help.])
AM_CONDITIONAL([USE_SHARED_MEMORY], [test x$use_shared_memory = xyes])
# Add some default CPP flags needed for Boost, identified by the AX macro.
......@@ -1032,12 +1041,16 @@ AC_SUBST(GTEST_LDFLAGS)
dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
dnl check for pkg-config itself
AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes, no)
if test "x$HAVE_PKG_CONFIG" = "xno" ; then
AC_MSG_ERROR(Please install pkg-config)
PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9, enable_features="$enable_features SQLite3")
if test "x$have_sqlite" = "xyes" ; then
enable_features="$enable_features SQLite3"
# ASIO: we extensively use it as the C++ event management module.
......@@ -1190,6 +1203,7 @@ AC_CONFIG_FILES([Makefile
......@@ -1311,6 +1325,7 @@ AC_CONFIG_FILES([Makefile
The IPC protocol
While the cc-protocol.txt describes the low-level primitives, here we
describe how the whole IPC should work and how to use it.
The system that moves data between the users and does bookkeeping.
In our current implementation, it is implemented as the MsgQ daemon,
which the users connect to and it routes the data.
Usually a process; generally an entity that wants to communicate
with the other users.
Session is the interface by which the user communicates with the
system. Single user may have multiple sessions, a session belongs to
single user.
A data blob sent by one user. The recipient might be the system
itself, other session or set of sessions (called group, see below,
it is possibly empty). Message is either a response or an original
message (TODO: Better name?).
A named set of sessions. Conceptually, all the possible groups
exist, there's no explicit creation and deletion of groups.
session id::
Unique identifier of a session. It is not reused for the whole
lifetime of the system. Historically called `lname` in the code.
undelivery signal::
While sending an original message, a client may request an
undelivery signal. If the recipient specification yields no
sessions to deliver the message to, the system informs user about
the situation.
sequence number::
Each message sent through the system carries a sequence number. The
number should be unique per sender. It can be used to pair a
response to the original message, since the response specifies which
sequence number had the message it response to. Even responses and
messages not expecting answer have their sequence number, but it is
generally unused.
non-blocking operation::
Operation that will complete without waiting for anything.
fast operation::
Operation that may wait for other process, but only for a very short
time. Generally, this includes communication between the user and
system, but not between two clients. It can be expected to be fast
enough to use this inside an interactive session, but may be too
heavy in the middle of query processing, for example. Every
non-blocking operation is considered fast.
The session
The session interface allows for several operations interacting with
the system. In the code, it is represented by a class.
Possible operations include:
Opening a session::
The session is created and connects to the system. This operation is
fast. The session receives session id from the system.
Group management::
A user may subscribe (become member) of a group, or unsubscribe from
a group. These are fast operations.
A user may send a message, addressed to the system, or other
session(s). This operation is expected to be non-blocking
(current implementation is based on assumption of how OS handles the
sends, which may need to be revisited if it turns out to be false).
Receive synchronously::
User may wait for an incoming message in blocking mode. It is
possible to specify the kind of message to wait for, either original
message or response to a message. This interface has a timeout.
Receive asynchronously::
Similar to previous, but non-blocking. It terminates immediately.
The user provides a callback that is invoked when the requested
message arrives.
A session may be terminated. No more messages are sent or received
over it, the session is automatically unsubscribed from all the
groups. This operation is non-blocking. A session is terminated
automatically if the user exits.
We assume reliability and order of delivery. Messages sent from user A
to B are all delivered unchanged in original order as long as B
All above operations are expected to always succeed. If there's an
error reported, it should be considered fatal and user should
exit. In case a user still wants to continue, the session must be
considered terminated and a new one must be created. Care must be
taken not to use any information obtained from the previous session,
since the state in other users and the system may have changed during
the reconnect.
Addressing happens in three ways:
By group name::
The message is routed to all the sessions subscribed to this group.
It is legal to address an empty group; such message is then
delivered to no sessions.
By session ID::
The message is sent to the single session, if it is still alive.
By an alias::
A session may have any number of aliases - well known names. Only
single session may hold given alias (but it is not yet enforced by
the system). The message is delivered to the one session owning the
alias, if any. Internally, the aliases are implemented as groups
with single subscribed session, so it is the same as the first
option on the protocol level, but semantically it is different.
The system
The system performs these goals:
* Maintains the open sessions and allows creating new ones.
* Keeps information about groups and which sessions are subscribed to
which group.
* Routes the messages between users.
Also, the system itself is a user of the system. It can be reached by
the alias `Msgq` and provides following high-level services (see
Notifications about sessions::
When a session is opened to the system or when a session is
terminated, a notification is sent to interested users. The
notification contains the session ID of the session in question.
The termination notification is probably more useful (if a user
communicated with a given session before, it might be interested it
is no longer available), the opening notification is provided mostly
for completeness.
Notifications about group subscriptions::
When a session subscribes to a group or unsubscribes from a group, a
notification is sent to interested users. The notification contains
both the session ID of the session subscribing/unsubscribing and
name of the group. This includes notifications about aliases (since
aliases are groups internally).
Commands to list sessions::
There's a command to list session IDs of all currently opened sessions
and a command to list session IDs of all sessions subscribed to a
given group. Note that using these lists might need some care, as
the information might be outdated at the time it is delivered to the
User shows interest in notifications about sessions and group
subscriptions by subscribing to a group with well-known name (as with
any notification).
Note that due to implementation details, the `Msgq` alias is not yet
available during early stage of the bootstrap of bind10 system. This
means some very core services can't rely on the above services of the
system. The alias is guaranteed to be working before the first
non-core module is started.
Higher-level services
While the system is able to send any kind of data, the payload sent by
users in bind10 is structured data encoded as JSON. The messages sent
are of three general types:
A message sent to single destination, with the undeliverable
signal turned on and expecting an answer. This is a request
to perform some operation on the recipient (it can have side effects
or not). The command is identified by a name and it can have
parameters. A command with the same name may behave differently (or
have different parameters) on different receiving users.
An answer to the `Command`. It is sent directly to the session where
the command originated from, does not expect further answer and the
undeliverable notification is not set. It either confirms the
command was run successfully and contains an optional result, or
notifies the sender of failure to run the command. Success and
failure differ only in the payload sent through the system, not in
the way it is sent. The undeliverable signal is failure
reply sent by the system on behalf of the missing recipient.
A message sent to any number of destinations (eg. sent to a group),
not expecting an answer. It notifies other users about an event or
change of state.
Details of the higher-level
While there are libraries implementing the communication in convenient
way, it is useful to know what happens inside.
The notifications are probably the simplest. Users interested in
receiving notifications of some family subscribe to corresponding
group. Then, a client sends a message to the group. For example, if
clients `receiver-A` and `receiver-B` want to receive notifications
about changes to zone data, they'd subscribe to the
`Notifications/ZoneUpdates` group. Then, other client (let's say
`XfrIn`, with session ID `s12345`) would send something like:
s12345 -> Notifications/ZoneUpdates
{"notification": ["zone-update", {
"class": "IN",
"origin": "",
"serial": 123456
Both receivers would receive the message and know that the
`` zone is now at version 123456. Note that multiple users
may produce the same kind of notification. Also, single group may be
used to send multiple notification names (but they should be related;
in our example, the `Notifications/ZoneUpdates` could be used for
`zone-update`, `zone-available` and `zone-unavailable` notifications
for change in zone data, configuration of new zone in the system and
removal of a zone from configuration).
Sending a command to single recipient is slightly more complex. The
sending user sends a message to the receiving one, addressed either by
session ID or by an alias (group to which at most one session may be
subscribed). The message contains the name of the command and
parameters. It is sent with the undeliverable signals turned on.
The user also starts a timer (with reasonably long timeout). The
sender also subscribes to notifications about terminated sessions or
unsubscription from the alias group.
The receiving user gets the message, runs the command and sends a
response back, with the result. The response has the undeliverable
signal turned off and it is marked as response to the message
containing the command. The sending user receives the answer and pairs
it with the command.
There are several things that may go wrong.
* There might be an error on the receiving user (bad parameters, the
operation failed, the recipient doesn't know command of that name).
The receiving side sends the response as previous, the only
difference is the content of the payload. The sending user is
notified about it, without delays.
* The recipient user doesn't exist (either the session ID is wrong or
terminated already, or the alias is empty). The system sends a
failure response and the sending user knows immediately the command
* The recipient disconnects while processing the command (possibly
crashes). The sender gets a notification about disconnection or
unsubscription from the alias group and knows the answer won't come.
* The recipient ``blackholes'' the command. It receives it, but never
answers. The timeout in sender times out. As this is a serious
programmer error in the recipient and should be rare, the sender
should at least log an error to notify about the case.
One example would be asking the question of life, universe and
everything (all the examples assume the sending user is already
subscribed to the notifications):
s12345 -> DeepThought
{"command": ["question", {
"what": ["Life", "Universe", "*"]
s23456 -> s12345
{"reply": [0, 42]}
The deep thought had an alias. But the answer is sent from its session
ID. The `0` in the reply means ``success''.
Another example might be asking for some data at a bureau and getting
an error:
s12345 -> Burreau
{"command": ["provide-information", {
"about": "me",
"topic": "taxes"
s23456 -> s12345
{"reply": [1, "You need to fill in other form"]}
And, in this example, the sender is trying to reach an non-existent
session. The `msgq` here is not the alias `Msgq`, but a special
``phantom'' session ID that is not listed anywhere.
s12345 -> s0
{"command": ["ping"]}
msgq -> s12345
{"reply": [-1, "No such recipient"]}
Last, an example when the other user disconnects while processing the
s12345 -> s23456
{"command": ["shutdown"]}
msgq -> s12345
{"notification": ["disconnected", {
"lname": "s23456"
The system does not support sending a command to multiple users
directly. It can be accomplished as this:
* The sending user calls a command on the system to get list of
sessions in given group. This is command to alias, so it can be done
by the previous way.
* After receiving the list of session IDs, multiple copies of the
command are sent by the sending user, one to each of the session
* Successes and failures are handled the same as above, since these
are just single-recipient commands.
So, this would be an example with unhelpful war council.
s12345 -> Msgq
{"command": ["get-subscriptions", {
"group": "WarCouncil"
msgq -> s12345
{"reply": [0, ["s1", "s2", "s3"]]}
s12345 -> s1
{"command": ["advice", {
"topic": "Should we attack?"
s12345 -> s2
{"command": ["advice", {
"topic": "Should we attack?"
s12345 -> s3
{"command": ["advice", {
"topic": "Should we attack?"
s1 -> s12345
{"reply": [0, true]}
s2 -> s12345
{"reply": [0, false]}
s3 -> s12345
{"reply": [1, "Advice feature not implemented"]}
While there's a lot of flexibility for the behaviour of a user, it
usually comes to something like this (during the lifetime of the
* The user starts up.
* Then it creates one or more sessions (there may be technical reasons
to have more than one session, such as threads, but it is not
required by the system).
* It subscribes to some groups to receive notifications in future.
* It binds to some aliases if it wants to be reachable by others by a
nice name.
* It invokes some start-up commands (to get the configuration, for
* During the lifetime, it listens for notifications and answers
commands. It also invokes remote commands and sends notifications
about things that are happening.
* Eventually, the user terminates, closing all the sessions it had
Known limitations
It is meant mostly as signalling protocol. Sending millions of
messages or messages of several tens of megabytes is probably a bad
idea. While there's no architectural limitation with regards of the
number of transferred messages and the maximum size of message is 4GB,
the code is not optimised and it would probably be very slow.
We currently expect the system not to be at heavy load. Therefore, we
expect the system to keep up with users sending messages. The
libraries write in blocking mode, which is no problem if the
expectation is true, as the write buffers will generally be empty and
the write wouldn't block, but if it turns out it is not the case, we
might need to reconsider.
EXTRA_DIST = ax_boost_for_bind10.m4
EXTRA_DIST += ax_sqlite3_for_bind10.m4
......@@ -23,7 +23,11 @@ dnl BOOST_OFFSET_PTR_WOULDFAIL set to "yes" if offset_ptr would cause build
dnl error; otherwise set to "no"
dnl BOOST_NUMERIC_CAST_WOULDFAIL set to "yes" if numeric_cast would cause
dnl build error; otherwise set to "no"
dnl BOOST_MAPPED_FILE_WOULDFAIL set to "yes" if managed_mapped_file would
dnl cause build failure; otherwise set to "no"
dnl BOOST_MAPPED_FILE_CXXFLAG set to the compiler flag that would need to
dnl compile managed_mapped_file (can be empty).
dnl It is of no use if "WOULDFAIL" is yes.
......@@ -101,10 +105,49 @@ if test "X$GXX" = "Xyes"; then
# This doesn't matter for non-g++
# This doesn't matter for non-g++
# Boost interprocess::managed_mapped_file is highly system dependent and
# can cause many portability issues. We are going to check if it could
# compile at all, possibly with being lenient about compiler warnings.
if test "X$GXX" = "Xyes"; then
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Werror"
try_flags="$try_flags -Wno-error"
# clang can cause false positives with -Werror without -Qunused-arguments
AC_CHECK_DECL([__clang__], [CXXFLAGS="$CXXFLAGS -Qunused-arguments"], [])
AC_MSG_CHECKING([Boost managed_mapped_file compiles])
for flag in $try_flags; do
if test "$flag" != no; then
#include <boost/interprocess/managed_mapped_file.hpp>
return (boost::interprocess::managed_mapped_file().all_memory_deallocated());
],[AC_MSG_RESULT([yes, with $flag flag])
if test $BOOST_MAPPED_FILE_WOULDFAIL = yes; then
dnl @synopsis AX_SQLITE3_FOR_BIND10
dnl Test for the sqlite3 library and program, intended to be used within
dnl BIND 10, and to test BIND 10.
dnl We use pkg-config to look for the sqlite3 library, so the sqlite3
dnl development package with the .pc file must be installed.
dnl This macro sets SQLITE_CFLAGS and SQLITE_LIBS. It also sets
dnl SQLITE3_PROGRAM to the path of the sqlite3 program, if it is found
dnl in PATH.
PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9,