Commit 1bd60308 authored by Yoshitaka Aharen's avatar Yoshitaka Aharen
Browse files

[2157] apply review comments

parent 5d108ef3
......@@ -1279,6 +1279,7 @@ AC_OUTPUT([doc/version.ent
src/bin/msgq/run_msgq.sh
src/bin/auth/auth.spec.pre
src/bin/auth/spec_config.h.pre
src/bin/auth/gen-statistics_items.py.pre
src/bin/dhcp4/spec_config.h.pre
src/bin/dhcp6/spec_config.h.pre
src/bin/tests/process_rename_test.py
......@@ -1341,6 +1342,7 @@ AC_OUTPUT([doc/version.ent
chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
chmod +x src/bin/msgq/run_msgq.sh
chmod +x src/bin/msgq/tests/msgq_test
chmod +x src/bin/auth/gen-statistics_items.py.pre
chmod +x src/lib/dns/gen-rdatacode.py
chmod +x src/lib/log/tests/console_test.sh
chmod +x src/lib/log/tests/destination_test.sh
......
......@@ -18,6 +18,9 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@
CLEANFILES = *.gcno *.gcda auth.spec spec_config.h
CLEANFILES += auth_messages.h auth_messages.cc
CLEANFILES += gen-statistics_items.py
# auto-generated by gen-statistics_items.py
CLEANFILES += statistics.cc statistics_items.h b10-auth.xml tests/statistics_unittest.cc
man_MANS = b10-auth.8
DISTCLEANFILES = $(man_MANS)
......@@ -36,8 +39,18 @@ $(man_MANS):
endif
auth.spec: auth.spec.pre
$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" auth.spec.pre >$@
auth.spec: auth.spec.pre statistics_qr_items.def
b10-auth.xml: b10-auth.xml.pre statistics_qr_items.def
statistics_items.h: statistics_items.h.pre statistics_qr_items.def
statistics.cc: statistics.cc.pre statistics_qr_items.def
tests/statistics_unittest.cc: tests/statistics_unittest.cc.pre statistics_qr_items.def
gen-statistics_items.py: gen-statistics_items.py.pre
$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" gen-statistics_items.py.pre >$@
chmod +x $@
auth.spec b10-auth.xml statistics_items.h statistics.cc tests/statistics_unittest.cc: Makefile gen-statistics_items.py
./gen-statistics_items.py
spec_config.h: spec_config.h.pre
$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
......@@ -46,6 +59,8 @@ auth_messages.h auth_messages.cc: auth_messages.mes
$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/auth/auth_messages.mes
BUILT_SOURCES = spec_config.h auth_messages.h auth_messages.cc
# auto-generated by gen-statistics_items.py
BUILT_SOURCES += statistics_items.h statistics.cc
pkglibexec_PROGRAMS = b10-auth
b10_auth_SOURCES = query.cc query.h
......@@ -54,12 +69,17 @@ b10_auth_SOURCES += auth_log.cc auth_log.h
b10_auth_SOURCES += auth_config.cc auth_config.h
b10_auth_SOURCES += command.cc command.h
b10_auth_SOURCES += common.h common.cc
b10_auth_SOURCES += statistics.cc statistics.h statistics_items.h
b10_auth_SOURCES += statistics.h
b10_auth_SOURCES += datasrc_configurator.h
b10_auth_SOURCES += main.cc
nodist_b10_auth_SOURCES = auth_messages.h auth_messages.cc
nodist_b10_auth_SOURCES += statistics.cc statistics_items.h
EXTRA_DIST += auth_messages.mes
EXTRA_DIST += statistics_qr_items.def
EXTRA_DIST += b10-auth.xml.pre
EXTRA_DIST += statistics_items.h.pre statistics.cc.pre
EXTRA_DIST += tests/statistics_unittest.cc.pre
b10_auth_LDADD = $(top_builddir)/src/lib/datasrc/libb10-datasrc.la
b10_auth_LDADD += $(top_builddir)/src/lib/dns/libb10-dns++.la
......
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2010-2012 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.
-->
<refentry>
<refentryinfo>
<date>October 3, 2012</date>
</refentryinfo>
<refmeta>
<refentrytitle>b10-auth</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo>BIND10</refmiscinfo>
</refmeta>
<refnamediv>
<refname>b10-auth</refname>
<refpurpose>Authoritative DNS server</refpurpose>
</refnamediv>
<docinfo>
<copyright>
<year>2010-2012</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refsynopsisdiv>
<cmdsynopsis>
<command>b10-auth</command>
<arg><option>-v</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>The <command>b10-auth</command> daemon provides the BIND 10
authoritative DNS server.
Normally it is started by the
<citerefentry><refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum></citerefentry>
boss process.
</para>
<para>
This daemon communicates with other BIND 10 components over a
<citerefentry><refentrytitle>b10-msgq</refentrytitle><manvolnum>8</manvolnum></citerefentry>
C-Channel connection. If this connection is not established,
<command>b10-auth</command> will exit.
<!-- TODO what if msgq connection closes later, will b10-auth exit? -->
It receives its configurations from
<citerefentry><refentrytitle>b10-cfgmgr</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>
<!-- TODO: mention xfrin, xfrout, zonemgr ? -->
</refsect1>
<refsect1>
<title>OPTIONS</title>
<para>The arguments are as follows:</para>
<variablelist>
<varlistentry>
<term><option>-v</option></term>
<listitem><para>
Enable verbose logging mode. This enables logging of
diagnostic messages at the maximum debug level.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>CONFIGURATION AND COMMANDS</title>
<para>
The configurable settings are:
</para>
<para>
<varname>database_file</varname> defines the path to the
SQLite3 zone file when using the sqlite datasource.
The default is
<filename>@@LOCALSTATEDIR@@/bind10-devel/zone.sqlite3</filename>.
</para>
<para>
<varname>datasources</varname> configures data sources.
The list items include:
<varname>type</varname> to define the required data source type
(such as <quote>memory</quote>);
<varname>class</varname> to optionally select the class
(it defaults to <quote>IN</quote>);
and
<varname>zones</varname> to define the
<varname>file</varname> path name,
<varname>origin</varname> (default domain), and optional
<varname>filetype</varname>.
By default, <varname>zones</varname> is empty.
For the in-memory data source (i.e., the <varname>type</varname>
is <quote>memory</quote>), the optional <varname>filetype</varname>
configuration item for <varname>zones</varname> can be
specified so the in-memory zone data can be built from another
data source that is based on a database backend (in practice
with current implementation, it would be an SQLite3 database
file for the SQLite3 data source).
See the <citetitle>BIND 10 Guide</citetitle> for configuration
details.
<note><simpara>
Only the IN class is supported at this time.
By default, the memory data source is disabled.
Also, currently the zone file must be canonical such as
generated by <command>named-compilezone -D</command>.
</simpara></note>
</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>tcp_recv_timeout</varname> is the timeout used on
incoming TCP connections, in milliseconds. If the query
is not sent within this time, the connection is closed.
Setting this to 0 will disable TCP timeouts completely.
</para>
<!-- TODO: formating -->
<para>
The configuration commands are:
</para>
<para>
<command>loadzone</command> tells <command>b10-auth</command>
to load or reload a zone file. The arguments include:
<varname>class</varname> which optionally defines the class
(it defaults to <quote>IN</quote>);
<varname>origin</varname> is the domain name of the zone;
and
<varname>datasrc</varname> optionally defines the type of datasource
(it defaults to <quote>memory</quote>).
<note><simpara>
In this development version, currently this only supports the
IN class and the memory data source.
</simpara></note>
</para>
<para>
<command>getstats</command> tells <command>b10-auth</command>
to send its statistics data.
</para>
<para>
<command>shutdown</command> exits <command>b10-auth</command>.
This has an optional <varname>pid</varname> argument to
select the process ID to stop.
(Note that the BIND 10 boss process may restart this service
if configured.)
</para>
</refsect1>
<refsect1>
<title>STATISTICS DATA</title>
<para>
The statistics data collected by the <command>b10-stats</command>
daemon for <quote>Auth</quote> include:
</para>
<!-- ### STATISTICS DATA PLACEHOLDER ### -->
<!-- TODO: missing stats docs. See ticket #1721 -->
</refsect1>
<refsect1>
<title>FILES</title>
<para>
<filename>@@LOCALSTATEDIR@@/bind10-devel/zone.sqlite3</filename>
&mdash; Location for the SQLite3 zone database
when <emphasis>database_file</emphasis> configuration is not
defined.
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>b10-cfgmgr</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-loadzone</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-msgq</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-stats</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-zonemgr</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citetitle>BIND 10 Guide</citetitle>.
</para>
</refsect1>
<refsect1>
<title>HISTORY</title>
<para>
The <command>b10-auth</command> daemon was first coded in October 2009.
</para>
</refsect1>
</refentry><!--
- Local variables:
- mode: sgml
- End:
-->
#!@PYTHON@
# Copyright (C) 2012 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.
import os
import re
import sys
import json
from xml.etree import ElementTree
item_list = []
localstatedir = '@@LOCALSTATEDIR@@'
builddir = '@builddir@'
srcdir = '@srcdir@'
pre_suffix = '.pre'
xmldocument_command_name = 'b10-auth'
def need_generate(filepath, mtime):
'''Check if we need to generate the specified file.
To avoid unnecessary compilation, we skip (re)generating the file when
the file already exists and newer than the base file.
'''
if os.path.exists(filepath) and os.path.getmtime(filepath) > mtime:
return False
return True
def import_definitions():
global item_list
items_definition_file = srcdir + os.sep + 'statistics_qr_items.def'
item_definition = open(items_definition_file, 'r')
re_splitter = re.compile('\t+')
l = item_list
lp = None
for line in item_definition.readlines():
element = re_splitter.split(line.rstrip())
if element[0] == '':
element.pop(0)
if element[-1] == '=':
l.append({'name': element[0], 'child': [], 'index': element[1],
'description': element[2], 'parent': lp})
lp = l
l = l[-1]['child']
elif element[-1] == ';':
l = lp
lp = l[-1]['parent']
else:
l.append({'name': element[0], 'child': None, 'index': element[1],
'description': element[2], 'parent': lp})
item_definition.close()
return os.path.getmtime(items_definition_file)
def generate_specfile(specfile, def_mtime):
global item_list
def convert_list(items, prefix = ''):
spec_list = []
default_map = {}
for item in items:
full_item_name = prefix + item['name']
if item['child'] is None:
default_map[item['name']] = 0
spec_list.append({
'item_name': item['name'],
'item_optional': False,
'item_type': 'integer',
'item_default': 0,
'item_title': full_item_name,
'item_description': item['description'],
})
else:
child_spec_list, child_default_map = \
convert_list(item['child'], full_item_name + '.')
spec_list.append({
'item_name': item['name'],
'item_type': 'map',
'item_optional': False,
'item_title': full_item_name,
'item_description': item['description'],
'item_default': child_default_map,
'map_item_spec': child_spec_list,
})
default_map[item['name']] = child_default_map
return spec_list, default_map
item_spec_list, item_default_map = convert_list(item_list)
statistics_spec_list = [{
'item_name': 'zones',
'item_type': 'named_set',
'item_optional': False,
'item_title': 'Zone statistics',
'item_description':
'Zone statistics items. ' +
"Items for all zones are stored in '_SERVER_'.",
'item_default': { '_SERVER_': item_default_map },
'named_set_item_spec': {
'item_name': 'zone',
'item_type': 'map',
'item_optional': False,
'item_default': {},
'map_item_spec': item_spec_list,
},
}]
if need_generate(builddir+os.sep+specfile, def_mtime):
stats_pre = open(builddir+os.sep+specfile+pre_suffix, 'r')
stats_pre_json = json.loads(stats_pre.read().replace('@@LOCAL'+'STATEDIR@@',
localstatedir))
stats_pre.close()
stats_pre_json['module_spec']['statistics'] = statistics_spec_list
statistics_spec_json = json.dumps(stats_pre_json, sort_keys = True,
indent = 2)
stats_spec = open(builddir+os.sep+specfile, 'w')
stats_spec.write(statistics_spec_json)
stats_spec.close()
else:
print('skip generating ' + specfile)
return
def generate_docfile(docfile, def_mtime):
global item_list
def convert_list(items, tree, prefix = ''):
for item in items:
full_item_name = prefix + item['name']
if item['child'] is None:
child_element = ElementTree.SubElement(tree, 'varlistentry')
term = ElementTree.SubElement(child_element, 'term')
term.text = full_item_name
list_item = ElementTree.SubElement(child_element, 'listitem')
sim_para = ElementTree.SubElement(list_item, 'simpara')
sim_para.text = ''
prev = None
for word in item['description'].split():
if word == xmldocument_command_name:
command = ElementTree.SubElement(sim_para, 'command')
command.text = word
para_tail = command
command.tail = ' '
prev = command
else:
if prev is None:
sim_para.text += word + ' '
else:
prev.tail += word + ' '
else:
convert_list(item['child'], tree, full_item_name + '.')
return
if need_generate(builddir+os.sep+docfile, def_mtime):
doc_pre = open(srcdir+os.sep+docfile+pre_suffix, 'r')
doc_pre_xml = doc_pre.read().replace('@@LOCALSTATEDIR@@', localstatedir)
doc_pre.close
variable_tree = ElementTree.Element('variablelist')
convert_list(item_list, variable_tree)
doc = open(builddir+os.sep+docfile, 'w')
doc.write(doc_pre_xml.replace(
'<!-- ### STATISTICS DATA PLACEHOLDER ### -->',
ElementTree.tostring(variable_tree)))
doc.close()
else:
print('skip generating ' + docfile)
return
def generate_cxx(itemsfile, ccfile, utfile, def_mtime):
global item_list
qr_counter_types = 'enum QRCounterType {\n'
item_names = []
def convert_list(items, qr_counter_types, item_names_current, item_names):
for item in items:
if item['child'] is None:
qr_counter_types += ' ' + item['index'] + ', ' +\
'///< ' + item['description'] + '\n'
item_names_current.append(' { "' + item['name'] +
'", NULL, ' + item['index'] + ' },\n'
)
else:
item_names_current_ = ['const struct CounterTypeTree ' +
item['index'] + '[] = {\n']
qr_counter_types, item_names_current_, item_names = \
convert_list(item['child'], qr_counter_types,
item_names_current_, item_names)
item_names_current_.append(' { NULL, NULL, -1 }\n' +
'};\n')
item_names.extend(item_names_current_)
item_names_current.append(' { "' + item['name'] + '", ' +
item['index'] + ', -1 },\n')
return qr_counter_types, item_names_current, item_names
qr_counter_types, item_names_current, item_names = \
convert_list(item_list, qr_counter_types, [], item_names)
item_names.append('const struct CounterTypeTree QRCounterTree[] = {\n')
item_names.extend(item_names_current)
item_names.append(' { NULL, NULL, -1 }\n' +
'};\n')
qr_counter_types += \
' // End of counter types\n' +\
' QR_COUNTER_TYPES ///< The number of defined counters\n' +\
'};\n'
item_defs = qr_counter_types
item_decls = ''.join(item_names)
if need_generate(builddir+os.sep+itemsfile, def_mtime):
statistics_items_h_pre = open(srcdir+os.sep+itemsfile+pre_suffix, 'r')
items_pre = statistics_items_h_pre.read()
statistics_items_h_pre.close
statistics_items_h = open(builddir+os.sep+itemsfile, 'w')
statistics_items_h.write(items_pre.replace(
'// ### STATISTICS ITEMS DECLARATION ###', item_defs))
statistics_items_h.close()
else:
print('skip generating ' + itemsfile)
if need_generate(builddir+os.sep+ccfile, def_mtime):
statistics_cc_pre = open(srcdir+os.sep+ccfile+pre_suffix, 'r')
items_pre = statistics_cc_pre.read()
statistics_cc_pre.close
statistics_cc = open(builddir+os.sep+ccfile, 'w')
statistics_cc.write(items_pre.replace(
'// ### STATISTICS ITEMS DEFINITION ###', item_decls))
statistics_cc.close()
else:
print('skip generating ' + ccfile)
if need_generate(builddir+os.sep+utfile, def_mtime):
statistics_ut_cc_pre = open(srcdir+os.sep+utfile+pre_suffix, 'r')
items_pre = statistics_ut_cc_pre.read()
statistics_ut_cc_pre.close
statistics_ut_cc = open(builddir+os.sep+utfile, 'w')
statistics_ut_cc.write(items_pre.replace(
'// ### STATISTICS ITEMS DEFINITION ###', item_decls))
statistics_ut_cc.close()
else:
print('skip generating ' + utfile)
return
if __name__ == "__main__":
try:
def_mtime = import_definitions()
generate_specfile('auth.spec', def_mtime)
generate_docfile('b10-auth.xml', def_mtime)
generate_cxx('statistics_items.h',
'statistics.cc',
'tests'+os.sep+'statistics_unittest.cc',
def_mtime)
except:
sys.stderr.write('Code generation failed due to exception: %s\n' %
sys.exc_info()[1])
exit(1)
......@@ -42,7 +42,8 @@ using namespace isc::statistics;
namespace {
void
fillNodes(const Counter& counter, const struct CounterTypeTree type_tree[],
fillNodes(const Counter& counter,
const struct isc::auth::statistics::CounterTypeTree type_tree[],
isc::auth::statistics::Counters::ItemTreeType& trees)
{
using namespace isc::data;
......@@ -68,6 +69,52 @@ namespace isc {
namespace auth {
namespace statistics {
// ### STATISTICS ITEMS DEFINITION ###
const int QROpCodeToQRCounterType[16] = {
QR_OPCODE_QUERY,
QR_OPCODE_IQUERY,
QR_OPCODE_STATUS,
QR_OPCODE_OTHER,
QR_OPCODE_NOTIFY,
QR_OPCODE_UPDATE,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER,
QR_OPCODE_OTHER
};
const int QRRCodeToQRCounterType[23] = {