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
Adam Osuchowski
Kea
Commits
307a588d
Commit
307a588d
authored
Aug 29, 2012
by
Naoki Kambe
Browse files
[master] Merge branch 'master' of
ssh://git.bind10.isc.org/var/bind10/git/bind10
parents
9a7b74db
5d1e1994
Changes
30
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/query.cc
View file @
307a588d
...
...
@@ -57,7 +57,7 @@ namespace auth {
void
Query
::
ResponseCreator
::
addRRset
(
isc
::
dns
::
Message
&
message
,
const
isc
::
dns
::
Message
::
Section
section
,
const
ConstRRsetPtr
&
rrset
,
const
bool
dnssec
)
const
ConstRRsetPtr
&
rrset
)
{
/// Is this RRset already in the list of RRsets added to the message?
const
std
::
vector
<
const
AbstractRRset
*>::
const_iterator
i
=
...
...
@@ -68,8 +68,7 @@ Query::ResponseCreator::addRRset(isc::dns::Message& message,
// No - add it to both the message and the list of RRsets processed.
// The const-cast is wrong, but the message interface seems to insist.
message
.
addRRset
(
section
,
boost
::
const_pointer_cast
<
AbstractRRset
>
(
rrset
),
dnssec
);
boost
::
const_pointer_cast
<
AbstractRRset
>
(
rrset
));
added_
.
push_back
(
rrset
.
get
());
}
}
...
...
@@ -78,8 +77,7 @@ void
Query
::
ResponseCreator
::
create
(
Message
&
response
,
const
vector
<
ConstRRsetPtr
>&
answers
,
const
vector
<
ConstRRsetPtr
>&
authorities
,
const
vector
<
ConstRRsetPtr
>&
additionals
,
const
bool
dnssec
)
const
vector
<
ConstRRsetPtr
>&
additionals
)
{
// Inserter should be reset each time the query is reset, so should be
// empty at this point.
...
...
@@ -91,13 +89,13 @@ Query::ResponseCreator::create(Message& response,
// guarantee that if there are duplicates, the single RRset added will
// appear in the most important section.
BOOST_FOREACH
(
const
ConstRRsetPtr
&
rrset
,
answers
)
{
addRRset
(
response
,
Message
::
SECTION_ANSWER
,
rrset
,
dnssec
);
addRRset
(
response
,
Message
::
SECTION_ANSWER
,
rrset
);
}
BOOST_FOREACH
(
const
ConstRRsetPtr
&
rrset
,
authorities
)
{
addRRset
(
response
,
Message
::
SECTION_AUTHORITY
,
rrset
,
dnssec
);
addRRset
(
response
,
Message
::
SECTION_AUTHORITY
,
rrset
);
}
BOOST_FOREACH
(
const
ConstRRsetPtr
&
rrset
,
additionals
)
{
addRRset
(
response
,
Message
::
SECTION_ADDITIONAL
,
rrset
,
dnssec
);
addRRset
(
response
,
Message
::
SECTION_ADDITIONAL
,
rrset
);
}
}
...
...
@@ -533,8 +531,7 @@ Query::process(datasrc::ClientList& client_list,
break
;
}
response_creator_
.
create
(
*
response_
,
answers_
,
authorities_
,
additionals_
,
dnssec_
);
response_creator_
.
create
(
*
response_
,
answers_
,
authorities_
,
additionals_
);
}
void
...
...
@@ -592,8 +589,7 @@ Query::processDSAtChild() {
}
}
response_creator_
.
create
(
*
response_
,
answers_
,
authorities_
,
additionals_
,
dnssec_
);
response_creator_
.
create
(
*
response_
,
answers_
,
authorities_
,
additionals_
);
return
(
true
);
}
...
...
src/bin/auth/query.h
View file @
307a588d
...
...
@@ -441,16 +441,13 @@ public:
/// authority, and additional sections, and add them to their
/// corresponding sections in the given message. The RRsets are
/// filtered such that a particular RRset appears only once in the
/// message.
///
/// If \c dnssec is true, it tells the message to include any RRSIGs
/// attached to the RRsets.
/// message. Any RRSIGs attached to the RRsets will be included
/// when they are rendered.
void
create
(
isc
::
dns
::
Message
&
message
,
const
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
answers_
,
const
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
authorities_
,
const
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
additionals_
,
const
bool
dnssec
);
const
std
::
vector
<
isc
::
dns
::
ConstRRsetPtr
>&
additionals_
);
private:
// \brief RRset comparison functor.
...
...
@@ -469,10 +466,9 @@ public:
/// \param message Message to which the RRset is to be added
/// \param section Section of the message in which the RRset is put
/// \param rrset Pointer to RRset to be added to the message
/// \param dnssec Whether RRSIG records should be added as well
void
addRRset
(
isc
::
dns
::
Message
&
message
,
const
isc
::
dns
::
Message
::
Section
section
,
const
isc
::
dns
::
ConstRRsetPtr
&
rrset
,
const
bool
dnssec
);
const
isc
::
dns
::
ConstRRsetPtr
&
rrset
);
private:
...
...
src/bin/auth/tests/query_unittest.cc
View file @
307a588d
...
...
@@ -211,12 +211,18 @@ const char* const nonsec_a_txt =
"nonsec.example.com. 3600 IN A 192.0.2.0
\n
"
;
// NSEC3 RRs. You may also need to add mapping to MockZoneFinder::hash_map_.
const
char
*
const
nsec3_apex_txt
=
const
string
nsec3_apex_txt
=
"0p9mhaveqvm6t7vbl5lop2u3t2rp3tom.example.com. 3600 IN NSEC3 1 1 12 "
"aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA NSEC3PARAM RRSIG
\n
"
;
const
char
*
const
nsec3_www_txt
=
const
string
nsec3_apex_rrsig_txt
=
"0p9mhaveqvm6t7vbl5lop2u3t2rp3tom.example.com. 3600 IN RRSIG NSEC3 5 3 "
"3600 20000101000000 20000201000000 12345 example.com. FAKEFAKEFAKE"
;
const
string
nsec3_www_txt
=
"q04jkcevqvmu85r014c7dkba38o0ji5r.example.com. 3600 IN NSEC3 1 1 12 "
"aabbccdd r53bq7cc2uvmubfu5ocmm6pers9tk9en A RRSIG
\n
"
;
const
string
nsec3_www_rrsig_txt
=
"q04jkcevqvmu85r014c7dkba38o0ji5r.example.com. 3600 IN RRSIG NSEC3 5 3 "
"3600 20000101000000 20000201000000 12345 example.com. FAKEFAKEFAKE"
;
// NSEC3 for wild.example.com (used in wildcard tests, will be added on
// demand not to confuse other tests)
...
...
@@ -479,9 +485,10 @@ protected:
isc
::
dns
::
ConstRRsetPtr
rrset
,
FindResultFlags
flags
=
RESULT_DEFAULT
)
{
ConstRRsetPtr
rp
=
stripRRsigs
(
rrset
,
options
);
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
ResultContext
(
code
,
r
rset
,
flags
))));
ResultContext
(
code
,
r
p
,
flags
))));
}
private:
...
...
@@ -594,7 +601,7 @@ MockZoneFinder::findAll(const Name& name, std::vector<ConstRRsetPtr>& target,
found_domain
->
second
.
begin
();
found_rrset
!=
found_domain
->
second
.
end
();
++
found_rrset
)
{
// Insert RRs under the domain name into target
target
.
push_back
(
found_rrset
->
second
);
target
.
push_back
(
stripRRsigs
(
found_rrset
->
second
,
options
)
);
}
return
(
ZoneFinderContextPtr
(
new
Context
(
*
this
,
options
,
...
...
@@ -701,25 +708,8 @@ MockZoneFinder::find(const Name& name, const RRType& type,
RRsetStore
::
const_iterator
found_rrset
=
found_domain
->
second
.
find
(
type
);
if
(
found_rrset
!=
found_domain
->
second
.
end
())
{
ConstRRsetPtr
rrset
;
// Strip whatever signature there is in case DNSSEC is not required
// Just to make sure the Query asks for it when it is needed
if
((
options
&
ZoneFinder
::
FIND_DNSSEC
)
!=
0
||
include_rrsig_anyway_
||
!
found_rrset
->
second
->
getRRsig
())
{
rrset
=
found_rrset
->
second
;
}
else
{
RRsetPtr
noconst
(
new
RRset
(
found_rrset
->
second
->
getName
(),
found_rrset
->
second
->
getClass
(),
found_rrset
->
second
->
getType
(),
found_rrset
->
second
->
getTTL
()));
for
(
RdataIteratorPtr
i
(
found_rrset
->
second
->
getRdataIterator
());
!
i
->
isLast
();
i
->
next
())
{
noconst
->
addRdata
(
i
->
getCurrent
());
}
rrset
=
noconst
;
}
ConstRRsetPtr
rrset
=
ZoneFinder
::
stripRRsigs
(
found_rrset
->
second
,
options
);
return
(
createContext
(
options
,
SUCCESS
,
rrset
));
}
...
...
@@ -1985,14 +1975,16 @@ TEST_F(QueryTest, findNSEC3) {
// Apex name. It should have a matching NSEC3
{
SCOPED_TRACE
(
"apex, non recursive"
);
nsec3Check
(
true
,
expected_closest_labels
,
nsec3_apex_txt
,
nsec3Check
(
true
,
expected_closest_labels
,
nsec3_apex_txt
+
"
\n
"
+
nsec3_apex_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"example.com"
),
false
));
}
// Recursive mode doesn't change the result in this case.
{
SCOPED_TRACE
(
"apex, recursive"
);
nsec3Check
(
true
,
expected_closest_labels
,
nsec3_apex_txt
,
nsec3Check
(
true
,
expected_closest_labels
,
nsec3_apex_txt
+
"
\n
"
+
nsec3_apex_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"example.com"
),
true
));
}
...
...
@@ -2000,7 +1992,8 @@ TEST_F(QueryTest, findNSEC3) {
// returned.
{
SCOPED_TRACE
(
"nxdomain, non recursive"
);
nsec3Check
(
false
,
4
,
nsec3_www_txt
,
nsec3Check
(
false
,
4
,
nsec3_www_txt
+
"
\n
"
+
nsec3_www_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"nxdomain.example.com"
),
false
));
}
...
...
@@ -2010,7 +2003,8 @@ TEST_F(QueryTest, findNSEC3) {
{
SCOPED_TRACE
(
"nxdomain, recursive"
);
nsec3Check
(
true
,
expected_closest_labels
,
string
(
nsec3_apex_txt
)
+
string
(
nsec3_www_txt
),
nsec3_apex_txt
+
"
\n
"
+
nsec3_apex_rrsig_txt
+
"
\n
"
+
nsec3_www_txt
+
"
\n
"
+
nsec3_www_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"nxdomain.example.com"
),
true
));
}
...
...
@@ -2019,7 +2013,8 @@ TEST_F(QueryTest, findNSEC3) {
{
SCOPED_TRACE
(
"nxdomain, next closer != qname"
);
nsec3Check
(
true
,
expected_closest_labels
,
string
(
nsec3_apex_txt
)
+
string
(
nsec3_www_txt
),
nsec3_apex_txt
+
"
\n
"
+
nsec3_apex_rrsig_txt
+
"
\n
"
+
nsec3_www_txt
+
"
\n
"
+
nsec3_www_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"nx.domain.example.com"
),
true
));
}
...
...
@@ -2027,13 +2022,15 @@ TEST_F(QueryTest, findNSEC3) {
// In the rest of test we check hash comparison for wrap around cases.
{
SCOPED_TRACE
(
"largest"
);
nsec3Check
(
false
,
4
,
nsec3_apex_txt
,
nsec3Check
(
false
,
4
,
nsec3_apex_txt
+
"
\n
"
+
nsec3_apex_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"nxdomain2.example.com"
),
false
));
}
{
SCOPED_TRACE
(
"smallest"
);
nsec3Check
(
false
,
4
,
nsec3_www_txt
,
nsec3Check
(
false
,
4
,
nsec3_www_txt
+
"
\n
"
+
nsec3_www_rrsig_txt
,
mock_finder
->
findNSEC3
(
Name
(
"nxdomain3.example.com"
),
false
));
}
...
...
@@ -2516,8 +2513,7 @@ TEST_F(QueryTest, DuplicateNameRemoval) {
EXPECT_EQ
(
0
,
message
.
getRRCount
(
Message
::
SECTION_ADDITIONAL
));
// ... and fill it.
Query
::
ResponseCreator
().
create
(
message
,
answer
,
authority
,
additional
,
false
);
Query
::
ResponseCreator
().
create
(
message
,
answer
,
authority
,
additional
);
// Check counts in each section. Note that these are RR counts,
// not RRset counts.
...
...
src/lib/cache/message_entry.cc
View file @
307a588d
...
...
@@ -110,8 +110,7 @@ MessageEntry::getRRsetEntries(vector<RRsetEntryPtr>& rrset_entry_vec,
void
MessageEntry
::
addRRset
(
isc
::
dns
::
Message
&
message
,
const
vector
<
RRsetEntryPtr
>&
rrset_entry_vec
,
const
isc
::
dns
::
Message
::
Section
&
section
,
bool
dnssec_need
)
const
isc
::
dns
::
Message
::
Section
&
section
)
{
uint16_t
start_index
=
0
;
uint16_t
end_index
=
answer_count_
;
...
...
@@ -126,8 +125,7 @@ MessageEntry::addRRset(isc::dns::Message& message,
}
for
(
uint16_t
index
=
start_index
;
index
<
end_index
;
++
index
)
{
message
.
addRRset
(
section
,
rrset_entry_vec
[
index
]
->
getRRset
(),
dnssec_need
);
message
.
addRRset
(
section
,
rrset_entry_vec
[
index
]
->
getRRset
());
}
}
...
...
@@ -156,10 +154,9 @@ MessageEntry::genMessage(const time_t& time_now,
msg
.
setHeaderFlag
(
Message
::
HEADERFLAG_AA
,
false
);
msg
.
setHeaderFlag
(
Message
::
HEADERFLAG_TC
,
headerflag_tc_
);
bool
dnssec_need
=
msg
.
getEDNS
().
get
();
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_ANSWER
,
dnssec_need
);
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_AUTHORITY
,
dnssec_need
);
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_ADDITIONAL
,
dnssec_need
);
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_ANSWER
);
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_AUTHORITY
);
addRRset
(
msg
,
rrset_entry_vec
,
Message
::
SECTION_ADDITIONAL
);
return
(
true
);
}
...
...
src/lib/cache/message_entry.h
View file @
307a588d
...
...
@@ -154,11 +154,9 @@ protected:
/// \param rrset_entry_vec vector for rrset entries in
/// different sections.
/// \param section The section to add to
/// \param dnssec_need need dnssec records or not.
void
addRRset
(
isc
::
dns
::
Message
&
message
,
const
std
::
vector
<
RRsetEntryPtr
>&
rrset_entry_vec
,
const
isc
::
dns
::
Message
::
Section
&
section
,
bool
dnssec_need
);
const
isc
::
dns
::
Message
::
Section
&
section
);
/// \brief Get the all the rrset entries for the message entry.
///
...
...
src/lib/datasrc/Makefile.am
View file @
307a588d
...
...
@@ -29,7 +29,7 @@ libb10_datasrc_la_SOURCES += cache.h cache.cc
libb10_datasrc_la_SOURCES
+=
rbnode_rrset.h
libb10_datasrc_la_SOURCES
+=
rbtree.h
libb10_datasrc_la_SOURCES
+=
zonetable.h zonetable.cc
libb10_datasrc_la_SOURCES
+=
zone.h zone_finder_context.cc
libb10_datasrc_la_SOURCES
+=
zone.h
zone_finder.cc
zone_finder_context.cc
libb10_datasrc_la_SOURCES
+=
result.h
libb10_datasrc_la_SOURCES
+=
logger.h logger.cc
libb10_datasrc_la_SOURCES
+=
client.h iterator.h
...
...
src/lib/datasrc/data_source.cc
View file @
307a588d
...
...
@@ -564,12 +564,12 @@ addToMessage(Query& q, const Message::Section sect, RRsetPtr rrset,
if
(
rrset
->
getType
()
==
RRType
::
RRSIG
()
||
!
m
.
hasRRset
(
sect
,
rrset
->
getName
(),
rrset
->
getClass
(),
rrset
->
getType
()))
{
m
.
addRRset
(
sect
,
rrset
,
false
);
m
.
addRRset
(
sect
,
rrset
);
}
}
else
{
if
(
!
m
.
hasRRset
(
sect
,
rrset
->
getName
(),
rrset
->
getClass
(),
rrset
->
getType
()))
{
m
.
addRRset
(
sect
,
rrset
,
q
.
wantDnssec
()
);
m
.
addRRset
(
sect
,
rrset
);
}
}
}
...
...
src/lib/datasrc/database.cc
View file @
307a588d
...
...
@@ -157,7 +157,7 @@ public:
const
isc
::
dns
::
RRType
&
type_covered
=
static_cast
<
isc
::
dns
::
rdata
::
generic
::
RRSIG
*>
(
sig_rdata
.
get
())
->
typeCovered
();
sigs
[
type_covered
].
push_back
(
sig_rdata
);
sigs
_
[
type_covered
].
push_back
(
sig_rdata
);
}
// If the store contains signatures for the type of the given
...
...
@@ -165,21 +165,26 @@ public:
void
appendSignatures
(
isc
::
dns
::
RRsetPtr
&
rrset
)
const
{
std
::
map
<
isc
::
dns
::
RRType
,
std
::
vector
<
isc
::
dns
::
rdata
::
RdataPtr
>
>::
const_iterator
found
=
sigs
.
find
(
rrset
->
getType
());
if
(
found
!=
sigs
.
end
())
{
found
=
sigs
_
.
find
(
rrset
->
getType
());
if
(
found
!=
sigs
_
.
end
())
{
BOOST_FOREACH
(
isc
::
dns
::
rdata
::
RdataPtr
sig
,
found
->
second
)
{
rrset
->
addRRsig
(
sig
);
}
}
}
bool
empty
()
const
{
return
(
sigs_
.
empty
());
}
private:
std
::
map
<
isc
::
dns
::
RRType
,
std
::
vector
<
isc
::
dns
::
rdata
::
RdataPtr
>
>
sigs
;
std
::
map
<
isc
::
dns
::
RRType
,
std
::
vector
<
isc
::
dns
::
rdata
::
RdataPtr
>
>
sigs
_
;
};
}
DatabaseClient
::
Finder
::
FoundRRsets
DatabaseClient
::
Finder
::
getRRsets
(
const
string
&
name
,
const
WantedTypes
&
types
,
bool
sigs
,
const
string
*
construct_name
,
bool
any
,
DatabaseAccessor
::
IteratorContextPtr
context
)
{
...
...
@@ -213,7 +218,7 @@ DatabaseClient::Finder::getRRsets(const string& name, const WantedTypes& types,
try
{
const
RRType
cur_type
(
columns
[
DatabaseAccessor
::
TYPE_COLUMN
]);
if
(
cur_type
==
RRType
::
RRSIG
())
{
if
(
sigs
&&
(
cur_type
==
RRType
::
RRSIG
())
)
{
// If we get signatures before we get the actual data, we
// can't know which ones to keep and which to drop...
// So we keep a separate store of any signature that may be
...
...
@@ -228,7 +233,7 @@ DatabaseClient::Finder::getRRsets(const string& name, const WantedTypes& types,
if
(
types
.
find
(
cur_type
)
!=
types
.
end
()
||
any
)
{
// This type is requested, so put it into result
const
RRTTL
cur_ttl
(
columns
[
DatabaseAccessor
::
TTL_COLUMN
]);
// Th
s
sigtype column was an optimization for finding the
// Th
e
sigtype column was an optimization for finding the
// relevant RRSIG RRs for a lookup. Currently this column is
// not used in this revised datasource implementation. We
// should either start using it again, or remove it from use
...
...
@@ -276,10 +281,12 @@ DatabaseClient::Finder::getRRsets(const string& name, const WantedTypes& types,
isc_throw
(
DataSourceError
,
"CNAME shares domain "
<<
name
<<
" with something else"
);
}
// Add signatures to all found RRsets
for
(
std
::
map
<
RRType
,
RRsetPtr
>::
iterator
i
(
result
.
begin
());
i
!=
result
.
end
();
++
i
)
{
sig_store
.
appendSignatures
(
i
->
second
);
if
(
!
sig_store
.
empty
())
{
// Add signatures to all found RRsets
for
(
std
::
map
<
RRType
,
RRsetPtr
>::
iterator
i
(
result
.
begin
());
i
!=
result
.
end
();
++
i
)
{
sig_store
.
appendSignatures
(
i
->
second
);
}
}
if
(
records_found
&&
any
)
{
result
[
RRType
::
ANY
()]
=
RRsetPtr
();
...
...
@@ -448,7 +455,9 @@ DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
// Look if there's NS or DNAME at this point of the tree, but ignore
// the NS RRs at the apex of the zone.
const
FoundRRsets
found
=
getRRsets
(
superdomain
.
toText
(),
DELEGATION_TYPES
());
DELEGATION_TYPES
(),
((
options
&
FIND_DNSSEC
)
==
FIND_DNSSEC
));
if
(
found
.
first
)
{
// This node contains either NS or DNAME RRs so it does exist.
const
FoundIterator
nsi
(
found
.
second
.
find
(
RRType
::
NS
()));
...
...
@@ -581,6 +590,8 @@ DatabaseClient::Finder::findWildcardMatch(
// RFC 4592 section 4.4).
// Search for a match. The types are the same as with original query.
const
FoundRRsets
found
=
getRRsets
(
wildcard
,
final_types
,
((
options
&
FIND_DNSSEC
)
==
FIND_DNSSEC
),
&
construct_name
,
type
==
RRType
::
ANY
());
if
(
found
.
first
)
{
...
...
@@ -685,7 +696,7 @@ DatabaseClient::Finder::FindDNSSECContext::probe() {
// such cases).
const
string
origin
=
finder_
.
getOrigin
().
toText
();
const
FoundRRsets
nsec3_found
=
finder_
.
getRRsets
(
origin
,
NSEC3PARAM_TYPES
());
finder_
.
getRRsets
(
origin
,
NSEC3PARAM_TYPES
()
,
true
);
const
FoundIterator
nfi
=
nsec3_found
.
second
.
find
(
RRType
::
NSEC3PARAM
());
is_nsec3_
=
(
nfi
!=
nsec3_found
.
second
.
end
());
...
...
@@ -696,7 +707,7 @@ DatabaseClient::Finder::FindDNSSECContext::probe() {
// described in Section 10.4 of RFC 5155.
if
(
!
is_nsec3_
)
{
const
FoundRRsets
nsec_found
=
finder_
.
getRRsets
(
origin
,
NSEC_TYPES
());
finder_
.
getRRsets
(
origin
,
NSEC_TYPES
()
,
true
);
const
FoundIterator
nfi
=
nsec_found
.
second
.
find
(
RRType
::
NSEC
());
is_nsec_
=
(
nfi
!=
nsec_found
.
second
.
end
());
...
...
@@ -749,7 +760,7 @@ DatabaseClient::Finder::FindDNSSECContext::getDNSSECRRset(const Name &name,
const
Name
&
nsec_name
=
covering
?
finder_
.
findPreviousName
(
name
)
:
name
;
const
FoundRRsets
found
=
finder_
.
getRRsets
(
nsec_name
.
toText
(),
NSEC_TYPES
());
NSEC_TYPES
()
,
true
);
const
FoundIterator
nci
=
found
.
second
.
find
(
RRType
::
NSEC
());
if
(
nci
!=
found
.
second
.
end
())
{
return
(
nci
->
second
);
...
...
@@ -976,6 +987,8 @@ DatabaseClient::Finder::findInternal(const Name& name, const RRType& type,
WantedTypes
final_types
(
FINAL_TYPES
());
final_types
.
insert
(
type
);
const
FoundRRsets
found
=
getRRsets
(
name
.
toText
(),
final_types
,
((
options
&
FIND_DNSSEC
)
==
FIND_DNSSEC
),
NULL
,
type
==
RRType
::
ANY
());
FindDNSSECContext
dnssec_ctx
(
*
this
,
options
);
if
(
found
.
first
)
{
...
...
@@ -1009,7 +1022,8 @@ DatabaseClient::Finder::findNSEC3(const Name& name, bool recursive) {
// Now, we need to get the NSEC3 params from the apex and create the hash
// creator for it.
const
FoundRRsets
nsec3param
(
getRRsets
(
getOrigin
().
toText
(),
NSEC3PARAM_TYPES
()));
NSEC3PARAM_TYPES
(),
true
));
const
FoundIterator
param
(
nsec3param
.
second
.
find
(
RRType
::
NSEC3PARAM
()));
if
(
!
nsec3param
.
first
||
param
==
nsec3param
.
second
.
end
())
{
// No NSEC3 params? :-(
...
...
@@ -1049,6 +1063,7 @@ DatabaseClient::Finder::findNSEC3(const Name& name, bool recursive) {
}
const
FoundRRsets
nsec3
(
getRRsets
(
hash
+
"."
+
otext
,
NSEC3_TYPES
(),
true
,
NULL
,
false
,
context
));
if
(
nsec3
.
first
)
{
...
...
@@ -1074,7 +1089,8 @@ DatabaseClient::Finder::findNSEC3(const Name& name, bool recursive) {
arg
(
labels
).
arg
(
prevHash
);
context
=
accessor_
->
getNSEC3Records
(
prevHash
,
zone_id_
);
const
FoundRRsets
prev_nsec3
(
getRRsets
(
prevHash
+
"."
+
otext
,
NSEC3_TYPES
(),
NULL
,
false
,
NSEC3_TYPES
(),
true
,
NULL
,
false
,
context
));
if
(
!
prev_nsec3
.
first
)
{
...
...
src/lib/datasrc/database.h
View file @
307a588d
...
...
@@ -963,6 +963,8 @@ public:
///
/// \param name Which domain name should be scanned.
/// \param types List of types the caller is interested in.
/// \param sigs Return RRSIGs if true is passed. Otherwise, no
/// associated RRSIGs are set on the returned RRsets.
/// \param construct_name If this is NULL, the resulting RRsets have
/// their name set to name. If it is not NULL, it overrides the
/// name and uses this one (this can be used for wildcard
...
...
@@ -984,6 +986,7 @@ public:
/// database or the database contains bad data.
FoundRRsets
getRRsets
(
const
std
::
string
&
name
,
const
WantedTypes
&
types
,
bool
sigs
,
const
std
::
string
*
construct_name
=
NULL
,
bool
any
=
false
,
DatabaseAccessor
::
IteratorContextPtr
srcContext
=
...
...
src/lib/datasrc/memory_datasrc.cc
View file @
307a588d
...
...
@@ -738,7 +738,24 @@ prepareRRset(const Name& name, const ConstRBNodeRRsetPtr& rrset, bool rename,
rrset
->
copyAdditionalNodes
(
*
result
);
return
(
result
);
}
else
{
return
(
rrset
);
ConstRRsetPtr
sig_rrset
=
rrset
->
getRRsig
();
if
(
sig_rrset
&&
((
options
&
ZoneFinder
::
FIND_DNSSEC
)
==
0
))
{
RRsetPtr
result_base
(
new
RRset
(
name
,
rrset
->
getClass
(),
rrset
->
getType
(),
rrset
->
getTTL
()));
for
(
RdataIteratorPtr
i
(
rrset
->
getRdataIterator
());
!
i
->
isLast
();
i
->
next
())
{
result_base
->
addRdata
(
i
->
getCurrent
());
}
RBNodeRRsetPtr
result
(
new
RBNodeRRset
(
result_base
));
rrset
->
copyAdditionalNodes
(
*
result
);
return
(
result
);
}
else
{
return
(
rrset
);
}
}
}
...
...
@@ -795,10 +812,10 @@ protected:
}
BOOST_FOREACH
(
const
DomainPair
&
dom_it
,
*
found_node_
->
getData
())
{
getAdditionalForRRset
(
*
dom_it
.
second
,
requested_types
,
result
);
result
,
options_
);
}
}
else
{
getAdditionalForRRset
(
*
rrset_
,
requested_types
,
result
);
getAdditionalForRRset
(
*
rrset_
,
requested_types
,
result
,
options_
);
}
}
...
...
@@ -809,7 +826,8 @@ private:
// type for each node.
static
void
getAdditionalForRRset
(
const
RBNodeRRset
&
rrset
,
const
vector
<
RRType
>&
requested_types
,
vector
<
ConstRRsetPtr
>&
result
)
vector
<
ConstRRsetPtr
>&
result
,
ZoneFinder
::
FindOptions
options
)
{
const
vector
<
AdditionalNodeInfo
>*
additionals_
=
rrset
.
getAdditionalNodes
();
...
...
@@ -836,11 +854,13 @@ private:
// in case the caller has the same RRset but as a result
// of normal find() and needs to know they are of the same
// kind; otherwise we simply use the stored RBNodeRRset.
ConstRRsetPtr
rp
;
if
(
wild_expanded
)
{
r
esult
.
push_back
(
found
->
second
->
getUnderlyingRRset
()
)
;
r
p
=
found
->
second
->
getUnderlyingRRset
();
}
else
{
r
esult
.
push_back
(
found
->
second
)
;
r
p
=
found
->
second
;
}
result
.
push_back
(
ZoneFinder
::
stripRRsigs
(
rp
,
options
));
}
}
}
...
...
src/lib/datasrc/tests/Makefile.am
View file @
307a588d
...
...
@@ -46,17 +46,21 @@ common_ldadd += $(GTEST_LDADD) $(SQLITE_LIBS)
# The general tests
run_unittests_SOURCES
=
$(common_sources)
run_unittests_SOURCES
+=
datasrc_unittest.cc
run_unittests_SOURCES
+=
static_unittest.cc
run_unittests_SOURCES
+=
query_unittest.cc
run_unittests_SOURCES
+=
cache_unittest.cc
# Commented out by ticket #2165. If you re-enable these, please modify
# EXTRA_DIST at the bottom of this file.
#run_unittests_SOURCES += datasrc_unittest.cc
#run_unittests_SOURCES += static_unittest.cc
#run_unittests_SOURCES += query_unittest.cc
#run_unittests_SOURCES += cache_unittest.cc
#run_unittests_SOURCES += sqlite3_unittest.cc
#run_unittests_SOURCES += test_datasrc.h test_datasrc.cc
run_unittests_SOURCES
+=
test_client.h test_client.cc
run_unittests_SOURCES
+=
test_datasrc.h test_datasrc.cc
run_unittests_SOURCES
+=
rbtree_unittest.cc
run_unittests_SOURCES
+=
logger_unittest.cc
run_unittests_SOURCES
+=
client_unittest.cc
run_unittests_SOURCES
+=
database_unittest.cc
run_unittests_SOURCES
+=
sqlite3_unittest.cc
run_unittests_SOURCES
+=
sqlite3_accessor_unittest.cc
run_unittests_SOURCES
+=
memory_datasrc_unittest.cc
run_unittests_SOURCES
+=
rbnode_rrset_unittest.cc
...
...
@@ -118,3 +122,11 @@ EXTRA_DIST += testdata/new_minor_schema.sqlite3
EXTRA_DIST
+=
testdata/newschema.sqlite3
EXTRA_DIST
+=
testdata/oldschema.sqlite3
EXTRA_DIST
+=
testdata/static.zone
# Added by ticket #2165
EXTRA_DIST
+=
datasrc_unittest.cc
EXTRA_DIST
+=
static_unittest.cc
EXTRA_DIST
+=
query_unittest.cc
EXTRA_DIST
+=
cache_unittest.cc
EXTRA_DIST
+=
sqlite3_unittest.cc
EXTRA_DIST
+=
test_datasrc.h test_datasrc.cc
src/lib/datasrc/tests/database_unittest.cc
View file @
307a588d
...
...
@@ -1711,17 +1711,22 @@ doFindTest(ZoneFinder& finder,
checkRRset
(
result
->
rrset
,
expected_name
!=
Name
(
"."
)
?
expected_name
:
name
,
finder
.
getClass
(),
expected_type
,
expected_ttl
,
expected_rdatas
);
if
(
!
expected_sig_rdatas
.
empty
()
&&
result
->
rrset
->
getRRsig
())
{
checkRRset
(
result
->
rrset
->
getRRsig
(),
expected_name
!=
Name
(
"."
)
?
expected_name
:
name
,
finder
.
getClass
(),
isc
::
dns
::
RRType
::
RRSIG
(),
expected_ttl
,
expected_sig_rdatas
);
}
else
if
(
expected_sig_rdatas
.
empty
())
{
if
((
options
&
ZoneFinder
::
FIND_DNSSEC
)
==
ZoneFinder
::
FIND_DNSSEC
)
{
if
(
!
expected_sig_rdatas
.
empty
()
&&
result
->
rrset
->
getRRsig
())
{
checkRRset
(
result
->
rrset
->
getRRsig
(),
expected_name
!=
Name
(
"."
)
?
expected_name
:
name
,
finder
.
getClass
(),
isc
::
dns
::
RRType
::
RRSIG
(),
expected_ttl
,
expected_sig_rdatas
);
}
else
if
(
expected_sig_rdatas
.
empty
())
{
EXPECT_EQ
(
isc
::
dns
::
RRsetPtr
(),
result
->
rrset
->
getRRsig
())
<<
"Unexpected RRSIG: "
<<
result
->
rrset
->
getRRsig
()
->
toText
();