Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
57f3e532
Commit
57f3e532
authored
Jan 29, 2013
by
JINMEI Tatuya
Browse files
[master] Merge branch 'trac2310'
parents
5cfbdc70
31707f9f
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/datasrc_messages.mes
View file @
57f3e532
...
...
@@ -197,6 +197,16 @@ modify the database). This is what the client would do when such RRs
were given in a DNS response according to RFC2181. The data in
database should be checked and fixed.
% DATASRC_DATABASE_JOURNALREADER_BADDATA failed to convert a diff to RRset in %1/%2 on %3 between %4 and %5: %6
This is an error message indicating that a zone's diff is broken and
the data source library failed to convert it to a valid RRset. The
most likely cause of this is that someone has manually modified the
zone's diff in the database and inserted invalid data as a result.
The zone's name and class, database name, and the start and end
serials, and an additional detail of the error are shown in the
message. The administrator should examine the diff in the database
to find any invalid data and fix it.
% DATASRC_DATABASE_JOURNALREADER_END %1/%2 on %3 from %4 to %5
This is a debug message indicating that the program (successfully)
reaches the end of sequences of a zone's differences. The zone's name
...
...
@@ -215,16 +225,6 @@ a zone's difference sequences from a database-based data source. The
zone's name and class, database name, and the start and end serials
are shown in the message.
% DATASRC_DATABASE_JOURNALREADER_BADDATA failed to convert a diff to RRset in %1/%2 on %3 between %4 and %5: %6
This is an error message indicating that a zone's diff is broken and
the data source library failed to convert it to a valid RRset. The
most likely cause of this is that someone has manually modified the
zone's diff in the database and inserted invalid data as a result.
The zone's name and class, database name, and the start and end
serials, and an additional detail of the error are shown in the
message. The administrator should examine the diff in the database
to find any invalid data and fix it.
% DATASRC_DATABASE_NO_MATCH not match for %2/%3/%4 in %1
No match (not even a wildcard) was found in the named data source for the given
name/type/class in the data source.
...
...
@@ -442,6 +442,10 @@ shown name, the search tries the superdomain name that share the shown
www.example.com. with shown label count of 3, example.com. is being
tried).
% DATASRC_MEM_FIND_TYPE_AT_ORIGIN origin query for type %1 in in-memory zone %2/%3 successful
Debug information. A specific type RRset is requested at a zone origin
of an in-memory zone and it is found.
% DATASRC_MEM_FIND_ZONE looking for zone '%1'
Debug information. A zone object for this zone is being searched for in the
in-memory data source.
...
...
src/lib/datasrc/memory/treenode_rrset.cc
View file @
57f3e532
...
...
@@ -59,8 +59,7 @@ TreeNodeRRset::getName() const {
const
RRTTL
&
TreeNodeRRset
::
getTTL
()
const
{
if
(
ttl_
==
NULL
)
{
util
::
InputBuffer
ttl_buffer
(
rdataset_
->
getTTLData
(),
sizeof
(
uint32_t
));
util
::
InputBuffer
ttl_buffer
(
ttl_data_
,
sizeof
(
uint32_t
));
ttl_
=
new
RRTTL
(
ttl_buffer
);
}
...
...
@@ -169,7 +168,7 @@ TreeNodeRRset::toWire(AbstractMessageRenderer& renderer) const {
// Render the main (non RRSIG) RRs
const
size_t
rendered_rdata_count
=
writeRRs
(
renderer
,
rdataset_
->
getRdataCount
(),
name_labels
,
rdataset_
->
type
,
rrclass_
,
rdataset_
->
getTTLD
ata
()
,
reader
,
rdataset_
->
type
,
rrclass_
,
ttl_d
ata
_
,
reader
,
&
RdataReader
::
iterateRdata
);
if
(
renderer
.
isTruncated
())
{
return
(
rendered_rdata_count
);
...
...
@@ -180,7 +179,7 @@ TreeNodeRRset::toWire(AbstractMessageRenderer& renderer) const {
// Render any RRSIGs, if we supposed to do so
const
size_t
rendered_rrsig_count
=
dnssec_ok_
?
writeRRs
(
renderer
,
rrsig_count_
,
name_labels
,
RRType
::
RRSIG
(),
rrclass_
,
rdataset_
->
getTTLD
ata
()
,
reader
,
rrclass_
,
ttl_d
ata
_
,
reader
,
&
RdataReader
::
iterateSingleSig
)
:
0
;
return
(
rendered_rdata_count
+
rendered_rrsig_count
);
...
...
src/lib/datasrc/memory/treenode_rrset.h
View file @
57f3e532
...
...
@@ -112,12 +112,34 @@ public:
const
RdataSet
*
rdataset
,
bool
dnssec_ok
)
:
node_
(
node
),
rdataset_
(
rdataset
),
rrsig_count_
(
rdataset_
->
getSigRdataCount
()),
rrclass_
(
rrclass
),
dnssec_ok_
(
dnssec_ok
),
name_
(
NULL
),
realname_
(
NULL
),
ttl_
(
NULL
)
dnssec_ok_
(
dnssec_ok
),
name_
(
NULL
),
realname_
(
NULL
),
ttl_data_
(
rdataset
->
getTTLData
()),
ttl_
(
NULL
)
{}
/// \brief Constructor with a specific TTL.
///
/// This constructor is mostly the same as the normal version, but takes
/// an extra parameter, \c ttl_data. It's expected to point to a memory
/// region at least for 32 bits, and the corresponding 32-bit data will
/// be used as wire-format TTL value of the RRset, instead of the TTL
/// associated with \c rdataset.
///
/// It's the caller's responsibility to guarantee the memory region is
/// valid and intact throughout the lifetime of the RRset.
///
/// \throw None
TreeNodeRRset
(
const
dns
::
RRClass
&
rrclass
,
const
ZoneNode
*
node
,
const
RdataSet
*
rdataset
,
bool
dnssec_ok
,
const
void
*
ttl_data
)
:
node_
(
node
),
rdataset_
(
rdataset
),
rrsig_count_
(
rdataset_
->
getSigRdataCount
()),
rrclass_
(
rrclass
),
dnssec_ok_
(
dnssec_ok
),
name_
(
NULL
),
realname_
(
NULL
),
ttl_data_
(
ttl_data
),
ttl_
(
NULL
)
{}
/// \brief Constructor for wildcard-expanded owner name.
///
/// This constructor is mostly the same as the
other
version, but takes
/// This constructor is mostly the same as the
normal
version, but takes
/// an extra parameter, \c realname. It effectively overrides the owner
/// name of the RRset; wherever the owner name is used (e.g., in the
/// \c toWire() method), the specified name will be used instead of
...
...
@@ -133,7 +155,7 @@ public:
node_
(
node
),
rdataset_
(
rdataset
),
rrsig_count_
(
rdataset_
->
getSigRdataCount
()),
rrclass_
(
rrclass
),
dnssec_ok_
(
dnssec_ok
),
name_
(
NULL
),
realname_
(
new
dns
::
Name
(
realname
)),
ttl_
(
NULL
)
ttl_data_
(
rdataset
->
getTTLData
()),
ttl_
(
NULL
)
{}
virtual
~
TreeNodeRRset
()
{
...
...
@@ -255,6 +277,7 @@ private:
const
bool
dnssec_ok_
;
mutable
dns
::
Name
*
name_
;
const
dns
::
Name
*
const
realname_
;
const
void
*
const
ttl_data_
;
mutable
dns
::
RRTTL
*
ttl_
;
};
...
...
src/lib/datasrc/memory/zone_data.cc
View file @
57f3e532
...
...
@@ -134,6 +134,31 @@ NSEC3Data::insertName(util::MemorySegment& mem_sgmt, const Name& name,
result
==
ZoneTree
::
ALREADYEXISTS
)
&&
node
!=
NULL
);
}
namespace
{
// A helper to convert a TTL value in network byte order and set it in
// ZoneData::min_ttl_. We can use util::OutputBuffer, but copy the logic
// here to guarantee it is exception free.
// Note: essentially this function is a local (re)implementation of the
// standard htonl() library function, but we avoid relying on it in case it's
// not available (it's not in the C++ standard library).
void
setTTLInNetOrder
(
uint32_t
val
,
uint32_t
*
result
)
{
uint8_t
buf
[
4
];
buf
[
0
]
=
static_cast
<
uint8_t
>
((
val
&
0xff000000
)
>>
24
);
buf
[
1
]
=
static_cast
<
uint8_t
>
((
val
&
0x00ff0000
)
>>
16
);
buf
[
2
]
=
static_cast
<
uint8_t
>
((
val
&
0x0000ff00
)
>>
8
);
buf
[
3
]
=
static_cast
<
uint8_t
>
(
val
&
0x000000ff
);
std
::
memcpy
(
result
,
buf
,
sizeof
(
*
result
));
}
}
ZoneData
::
ZoneData
(
ZoneTree
*
zone_tree
,
ZoneNode
*
origin_node
)
:
zone_tree_
(
zone_tree
),
origin_node_
(
origin_node
),
min_ttl_
(
0
)
// tentatively set to silence static checkers
{
setTTLInNetOrder
(
RRTTL
::
MAX_TTL
().
getValue
(),
&
min_ttl_
);
}
ZoneData
*
ZoneData
::
create
(
util
::
MemorySegment
&
mem_sgmt
,
const
Name
&
zone_origin
)
{
// ZoneTree::insert() and ZoneData allocation can throw. See also
...
...
@@ -178,6 +203,11 @@ ZoneData::insertName(util::MemorySegment& mem_sgmt, const Name& name,
result
==
ZoneTree
::
ALREADYEXISTS
)
&&
node
!=
NULL
);
}
void
ZoneData
::
setMinTTL
(
uint32_t
min_ttl_val
)
{
setTTLInNetOrder
(
min_ttl_val
,
&
min_ttl_
);
}
}
// namespace memory
}
// namespace datasrc
}
// datasrc isc
src/lib/datasrc/memory/zone_data.h
View file @
57f3e532
...
...
@@ -287,7 +287,7 @@ private:
/// from NSEC to NSEC3 or vice versa, support incremental signing, or support
/// multiple sets of NSEC3 parameters.
///
/// One
last
type of meta data is the status of the zone in terms of DNSSEC
/// One
other
type of meta data is the status of the zone in terms of DNSSEC
/// signing. This class supports the following concepts:
/// - Whether the zone is signed or not, either with NSEC records or NSEC3
/// records.
...
...
@@ -315,6 +315,15 @@ private:
/// because we won't have to change the application code when we implement
/// the future separation.
///
/// One last type of meta data is the zone's "minimum" TTL. It's expected
/// to be a shortcut copy of the minimum field of the zone's SOA RDATA,
/// and is expected to be used to create an SOA RR for a negative response,
/// whose RR TTL may have to be set to this value according to RFC2308.
/// This class is not aware of such usage, however, and only provides a
/// simple getter and setter method for this value: \c getMinTTLData() and
/// \c setMinTTL(). The user of this class is responsible for setting the
/// value with \c setMinTTL() when it loads or updates the SOA RR.
///
/// The intended usage of these two status concepts is to implement the
/// \c ZoneFinder::Context::isNSECSigned() and
/// \c ZoneFinder::Context::isNSEC3Signed() methods. A possible implementation
...
...
@@ -349,9 +358,7 @@ private:
/// allocator (\c create()), so the constructor is hidden as private.
///
/// It never throws an exception.
ZoneData
(
ZoneTree
*
zone_tree
,
ZoneNode
*
origin_node
)
:
zone_tree_
(
zone_tree
),
origin_node_
(
origin_node
)
{}
ZoneData
(
ZoneTree
*
zone_tree
,
ZoneNode
*
origin_node
);
// Zone node flags.
private:
...
...
@@ -413,7 +420,7 @@ public:
///
/// The class encapsulation ensures that the origin node always exists at
/// the same address, so this method always returns a non-NULL valid
///
valid
pointer.
/// pointer.
///
/// \throw none
const
ZoneNode
*
getOriginNode
()
const
{
...
...
@@ -456,6 +463,26 @@ public:
///
/// \throw none
const
NSEC3Data
*
getNSEC3Data
()
const
{
return
(
nsec3_data_
.
get
());
}
/// \brief Return a pointer to the zone's minimum TTL data.
///
/// The returned pointer points to a memory region that is valid at least
/// for 32 bits, storing the zone's minimum TTL in the network byte
/// order. The corresponding 32-bit value as an integer is initially
/// set to the value of \c dns::RRTTL::MAX_TTL(), and, once
/// \c setMinTTL() is called, set to the value specified at the latest
/// call to \c setMinTTL().
///
/// It returns opaque data to make it clear that unless the wire
/// format data is necessary (e.g., when rendering it in a DNS message),
/// it should be converted to, e.g., an \c RRTTL object explicitly.
///
/// The returned pointer is valid as long as the \c ZoneData is valid,
/// and the corresponding 32-bit data are the same until \c setMinTTL()
/// is called.
///
/// \throw none
const
void
*
getMinTTLData
()
const
{
return
(
&
min_ttl_
);
}
//@}
///
...
...
@@ -552,12 +579,32 @@ public:
nsec3_data_
=
nsec3_data
;
return
(
old
);
}
/// \brief Set the zone's "minimum" TTL.
///
/// This method updates the recorded minimum TTL of the zone data.
/// It's expected to be identical to the value of the Minimum field
/// of the SOA RR at the zone apex, but this method does not check the
/// consistency; it's the caller's responsibility.
///
/// While RFC2181 specifies the max TTL value to be 2^31-1, this method
/// does not check the range; it accepts any unsigned 32-bit integer
/// value. In practice, this shouldn't cause a problem, however, because
/// the only expected usage of this value is to use the minimum of this
/// value and SOA RR's TTL, and the latter is expected to be in the
/// valid range.
///
/// \throw None
/// \param min_ttl_val The minimum TTL value as unsigned 32-bit integer
/// in the host byte order.
void
setMinTTL
(
uint32_t
min_ttl_val
);
//@}
private:
const
boost
::
interprocess
::
offset_ptr
<
ZoneTree
>
zone_tree_
;
const
boost
::
interprocess
::
offset_ptr
<
ZoneNode
>
origin_node_
;
boost
::
interprocess
::
offset_ptr
<
NSEC3Data
>
nsec3_data_
;
uint32_t
min_ttl_
;
};
}
// namespace memory
...
...
src/lib/datasrc/memory/zone_data_updater.cc
View file @
57f3e532
...
...
@@ -336,6 +336,17 @@ ZoneDataUpdater::addRdataSet(const Name& name, const RRType& rrtype,
// "NSEC signed")
zone_data_
.
setSigned
(
true
);
}
// If we are adding a new SOA at the origin, update zone's min TTL.
// Note: if the input is broken and contains multiple SOAs, the load
// or update will be rejected higher level. We just always (though
// this should be only once in normal cases) update the TTL.
if
(
rrset
&&
rrtype
==
RRType
::
SOA
()
&&
is_origin
)
{
// Our own validation ensures the RRset is not empty.
zone_data_
.
setMinTTL
(
dynamic_cast
<
const
generic
::
SOA
&>
(
rrset
->
getRdataIterator
()
->
getCurrent
()).
getMinimum
());
}
}
}
...
...
src/lib/datasrc/memory/zone_finder.cc
View file @
57f3e532
...
...
@@ -23,10 +23,13 @@
#include <dns/name.h>
#include <dns/rrset.h>
#include <dns/rrtype.h>
#include <dns/rrttl.h>
#include <dns/nsec3hash.h>
#include <datasrc/logger.h>
#include <util/buffer.h>
#include <boost/scoped_ptr.hpp>
#include <boost/bind.hpp>
...
...
@@ -104,14 +107,19 @@ createTreeNodeRRset(const ZoneNode* node,
const
RdataSet
*
rdataset
,
const
RRClass
&
rrclass
,
ZoneFinder
::
FindOptions
options
,
const
Name
*
realname
=
NULL
)
const
Name
*
realname
=
NULL
,
const
void
*
ttl_data
=
NULL
)
{
const
bool
dnssec
=
((
options
&
ZoneFinder
::
FIND_DNSSEC
)
!=
0
);
if
(
node
!=
NULL
&&
rdataset
!=
NULL
)
{
if
(
realname
!=
NULL
)
{
if
(
node
&&
rdataset
)
{
if
(
realname
)
{
return
(
TreeNodeRRsetPtr
(
new
TreeNodeRRset
(
*
realname
,
rrclass
,
node
,
rdataset
,
dnssec
)));
}
else
if
(
ttl_data
)
{
assert
(
!
realname
);
// these two cases should be mixed in our use
return
(
TreeNodeRRsetPtr
(
new
TreeNodeRRset
(
rrclass
,
node
,
rdataset
,
dnssec
,
ttl_data
)));
}
else
{
return
(
TreeNodeRRsetPtr
(
new
TreeNodeRRset
(
rrclass
,
node
,
rdataset
,
dnssec
)));
...
...
@@ -229,6 +237,12 @@ createNSEC3RRset(const ZoneNode* node, const RRClass& rrclass) {
ZoneFinder
::
FIND_DNSSEC
));
}
inline
RRTTL
createTTLFromData
(
const
void
*
ttl_data
)
{
util
::
InputBuffer
b
(
ttl_data
,
sizeof
(
uint32_t
));
return
(
RRTTL
(
b
));
}
// convenience function to fill in the final details
//
// Set up ZoneFinderResultContext object as a return value of find(),
...
...
@@ -250,7 +264,8 @@ createFindResult(const RRClass& rrclass,
const
RdataSet
*
rdataset
,
ZoneFinder
::
FindOptions
options
,
bool
wild
=
false
,
const
Name
*
qname
=
NULL
)
const
Name
*
qname
=
NULL
,
bool
use_minttl
=
false
)
{
ZoneFinder
::
FindResultFlags
flags
=
ZoneFinder
::
RESULT_DEFAULT
;
const
Name
*
rename
=
NULL
;
...
...
@@ -268,6 +283,15 @@ createFindResult(const RRClass& rrclass,
}
}
if
(
use_minttl
&&
rdataset
&&
createTTLFromData
(
zone_data
.
getMinTTLData
())
<
createTTLFromData
(
rdataset
->
getTTLData
()))
{
return
(
ZoneFinderResultContext
(
code
,
createTreeNodeRRset
(
node
,
rdataset
,
rrclass
,
options
,
rename
,
zone_data
.
getMinTTLData
()),
flags
,
zone_data
,
node
,
rdataset
));
}
return
(
ZoneFinderResultContext
(
code
,
createTreeNodeRRset
(
node
,
rdataset
,
rrclass
,
options
,
rename
),
...
...
@@ -721,8 +745,8 @@ InMemoryZoneFinder::Context::findAdditional(
boost
::
shared_ptr
<
ZoneFinder
::
Context
>
InMemoryZoneFinder
::
find
(
const
isc
::
dns
::
Name
&
name
,
const
isc
::
dns
::
RRType
&
type
,
const
FindOptions
options
)
const
isc
::
dns
::
RRType
&
type
,
const
FindOptions
options
)
{
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
rrclass_
,
findInternal
(
name
,
type
,
...
...
@@ -731,8 +755,8 @@ InMemoryZoneFinder::find(const isc::dns::Name& name,
boost
::
shared_ptr
<
ZoneFinder
::
Context
>
InMemoryZoneFinder
::
findAll
(
const
isc
::
dns
::
Name
&
name
,
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
target
,
const
FindOptions
options
)
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
target
,
const
FindOptions
options
)
{
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
rrclass_
,
findInternal
(
name
,
...
...
@@ -741,6 +765,44 @@ InMemoryZoneFinder::findAll(const isc::dns::Name& name,
options
))));
}
// The implementation is a special case of the generic findInternal: we know
// the qname should have an "exact match" and its node is accessible via
// getOriginNode(); and, since there should be at least SOA RR at the origin
// the case of CNAME can be eliminated (these should be guaranteed at the load
// or update time, but even if they miss a corner case and allows a CNAME to
// be added at origin, the zone is broken anyway, so we'd just let this
// method return garbage, too). As a result, there can be only too cases
// for the result codes: SUCCESS if the requested type of RR exists; NXRRSET
// otherwise. Due to its simplicity we implement it separately, rather than
// sharing the code with findInternal.
boost
::
shared_ptr
<
ZoneFinder
::
Context
>
InMemoryZoneFinder
::
findAtOrigin
(
const
isc
::
dns
::
RRType
&
type
,
bool
use_minttl
,
const
FindOptions
options
)
{
const
ZoneNode
*
const
node
=
zone_data_
.
getOriginNode
();
const
RdataSet
*
const
found
=
RdataSet
::
find
(
node
->
getData
(),
type
);
if
(
found
!=
NULL
)
{
LOG_DEBUG
(
logger
,
DBG_TRACE_DATA
,
DATASRC_MEM_FIND_TYPE_AT_ORIGIN
).
arg
(
type
).
arg
(
getOrigin
()).
arg
(
rrclass_
);
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
rrclass_
,
createFindResult
(
rrclass_
,
zone_data_
,
SUCCESS
,
node
,
found
,
options
,
false
,
NULL
,
use_minttl
))));
}
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
rrclass_
,
createFindResult
(
rrclass_
,
zone_data_
,
NXRRSET
,
node
,
getNSECForNXRRSET
(
zone_data_
,
options
,
node
),
options
,
false
,
NULL
,
use_minttl
))));
}
ZoneFinderResultContext
InMemoryZoneFinder
::
findInternal
(
const
isc
::
dns
::
Name
&
name
,
const
isc
::
dns
::
RRType
&
type
,
...
...
src/lib/datasrc/memory/zone_finder.h
View file @
57f3e532
...
...
@@ -60,6 +60,16 @@ public:
const
isc
::
dns
::
RRType
&
type
,
const
FindOptions
options
=
FIND_DEFAULT
);
/// \brief Search for an RRset of given RR type at the zone origin
/// specialized for in-memory data source.
///
/// This specialized version exploits internal data structure to find
/// RRsets at the zone origin and (if \c use_minttl is true) extract
/// the SOA Minimum TTL much more efficiently.
virtual
boost
::
shared_ptr
<
Context
>
findAtOrigin
(
const
isc
::
dns
::
RRType
&
type
,
bool
use_minttl
,
FindOptions
options
);
/// \brief Version of find that returns all types at once
///
/// It acts the same as find, just that when the correct node is found,
...
...
@@ -108,3 +118,7 @@ private:
}
// namespace isc
#endif // DATASRC_MEMORY_ZONE_FINDER_H
// Local Variables:
// mode: c++
// End:
src/lib/datasrc/tests/memory/treenode_rrset_unittest.cc
View file @
57f3e532
...
...
@@ -194,8 +194,14 @@ checkBasicFields(const AbstractRRset& actual_rrset, const RdataSet* rdataset,
// a temporary non-copyable object.
boost
::
shared_ptr
<
TreeNodeRRset
>
createRRset
(
const
RRClass
&
rrclass
,
const
ZoneNode
*
node
,
const
RdataSet
*
rdataset
,
bool
dnssec_ok
)
const
RdataSet
*
rdataset
,
bool
dnssec_ok
,
const
void
*
ttl_data
=
NULL
)
{
if
(
ttl_data
)
{
return
(
boost
::
shared_ptr
<
TreeNodeRRset
>
(
new
TreeNodeRRset
(
rrclass
,
node
,
rdataset
,
dnssec_ok
,
ttl_data
)));
}
return
(
boost
::
shared_ptr
<
TreeNodeRRset
>
(
new
TreeNodeRRset
(
rrclass
,
node
,
rdataset
,
dnssec_ok
)));
}
...
...
@@ -243,6 +249,13 @@ TEST_F(TreeNodeRRsetTest, create) {
true
),
wildcard_rdataset_
,
match_name_
,
rrclass_
,
RRType
::
A
(),
3600
,
2
,
1
);
// Constructed with explicit TTL
const
uint32_t
ttl
=
0
;
// use 0 to avoid byte-order conversion
checkBasicFields
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
,
&
ttl
),
a_rdataset_
,
www_name_
,
rrclass_
,
RRType
::
A
(),
0
,
2
,
1
);
}
// The following two templated functions are helper to encapsulate the
...
...
@@ -336,6 +349,21 @@ TEST_F(TreeNodeRRsetTest, toWire) {
isc
::
Unexpected
);
}
{
SCOPED_TRACE
(
"with RRSIG, DNSSEC OK, explicit TTL"
);
const
uint32_t
ttl
=
0
;
const
TreeNodeRRset
rrset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
,
&
ttl
);
checkToWireResult
(
expected_renderer
,
actual_renderer
,
rrset
,
www_name_
,
textToRRset
(
"www.example.com. 0 IN A 192.0.2.1
\n
"
"www.example.com. 0 IN A 192.0.2.2"
),
textToRRset
(
"www.example.com. 0 IN RRSIG "
"A 5 2 3600 20120814220826 "
"20120715220826 1234 example.com. FAKE"
),
true
);
}
{
SCOPED_TRACE
(
"with RRSIG, DNSSEC not OK"
);
const
TreeNodeRRset
rrset
(
rrclass_
,
www_node_
,
a_rdataset_
,
false
);
...
...
@@ -396,7 +424,7 @@ TEST_F(TreeNodeRRsetTest, toWire) {
const
TreeNodeRRset
rrset
(
rrclass_
,
www_node_
,
rrsig_only_rdataset_
,
true
);
checkToWireResult
(
expected_renderer
,
actual_renderer
,
rrset
,
www_name_
,
ConstRRsetPtr
(),
txt_rrsig_rrset_
,
true
);
www_name_
,
ConstRRsetPtr
(),
txt_rrsig_rrset_
,
true
);
}
{
...
...
@@ -407,7 +435,7 @@ TEST_F(TreeNodeRRsetTest, toWire) {
const
TreeNodeRRset
rrset
(
rrclass_
,
www_node_
,
rrsig_only_rdataset_
,
false
);
checkToWireResult
(
expected_renderer
,
actual_renderer
,
rrset
,
www_name_
,
ConstRRsetPtr
(),
txt_rrsig_rrset_
,
false
);
www_name_
,
ConstRRsetPtr
(),
txt_rrsig_rrset_
,
false
);
}
}
...
...
@@ -522,6 +550,14 @@ TEST_F(TreeNodeRRsetTest, toText) {
// Constructed with RRSIG, and it should be visible.
checkToText
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
),
a_rrset_
,
a_rrsig_rrset_
);
// Same as the previous, but with explicit TTL.
const
uint32_t
ttl
=
0
;
checkToText
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
,
&
ttl
),
textToRRset
(
"www.example.com. 0 IN A 192.0.2.1
\n
"
"www.example.com. 0 IN A 192.0.2.2"
),
textToRRset
(
"www.example.com. 0 IN RRSIG A 5 2 3600 "
"20120814220826 20120715220826 1234 example.com. "
"FAKE"
));
// Constructed with RRSIG, and it should be invisible.
checkToText
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
false
),
a_rrset_
,
ConstRRsetPtr
());
...
...
@@ -556,6 +592,11 @@ TEST_F(TreeNodeRRsetTest, isSameKind) {
EXPECT_TRUE
(
rrset
.
isSameKind
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
)));
// Similar to the previous, but with explicit (different TTL) => still same
const
uint32_t
ttl
=
0
;
EXPECT_TRUE
(
rrset
.
isSameKind
(
*
createRRset
(
rrclass_
,
www_node_
,
a_rdataset_
,
true
,
&
ttl
)));
// Same name (node), different type (rdataset) => not same kind
EXPECT_FALSE
(
rrset
.
isSameKind
(
*
createRRset
(
rrclass_
,
www_node_
,
aaaa_rdataset_
,
true
)));
...
...
src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc
View file @
57f3e532
...
...
@@ -12,13 +12,15 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <dns/name.h>
#include <dns/rrclass.h>
#include <datasrc/memory/zone_data_loader.h>
#include <datasrc/memory/rdataset.h>
#include <datasrc/memory/zone_data.h>
#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/memory/zone_data_loader.h>
#include <util/buffer.h>
#include <dns/name.h>
#include <dns/rrclass.h>
#include "memory_segment_test.h"
...
...
@@ -62,4 +64,13 @@ TEST_F(ZoneDataLoaderTest, loadRRSIGFollowsNothing) {
// Teardown checks for memory segment leaks
}
TEST_F
(
ZoneDataLoaderTest
,
zoneMinTTL
)
{
// This should hold outside of the loader class, but we do double check.
zone_data_
=
loadZoneData
(
mem_sgmt_
,
zclass_
,
Name
(
"example.org"
),
TEST_DATA_DIR
"/example.org-nsec3-signed.zone"
);
isc
::
util
::
InputBuffer
b
(
zone_data_
->
getMinTTLData
(),
sizeof
(
uint32_t
));
EXPECT_EQ
(
RRTTL
(
1200
),
RRTTL
(
b
));
}
}
src/lib/datasrc/tests/memory/zone_data_unittest.cc
View file @
57f3e532
...
...
@@ -12,19 +12,22 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <datasrc/memory/zone_data.h>
#include <datasrc/memory/rdata_serialization.h>
#include <datasrc/memory/rdataset.h>
#include "memory_segment_test.h"
#include <dns/rdataclass.h>
#include <exceptions/exceptions.h>
#include <util/buffer.h>
#include <dns/name.h>
#include <dns/labelsequence.h>
#include <dns/rrclass.h>
#include <datasrc/memory/rdata_serialization.h>
#include <datasrc/memory/rdataset.h>
#include <datasrc/memory/zone_data.h>
#include <dns/rrttl.h>