BIND 10 trac2157_2, updated. 3476033eb79b246bbf0904085f4cab3805d5eddd [2157] avoid using unnamed namespace in header file
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jan 28 13:41:00 UTC 2013
The branch, trac2157_2 has been updated
via 3476033eb79b246bbf0904085f4cab3805d5eddd (commit)
via d792272541407b25dcda463321416d61315d785f (commit)
via f1b061b42a6ea0257f09d45de0243d064497609b (commit)
via ed014f274ce18bcbdb8c79c3ea856a88af23f8e2 (commit)
via daccf2d63231865ce3c5498a4bde4e895f047cd7 (commit)
via dbf019c34b50e415fae366e062bdaa353d873412 (commit)
via 9aaf0f9883c7a67ff2acd8be43afd91e235f7164 (commit)
via ce5cf26e3637a7faf5901debecaf542cdacf69cc (commit)
via c0fa34d5aa68b4d189cfb606373856e6fceb1388 (commit)
via ab9c7fa4343ba35decbf47b765d81ffa785c7638 (commit)
via 702c844a645dd91379d0e6b6896566863291d96f (commit)
via a2cb2c80637696d1268f87660508c6aa8e0e14ec (commit)
via 825e49f101bf3a00de47d0c6e388f00e265f5658 (commit)
via 9cbc650016910ad14ded2b0a4a7fb18f8275085a (commit)
from e3fb3a101e6874ca1c93e46916ab53f278c55642 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3476033eb79b246bbf0904085f4cab3805d5eddd
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 22:38:26 2013 +0900
[2157] avoid using unnamed namespace in header file
commit d792272541407b25dcda463321416d61315d785f
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 22:33:21 2013 +0900
Revert "[2157] pass IP versions and transport protocols with enum"
This reverts commit c2165222deb85cb2ff99a7146b28c659624edc24.
Conflicts:
src/bin/auth/statistics.cc.pre
src/bin/auth/statistics.h
src/bin/auth/tests/statistics_unittest.cc.pre
commit f1b061b42a6ea0257f09d45de0243d064497609b
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 22:04:02 2013 +0900
[2157] added a comment for step.hashes
commit ed014f274ce18bcbdb8c79c3ea856a88af23f8e2
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:50:20 2013 +0900
[2157] added a note to describe response() processes 3 messages
commit daccf2d63231865ce3c5498a4bde4e895f047cd7
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:42:47 2013 +0900
[2157] removed unused helper function from test code
commit dbf019c34b50e415fae366e062bdaa353d873412
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:41:32 2013 +0900
[2157] removed duplicate comment
commit 9aaf0f9883c7a67ff2acd8be43afd91e235f7164
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:36:04 2013 +0900
[2157] use boost::optional for getRequestOpcode()
commit ce5cf26e3637a7faf5901debecaf542cdacf69cc
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:12:42 2013 +0900
[2157] doxygen: Counters::inc() doesn't throw
commit c0fa34d5aa68b4d189cfb606373856e6fceb1388
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:08:54 2013 +0900
[2157] applied patch from 2157#comment:48
commit ab9c7fa4343ba35decbf47b765d81ffa785c7638
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 21:01:42 2013 +0900
[2157] added a note to explain why empty string is required
commit 702c844a645dd91379d0e6b6896566863291d96f
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 20:50:14 2013 +0900
[2157] updated doxygen comments
commit a2cb2c80637696d1268f87660508c6aa8e0e14ec
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 20:46:32 2013 +0900
[2157] rename setResponseSigTSIG to setResponseTSIG
commit 825e49f101bf3a00de47d0c6e388f00e265f5658
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 20:42:55 2013 +0900
[2157] renamed setRequestSig to setRequestTSIG
commit 9cbc650016910ad14ded2b0a4a7fb18f8275085a
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Mon Jan 28 20:38:57 2013 +0900
[2157] updated brief notes; indicate explicitly what is the attribute
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_srv.cc | 16 ++--
src/bin/auth/gen-statisticsitems.py.pre.in | 90 ++++++++++--------
src/bin/auth/statistics.cc.pre | 110 +++++++++++-----------
src/bin/auth/statistics.h | 89 ++++++++---------
src/bin/auth/tests/auth_srv_unittest.cc | 10 +-
src/bin/auth/tests/statistics_unittest.cc.pre | 72 +++++---------
src/bin/auth/tests/statistics_util.cc | 2 -
src/lib/statistics/counter.h | 5 +-
src/lib/statistics/counter_dict.h | 6 +-
tests/lettuce/features/terrain/bind10_control.py | 1 +
10 files changed, 184 insertions(+), 217 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index ff1e90a..6a58cae 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -466,7 +466,7 @@ makeErrorMessage(MessageRenderer& renderer, Message& message,
RendererHolder holder(renderer, &buffer, stats_attrs);
if (tsig_context.get() != NULL) {
message.toWire(renderer, *tsig_context);
- stats_attrs.setResponseSigTSIG(true);
+ stats_attrs.setResponseTSIG(true);
} else {
message.toWire(renderer);
}
@@ -503,13 +503,9 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
MessageAttributes stats_attrs;
stats_attrs.setRequestIPVersion(
- io_message.getRemoteEndpoint().getFamily() == AF_INET ?
- MessageAttributes::IP_VERSION_IPV4 :
- MessageAttributes::IP_VERSION_IPV6);
+ io_message.getRemoteEndpoint().getFamily());
stats_attrs.setRequestTransportProtocol(
- io_message.getRemoteEndpoint().getProtocol() == IPPROTO_UDP ?
- MessageAttributes::TRANSPORT_UDP :
- MessageAttributes::TRANSPORT_TCP);
+ io_message.getRemoteEndpoint().getProtocol());
// First, check the header part. If we fail even for the base header,
// just drop the message.
@@ -567,7 +563,7 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
**impl_->keyring_));
tsig_error = tsig_context->verify(tsig_record, io_message.getData(),
io_message.getDataSize());
- stats_attrs.setRequestSig(true, tsig_error != TSIGError::NOERROR());
+ stats_attrs.setRequestTSIG(true, tsig_error != TSIGError::NOERROR());
}
if (tsig_error != TSIGError::NOERROR()) {
@@ -687,7 +683,7 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message,
renderer_.setLengthLimit(udp_buffer ? remote_bufsize : 65535);
if (tsig_context.get() != NULL) {
message.toWire(renderer_, *tsig_context);
- stats_attrs.setResponseSigTSIG(true);
+ stats_attrs.setResponseTSIG(true);
} else {
message.toWire(renderer_);
}
@@ -819,7 +815,7 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, Message& message,
RendererHolder holder(renderer_, &buffer, stats_attrs);
if (tsig_context.get() != NULL) {
message.toWire(renderer_, *tsig_context);
- stats_attrs.setResponseSigTSIG(true);
+ stats_attrs.setResponseTSIG(true);
} else {
message.toWire(renderer_);
}
diff --git a/src/bin/auth/gen-statisticsitems.py.pre.in b/src/bin/auth/gen-statisticsitems.py.pre.in
index 43f81fd..9a4e626 100755
--- a/src/bin/auth/gen-statisticsitems.py.pre.in
+++ b/src/bin/auth/gen-statisticsitems.py.pre.in
@@ -62,7 +62,7 @@ def import_definitions():
leaf node:
(item name)\t+(internal item counter name)\t+(description of the item)
- Branch nodes contains leaf nodes and/or branch nodes. The end of
+ Branch nodes contain leaf nodes and/or branch nodes. The end of
a branch node is indicated with ';' as item name (first column).
Internal branch name and internal item counter name must be unique.
@@ -219,7 +219,9 @@ def generate_docfile(docfile, def_mtime):
if word == xmldocument_command_name:
command = ElementTree.SubElement(sim_para, 'command')
command.text = word
- # append empty string for trailing text
+ # at this point command.tail is None
+ # append empty string as trailing text for the next
+ # word so it can be concatinated with trailing words
command.tail = ''
prev = command
else:
@@ -275,46 +277,60 @@ def generate_cxx(itemsfile, ccfile, utfile, def_mtime):
Returns nothing.
'''
- msg_counter_types = 'enum MSGCounterType {\n'
+ msg_counter_types = ['enum MSGCounterType {']
item_names = ['// using -1 as counter_id to state it is not a '
- + 'counter item\n']
- item_names += ['const int NOT_ITEM = -1;\n', '\n']
+ + 'counter item']
+ item_names += ['const int NOT_ITEM = -1;', '']
+
+ def convert_list(items, item_head, msg_counter_types, item_names):
+ '''Convert item tree to a set of C++ code fragment in given lists.
+
+ This method recursively builds two lists:
+ - msg_counter_types consists of strings for all leaf items, each
+ defines one enum element with a comment, e.g.
+ COUNTER_ITEM, ///< item's descriptin
+ - item_names consists of tuples of three elements, depending on
+ whether it's a leaf element (no child from it) or not:
+ (leaf) { "item_name", NULL, COUNTER_ITEM },
+ (branch) { "item_name", CHILD_NAME, NOT_ITEM
+
+ Each single call to this function builds a C++ structure beginning
+ with the given item_head, which is a string that reads like
+ 'const struct CounterSpec some_counters[] = {'
+ followed by the item_names tuples corresponding to that level.
+ If some of the items of this level have a child, recursive calls
+ to this function extends msg_counter_types and item_names.
+ item_names for this level will be concatenated at the end end of
+ the given item_names.
- def convert_list(items, msg_counter_types, item_names_current, item_names):
+ '''
+ item_names_current = [item_head]
for item in items:
+ item_spec = ' { "' + item['name'] + '", '
if item['child'] is None:
- msg_counter_types += ' ' + item['index'] + ', ' +\
- '///< ' + item['description'] + '\n'
- item_names_current.append(' { "' + item['name'] +
- '", NULL, ' + item['index'] + ' },\n'
- )
+ item_spec += 'NULL, ' + item['index']
+ msg_counter_types.append(' ' + item['index'] + ', ' +
+ '///< ' + item['description'])
else:
- item_names_current_ = ['const struct CounterSpec ' +
- item['index'] + '[] = {\n']
- msg_counter_types, item_names_current_, item_names = \
- convert_list(item['child'], msg_counter_types,
- item_names_current_, item_names)
- item_names_current_.append(' { NULL, NULL, NOT_ITEM }\n' +
- '};\n')
- item_names.extend(item_names_current_)
- item_names_current.append(' { "' + item['name'] + '", ' +
- item['index'] + ', NOT_ITEM },\n')
- return msg_counter_types, item_names_current, item_names
-
- msg_counter_types, item_names_current, item_names = \
- convert_list(item_list, msg_counter_types, [], item_names)
- item_names.append('const struct CounterSpec msg_counter_tree[] = {\n')
- item_names.extend(item_names_current)
- item_names.append(' { NULL, NULL, NOT_ITEM }\n' +
- '};\n')
-
- msg_counter_types += \
- ' // End of counter types\n' +\
- ' MSG_COUNTER_TYPES ///< The number of defined counters\n' +\
- '};\n'
-
- item_decls = msg_counter_types
- item_defs = ''.join(item_names)
+ item_spec += item['index'] + ', NOT_ITEM'
+ child_head = 'const struct CounterSpec ' + \
+ item['index'] + '[] = {'
+ convert_list(item['child'], child_head,
+ msg_counter_types, item_names)
+ item_names_current.append(item_spec + ' },')
+
+ item_names_current.append(' { NULL, NULL, NOT_ITEM }\n};')
+ item_names.extend(item_names_current)
+
+ convert_list(item_list, 'const struct CounterSpec msg_counter_tree[] = {',
+ msg_counter_types, item_names)
+ msg_counter_types.extend([
+ ' // End of counter types',
+ ' MSG_COUNTER_TYPES ///< The number of defined counters',
+ '};'])
+
+ item_decls = '\n'.join(msg_counter_types)
+ item_defs = '\n'.join(item_names)
if need_generate(builddir+os.sep+itemsfile,
srcdir+os.sep+itemsfile+pre_suffix, def_mtime):
diff --git a/src/bin/auth/statistics.cc.pre b/src/bin/auth/statistics.cc.pre
index 707a9ba..24a28d2 100644
--- a/src/bin/auth/statistics.cc.pre
+++ b/src/bin/auth/statistics.cc.pre
@@ -24,6 +24,14 @@
#include <statistics/counter.h>
+#include <boost/optional.hpp>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
using namespace isc::dns;
using namespace isc::auth;
using namespace isc::statistics;
@@ -118,16 +126,16 @@ Counters::Counters() :
void
Counters::incRequest(const MessageAttributes& msgattrs) {
// protocols carrying request
- server_msg_counter_.inc(
- msgattrs.getRequestIPVersion() ==
- MessageAttributes::IP_VERSION_IPV4 ?
- MSG_REQUEST_IPV4 :
- MSG_REQUEST_IPV6);
- server_msg_counter_.inc(
- msgattrs.getRequestTransportProtocol() ==
- MessageAttributes::TRANSPORT_UDP ?
- MSG_REQUEST_UDP :
- MSG_REQUEST_TCP);
+ if (msgattrs.getRequestIPVersion() == AF_INET) {
+ server_msg_counter_.inc(MSG_REQUEST_IPV4);
+ } else if (msgattrs.getRequestIPVersion() == AF_INET6) {
+ server_msg_counter_.inc(MSG_REQUEST_IPV6);
+ }
+ if (msgattrs.getRequestTransportProtocol() == IPPROTO_UDP) {
+ server_msg_counter_.inc(MSG_REQUEST_UDP);
+ } else if (msgattrs.getRequestTransportProtocol() == IPPROTO_TCP) {
+ server_msg_counter_.inc(MSG_REQUEST_TCP);
+ }
// request TSIG
if (msgattrs.getRequestSigTSIG()) {
@@ -151,14 +159,11 @@ Counters::incRequest(const MessageAttributes& msgattrs) {
}
// OPCODE
- try {
- server_msg_counter_.inc(
- opcode_to_msgcounter[msgattrs.getRequestOpCode().getCode()]);
- } catch (const isc::InvalidOperation& ex) {
- // The exception will be thrown if OpCode is not set
- // (e.g. message is short).
- // Increment MSG_OPCODE_OTHER.
- server_msg_counter_.inc(MSG_OPCODE_OTHER);
+ const boost::optional<const isc::dns::Opcode&> opcode =
+ msgattrs.getRequestOpCode();
+ // Increment opcode counter only if the opcode exists.
+ if (opcode) {
+ server_msg_counter_.inc(opcode_to_msgcounter[opcode.get().getCode()]);
}
}
@@ -181,7 +186,7 @@ Counters::incResponse(const MessageAttributes& msgattrs,
}
// response TSIG
- if (msgattrs.getResponseSigTSIG()) {
+ if (msgattrs.getResponseTSIG()) {
server_msg_counter_.inc(MSG_RESPONSE_TSIG);
}
@@ -198,47 +203,42 @@ Counters::incResponse(const MessageAttributes& msgattrs,
server_msg_counter_.inc(MSG_REQUEST_BADEDNSVER);
}
- try {
- if (msgattrs.getRequestOpCode() == Opcode::QUERY()) {
- // compound attributes
- const unsigned int answer_rrs =
- response.getRRCount(Message::SECTION_ANSWER);
- const bool is_aa_set =
- response.getHeaderFlag(Message::HEADERFLAG_AA);
-
- if (is_aa_set) {
- // QryAuthAns
- server_msg_counter_.inc(MSG_QRYAUTHANS);
- } else {
- // QryNoAuthAns
- server_msg_counter_.inc(MSG_QRYNOAUTHANS);
- }
+ const boost::optional<const isc::dns::Opcode&> opcode =
+ msgattrs.getRequestOpCode();
+ if (opcode && opcode.get() == Opcode::QUERY()) {
+ // compound attributes
+ const unsigned int answer_rrs =
+ response.getRRCount(Message::SECTION_ANSWER);
+ const bool is_aa_set =
+ response.getHeaderFlag(Message::HEADERFLAG_AA);
+
+ if (is_aa_set) {
+ // QryAuthAns
+ server_msg_counter_.inc(MSG_QRYAUTHANS);
+ } else {
+ // QryNoAuthAns
+ server_msg_counter_.inc(MSG_QRYNOAUTHANS);
+ }
- if (rcode == Rcode::NOERROR_CODE) {
- if (answer_rrs > 0) {
- // QrySuccess
- server_msg_counter_.inc(MSG_QRYSUCCESS);
+ if (rcode == Rcode::NOERROR_CODE) {
+ if (answer_rrs > 0) {
+ // QrySuccess
+ server_msg_counter_.inc(MSG_QRYSUCCESS);
+ } else {
+ if (is_aa_set) {
+ // QryNxrrset
+ server_msg_counter_.inc(MSG_QRYNXRRSET);
} else {
- if (is_aa_set) {
- // QryNxrrset
- server_msg_counter_.inc(MSG_QRYNXRRSET);
- } else {
- // QryReferral
- server_msg_counter_.inc(MSG_QRYREFERRAL);
- }
- }
- } else if (rcode == Rcode::REFUSED_CODE) {
- if (!response.getHeaderFlag(Message::HEADERFLAG_RD)) {
- // AuthRej
- server_msg_counter_.inc(MSG_QRYREJECT);
+ // QryReferral
+ server_msg_counter_.inc(MSG_QRYREFERRAL);
}
}
+ } else if (rcode == Rcode::REFUSED_CODE) {
+ if (!response.getHeaderFlag(Message::HEADERFLAG_RD)) {
+ // AuthRej
+ server_msg_counter_.inc(MSG_QRYREJECT);
+ }
}
- } catch (const isc::InvalidOperation& ex) {
- // The exception will be thrown if OpCode is not set
- // (e.g. message is short).
- // Do not increment the counters above since they are incremented
- // only if Opcode is Query.
}
}
diff --git a/src/bin/auth/statistics.h b/src/bin/auth/statistics.h
index 7a096b1..7e7a53a 100644
--- a/src/bin/auth/statistics.h
+++ b/src/bin/auth/statistics.h
@@ -54,8 +54,8 @@ public:
};
private:
// request attributes
- IPVersionType req_ip_version_; // IP version
- TransportProtocolType req_transport_protocol_; // Transport layer protocol
+ int req_ip_version_; // IP version
+ int req_transport_protocol_; // Transport layer protocol
boost::optional<isc::dns::Opcode> req_opcode_; // OpCode
enum BitAttributes {
REQ_WITH_EDNS_0, // request with EDNS ver.0
@@ -71,19 +71,17 @@ public:
/// \brief The constructor.
///
/// \throw None
- MessageAttributes() :
- req_ip_version_(IP_VERSION_UNSPEC),
- req_transport_protocol_(TRANSPORT_UNSPEC)
+ MessageAttributes() : req_ip_version_(0), req_transport_protocol_(0)
{}
/// \brief Return opcode of the request.
- /// \return opcode of the request
+ /// \return opcode of the request wrapped with boost::optional
/// \throw isc::InvalidOperation Opcode is not set
- const isc::dns::Opcode& getRequestOpCode() const {
+ const boost::optional<const isc::dns::Opcode&> getRequestOpCode() const {
if (req_opcode_) {
return (req_opcode_.get());
} else {
- isc_throw(isc::InvalidOperation, "Opcode is not set");
+ return boost::none;
}
}
@@ -94,50 +92,43 @@ public:
req_opcode_ = opcode;
}
- /// \brief Return IP version carrying the request.
- /// \return IP version carrying the request
+ /// \brief Get IP version carrying a request.
+ /// \return IP version carrying a request (AF_INET or AF_INET6)
/// \throw None
- IPVersionType getRequestIPVersion() const {
+ int getRequestIPVersion() const {
return (req_ip_version_);
}
- /// \brief Set IP version carrying the request.
- /// \param ip_version IP version carrying the request
- /// \throw isc::InvalidParameter ip_version is invalid
- void setRequestIPVersion(const IPVersionType ip_version) {
- if (ip_version == IP_VERSION_UNSPEC) {
- isc_throw(isc::InvalidParameter, "Invalid IP version");
- }
+ /// \brief Set IP version carrying a request.
+ /// \param ip_version AF_INET or AF_INET6
+ /// \throw None
+ void setRequestIPVersion(const int ip_version) {
req_ip_version_ = ip_version;
}
- /// \brief Return transport protocol carrying the request.
- /// \return Transport protocol carrying the request
+ /// \brief Get transport protocol carrying a request.
+ /// \return Transport protocol carrying a request
+ /// (IPPROTO_UDP or IPPROTO_TCP)
/// \throw None
- TransportProtocolType getRequestTransportProtocol() const {
+ int getRequestTransportProtocol() const {
return (req_transport_protocol_);
}
- /// \brief Set transport protocol carrying the request.
- /// \param transport_protocol Transport protocol carrying the request
- /// \throw isc::InvalidParameter transport_protocol is invalid
- void setRequestTransportProtocol(
- const TransportProtocolType transport_protocol)
- {
- if (transport_protocol == TRANSPORT_UNSPEC) {
- isc_throw(isc::InvalidParameter, "Invalid transport protocol");
- }
+ /// \brief Set transport protocol carrying a request.
+ /// \param transport_protocol IPPROTO_UDP or IPPROTO_TCP
+ /// \throw None
+ void setRequestTransportProtocol(const int transport_protocol) {
req_transport_protocol_ = transport_protocol;
}
- /// \brief Return EDNS attribute of the request.
+ /// \brief Return whether EDNS version of the request is 0 or not.
/// \return true if EDNS version of the request is 0
/// \throw None
bool getRequestEDNS0() const {
return (bit_attributes_[REQ_WITH_EDNS_0]);
}
- /// \brief Set EDNS attribute of the request.
+ /// \brief Set whether EDNS version of the request is 0 or not.
/// \param with_edns_0 true if EDNS version of the request is 0
/// \throw None
void setRequestEDNS0(const bool with_edns_0) {
@@ -152,20 +143,20 @@ public:
}
/// \brief Set DNSSEC OK (DO) bit of the request.
- /// \param is_dnssec_ok true if DNSSEC OK (DO) bit of the request is set
+ /// \param with_dnssec_ok true if DNSSEC OK (DO) bit of the request is set
/// \throw None
void setRequestDO(const bool with_dnssec_ok) {
bit_attributes_[REQ_WITH_DNSSEC_OK] = with_dnssec_ok;
}
- /// \brief Return TSIG attribute of the request.
+ /// \brief Return whether the request is TSIG signed or not.
/// \return true if the request is TSIG signed
/// \throw None
bool getRequestSigTSIG() const {
return (bit_attributes_[REQ_TSIG_SIGNED]);
}
- /// \brief Return the status of the signature of the request.
+ /// \brief Return whether the signature of the request is bad or not.
/// \return true if the signature of the request is bad
/// \throw None
bool getRequestSigBadSig() const {
@@ -173,12 +164,12 @@ public:
}
/// \brief Set TSIG attributes of the request.
- /// \param is_tsig true if the request is TSIG signed
- /// \param is_badsig true if the signature of the request is bad
+ /// \param signed_tsig true if the request is signed with TSIG
+ /// \param badsig true if the signature of the request is bad
/// \throw None
- void setRequestSig(const bool tsig_signed, const bool badsig) {
- assert(!(!tsig_signed && badsig));
- bit_attributes_[REQ_TSIG_SIGNED] = tsig_signed;
+ void setRequestTSIG(const bool signed_tsig, const bool badsig) {
+ assert(!(!signed_tsig && badsig));
+ bit_attributes_[REQ_TSIG_SIGNED] = signed_tsig;
bit_attributes_[REQ_BADSIG] = badsig;
}
@@ -196,17 +187,17 @@ public:
bit_attributes_[RES_IS_TRUNCATED] = is_truncated;
}
- /// \brief Return TSIG attributes of the response.
- /// \return true if the response is TSIG signed
+ /// \brief Return whether the response is TSIG signed or not.
+ /// \return true if the response is signed with TSIG
/// \throw None
- bool getResponseSigTSIG() const {
+ bool getResponseTSIG() const {
return (bit_attributes_[RES_TSIG_SIGNED]);
}
- /// \brief Set TSIG attributes of the response.
- /// \param is_tsig_signed true if the response is TSIG signed
+ /// \brief Set whether the response is TSIG signed or not.
+ /// \param signed_tsig true if the response is signed with TSIG
/// \throw None
- void setResponseSigTSIG(const bool signed_tsig) {
+ void setResponseTSIG(const bool signed_tsig) {
bit_attributes_[RES_TSIG_SIGNED] = signed_tsig;
}
};
@@ -233,7 +224,6 @@ class Counters : boost::noncopyable {
private:
// counter for DNS message attributes
isc::statistics::Counter server_msg_counter_;
-
void incRequest(const MessageAttributes& msgattrs);
void incResponse(const MessageAttributes& msgattrs,
const isc::dns::Message& response);
@@ -262,13 +252,12 @@ public:
/// \brief Increment counters according to the parameters.
///
- /// This method is mostly exception free. But it may still throw a
- /// standard exception if memory allocation fails inside the method.
- ///
/// \param msgattrs DNS message attributes.
/// \param response DNS response message.
/// \param done DNS response was sent to the client.
///
+ /// \throw None
+ ///
void inc(const MessageAttributes& msgattrs,
const isc::dns::Message& response, const bool done);
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index f6d357c..70f98fb 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -135,12 +135,6 @@ protected:
rcode_value;
}
- // Checks whether all Rcode counters are set to zero
- void checkAllRcodeCountersZero() const {
- // with checking NOERROR == 0 and the others are 0
- checkAllRcodeCountersZeroExcept(Rcode::NOERROR(), 0);
- }
-
// Checks whether all Rcode counters are set to zero except the given
// rcode (it is checked to be set to 'value')
void checkAllRcodeCountersZeroExcept(const Rcode& rcode, int value) const {
@@ -295,13 +289,13 @@ TEST_F(AuthSrvTest, shortMessage) {
std::map<std::string, int> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
- expect["opcode.other"] = 1;
checkStatisticsCounters(stats_after, expect);
}
// Response messages. Must be silently dropped, whether it's a valid response
// or malformed or could otherwise cause a protocol error.
TEST_F(AuthSrvTest, response) {
+ // isc::testutils::SrvTestBase::response() processes 3 messages.
response();
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
@@ -309,7 +303,6 @@ TEST_F(AuthSrvTest, response) {
std::map<std::string, int> expect;
expect["request.v4"] = 3;
expect["request.udp"] = 3;
- expect["opcode.other"] = 3;
checkStatisticsCounters(stats_after, expect);
}
@@ -335,7 +328,6 @@ TEST_F(AuthSrvTest, ednsBadVers) {
expect["request.v4"] = 1;
expect["request.badednsver"] = 1;
expect["request.udp"] = 1;
- expect["opcode.other"] = 1;
expect["responses"] = 1;
expect["rcode.badvers"] = 1;
checkStatisticsCounters(stats_after, expect);
diff --git a/src/bin/auth/tests/statistics_unittest.cc.pre b/src/bin/auth/tests/statistics_unittest.cc.pre
index 86a7180..e6b3aa0 100644
--- a/src/bin/auth/tests/statistics_unittest.cc.pre
+++ b/src/bin/auth/tests/statistics_unittest.cc.pre
@@ -56,37 +56,23 @@ protected:
void
buildSkeletonMessage(MessageAttributes& msgattrs) {
- msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_IPV4);
- msgattrs.setRequestTransportProtocol(MessageAttributes::TRANSPORT_UDP);
+ msgattrs.setRequestIPVersion(AF_INET);
+ msgattrs.setRequestTransportProtocol(IPPROTO_UDP);
msgattrs.setRequestOpCode(Opcode::QUERY());
msgattrs.setRequestEDNS0(true);
msgattrs.setRequestDO(true);
}
-TEST_F(CountersTest, invalidParameter) {
- MessageAttributes msgattrs;
-
- // Passing *_UNSPEC should trigger throwing an exception
- // isc::InvalidParameter.
- EXPECT_THROW(
- msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_UNSPEC),
- isc::InvalidParameter);
- EXPECT_THROW(
- msgattrs.setRequestTransportProtocol(
- MessageAttributes::TRANSPORT_UNSPEC),
- isc::InvalidParameter);
-}
-
TEST_F(CountersTest, invalidOperationForGetRequestOpCode) {
MessageAttributes msgattrs;
- // getRequestOpCode() will throw isc::InvalidOperation when called before
+ // getRequestOpCode() should return boost::none when called before
// opcode is set with setRequestOpCode().
- EXPECT_THROW(msgattrs.getRequestOpCode(), isc::InvalidOperation);
+ EXPECT_FALSE(msgattrs.getRequestOpCode());
msgattrs.setRequestOpCode(Opcode::QUERY());
- // getRequestOpCode() will not throw at this point.
- EXPECT_NO_THROW(msgattrs.getRequestOpCode());
+ // getRequestOpCode() should be Opcode::QUERY.
+ EXPECT_EQ(Opcode::QUERY(), msgattrs.getRequestOpCode().get());
}
TEST_F(CountersTest, incrementResponse) {
@@ -137,17 +123,11 @@ TEST_F(CountersTest, incrementProtocolType) {
// ipv6 tcp
int count_v4 = 0, count_v6 = 0, count_udp = 0, count_tcp = 0;
for (int i = 0; i < 4; ++i) {
- const enum MessageAttributes::IPVersionType ipversion =
- (i & 1) != 0 ?
- MessageAttributes::IP_VERSION_IPV4 :
- MessageAttributes::IP_VERSION_IPV6;
- const enum MessageAttributes::TransportProtocolType proto =
- (i & 2) != 0 ?
- MessageAttributes::TRANSPORT_UDP :
- MessageAttributes::TRANSPORT_TCP;
+ const int af = i & 1 ? AF_INET : AF_INET6;
+ const int proto = i & 2 ? IPPROTO_UDP : IPPROTO_TCP;
buildSkeletonMessage(msgattrs);
- msgattrs.setRequestIPVersion(ipversion);
+ msgattrs.setRequestIPVersion(af);
msgattrs.setRequestTransportProtocol(proto);
response.setRcode(Rcode::REFUSED());
@@ -157,12 +137,12 @@ TEST_F(CountersTest, incrementProtocolType) {
counters.inc(msgattrs, response, true);
- if (ipversion == MessageAttributes::IP_VERSION_IPV4) {
+ if (af == AF_INET) {
++count_v4;
} else {
++count_v6;
}
- if (proto == MessageAttributes::TRANSPORT_UDP) {
+ if (proto == IPPROTO_UDP) {
++count_udp;
} else {
++count_tcp;
@@ -297,8 +277,8 @@ TEST_F(CountersTest, incrementTSIG) {
const bool is_res_tsig = (i & 1) != 0;
const bool is_badsig = (i & 2) != 0;
buildSkeletonMessage(msgattrs);
- msgattrs.setRequestSig(is_req_tsig, is_badsig);
- msgattrs.setResponseSigTSIG(is_res_tsig);
+ msgattrs.setRequestTSIG(is_req_tsig, is_badsig);
+ msgattrs.setResponseTSIG(is_res_tsig);
response.setRcode(Rcode::REFUSED());
response.addQuestion(Question(Name("example.com"),
@@ -352,7 +332,7 @@ TEST_F(CountersTest, incrementOpcode) {
{
buildSkeletonMessage(msgattrs);
msgattrs.setRequestOpCode(Opcode(i));
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode::REFUSED());
response.addQuestion(Question(Name("example.com"),
@@ -408,7 +388,7 @@ TEST_F(CountersTest, incrementRcode) {
{
buildSkeletonMessage(msgattrs);
msgattrs.setRequestOpCode(Opcode::IQUERY());
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode(i));
response.addQuestion(Question(Name("example.com"),
@@ -469,7 +449,7 @@ TEST_F(CountersTest, incrementTruncated) {
const bool is_truncated = i & 1;
buildSkeletonMessage(msgattrs);
msgattrs.setRequestOpCode(Opcode::IQUERY());
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
msgattrs.setResponseTruncated(is_truncated);
response.setRcode(Rcode::SERVFAIL());
@@ -512,7 +492,7 @@ TEST_F(CountersTest, incrementQryAuthAnsAndNoAuthAns) {
for (int i = 0; i < 2; ++i) {
const bool is_aa_set = i & 1;
buildSkeletonMessage(msgattrs);
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode::SERVFAIL());
response.addQuestion(Question(Name("example.com"),
@@ -548,12 +528,12 @@ TEST_F(CountersTest, incrementQrySuccess) {
std::map<std::string, int> expect;
// Opcode = QUERY, Rcode = NOERROR, ANCOUNT > 0
- msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_IPV4);
- msgattrs.setRequestTransportProtocol(MessageAttributes::TRANSPORT_UDP);
+ msgattrs.setRequestIPVersion(AF_INET);
+ msgattrs.setRequestTransportProtocol(IPPROTO_UDP);
msgattrs.setRequestOpCode(Opcode::QUERY());
msgattrs.setRequestEDNS0(true);
msgattrs.setRequestDO(true);
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode::NOERROR());
response.addQuestion(Question(Name("example.com"),
@@ -598,12 +578,12 @@ TEST_F(CountersTest, incrementQryReferralAndNxrrset) {
int count_referral = 0, count_nxrrset = 0;
for (int i = 0; i < 2; ++i) {
const bool is_aa_set = i & 1;
- msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_IPV4);
- msgattrs.setRequestTransportProtocol(MessageAttributes::TRANSPORT_UDP);
+ msgattrs.setRequestIPVersion(AF_INET);
+ msgattrs.setRequestTransportProtocol(IPPROTO_UDP);
msgattrs.setRequestOpCode(Opcode::QUERY());
msgattrs.setRequestEDNS0(true);
msgattrs.setRequestDO(true);
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode::NOERROR());
response.addQuestion(Question(Name("example.com"),
@@ -642,12 +622,12 @@ TEST_F(CountersTest, incrementAuthQryRej) {
std::map<std::string, int> expect;
// Opcode = QUERY, Rcode = REFUSED, ANCOUNT = 0 (don't care)
- msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_IPV4);
- msgattrs.setRequestTransportProtocol(MessageAttributes::TRANSPORT_UDP);
+ msgattrs.setRequestIPVersion(AF_INET);
+ msgattrs.setRequestTransportProtocol(IPPROTO_UDP);
msgattrs.setRequestOpCode(Opcode::QUERY());
msgattrs.setRequestEDNS0(true);
msgattrs.setRequestDO(true);
- msgattrs.setRequestSig(false, false);
+ msgattrs.setRequestTSIG(false, false);
response.setRcode(Rcode::REFUSED());
response.addQuestion(Question(Name("example.com"),
diff --git a/src/bin/auth/tests/statistics_util.cc b/src/bin/auth/tests/statistics_util.cc
index 8aca25a..bb2cd5c 100644
--- a/src/bin/auth/tests/statistics_util.cc
+++ b/src/bin/auth/tests/statistics_util.cc
@@ -49,8 +49,6 @@ namespace isc {
namespace auth {
namespace unittest {
-// Test if the counters has expected values specified in expect and the others
-// are zero.
void
checkStatisticsCounters(const isc::data::ConstElementPtr counters,
const std::map<std::string, int>& expect)
diff --git a/src/lib/statistics/counter.h b/src/lib/statistics/counter.h
index 6ed05de..186b294 100644
--- a/src/lib/statistics/counter.h
+++ b/src/lib/statistics/counter.h
@@ -22,10 +22,6 @@
#include <vector>
-namespace {
-const unsigned int InitialValue = 0;
-} // anonymous namespace
-
namespace isc {
namespace statistics {
@@ -36,6 +32,7 @@ public:
private:
std::vector<Counter::Value> counters_;
+ static const unsigned int InitialValue = 0;
public:
/// The constructor.
diff --git a/src/lib/statistics/counter_dict.h b/src/lib/statistics/counter_dict.h
index 594418a..6fb74ce 100644
--- a/src/lib/statistics/counter_dict.h
+++ b/src/lib/statistics/counter_dict.h
@@ -31,16 +31,14 @@
#include <iterator>
#include <utility>
-namespace {
-typedef boost::shared_ptr<isc::statistics::Counter> CounterPtr;
-typedef std::map<std::string, CounterPtr> DictionaryMap;
-}
namespace isc {
namespace statistics {
class CounterDictionary : boost::noncopyable {
private:
+ typedef boost::shared_ptr<isc::statistics::Counter> CounterPtr;
+ typedef std::map<std::string, CounterPtr> DictionaryMap;
DictionaryMap dictionary_;
std::vector<std::string> elements_;
const size_t items_;
diff --git a/tests/lettuce/features/terrain/bind10_control.py b/tests/lettuce/features/terrain/bind10_control.py
index 50b165d..7e71abb 100644
--- a/tests/lettuce/features/terrain/bind10_control.py
+++ b/tests/lettuce/features/terrain/bind10_control.py
@@ -468,6 +468,7 @@ def check_statistics_items(step, category, has_except_for):
stats = flatten(parse_bindctl_output_as_data_structure())
if has_except_for:
+ # fetch step tables in the scnario as hashes
for item in step.hashes:
name = category+'.'+item['item_name']
value = item['item_value']
More information about the bind10-changes
mailing list