Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
BIND
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
600
Issues
600
List
Boards
Labels
Service Desk
Milestones
Merge Requests
110
Merge Requests
110
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
BIND
Commits
03be5a6b
Commit
03be5a6b
authored
Apr 22, 2017
by
Mukund Sivaraman
8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance for delegation heavy answers and also general query performance (#44029)
parent
4c31eda5
Changes
134
Hide whitespace changes
Inline
Side-by-side
Showing
134 changed files
with
1570 additions
and
4371 deletions
+1570
-4371
CHANGES
CHANGES
+12
-0
bin/named/config.c
bin/named/config.c
+1
-7
bin/named/include/named/server.h
bin/named/include/named/server.h
+0
-2
bin/named/query.c
bin/named/query.c
+73
-577
bin/named/server.c
bin/named/server.c
+4
-88
bin/tests/system/additional/ns1/named1.conf
bin/tests/system/additional/ns1/named1.conf
+0
-1
bin/tests/system/additional/ns1/named2.conf
bin/tests/system/additional/ns1/named2.conf
+0
-1
bin/tests/system/additional/ns1/named3.conf
bin/tests/system/additional/ns1/named3.conf
+0
-1
bin/tests/system/additional/ns1/named4.conf
bin/tests/system/additional/ns1/named4.conf
+0
-1
bin/tests/system/autosign/clean.sh
bin/tests/system/autosign/clean.sh
+2
-1
bin/tests/system/autosign/ns2/keygen.sh
bin/tests/system/autosign/ns2/keygen.sh
+12
-2
bin/tests/system/autosign/ns4/named.conf
bin/tests/system/autosign/ns4/named.conf
+1
-3
bin/tests/system/autosign/ns5/named.conf
bin/tests/system/autosign/ns5/named.conf
+0
-1
bin/tests/system/autosign/tests.sh
bin/tests/system/autosign/tests.sh
+4
-9
bin/tests/system/cacheclean/ns1/named.conf
bin/tests/system/cacheclean/ns1/named.conf
+1
-2
bin/tests/system/case/ns1/named.conf
bin/tests/system/case/ns1/named.conf
+1
-0
bin/tests/system/case/ns2/named.conf
bin/tests/system/case/ns2/named.conf
+1
-0
bin/tests/system/checknames/ns2/named.conf
bin/tests/system/checknames/ns2/named.conf
+0
-1
bin/tests/system/checknames/ns3/named.conf
bin/tests/system/checknames/ns3/named.conf
+0
-1
bin/tests/system/checknames/ns4/named.conf
bin/tests/system/checknames/ns4/named.conf
+0
-1
bin/tests/system/cookie/ns1/named.conf
bin/tests/system/cookie/ns1/named.conf
+0
-1
bin/tests/system/cookie/ns2/named.conf
bin/tests/system/cookie/ns2/named.conf
+0
-1
bin/tests/system/cookie/ns3/named.conf
bin/tests/system/cookie/ns3/named.conf
+0
-1
bin/tests/system/digdelv/ns3/named.conf
bin/tests/system/digdelv/ns3/named.conf
+0
-1
bin/tests/system/dlv/ns5/named.conf
bin/tests/system/dlv/ns5/named.conf
+0
-1
bin/tests/system/dnssec/ns2/named.conf
bin/tests/system/dnssec/ns2/named.conf
+1
-2
bin/tests/system/dnssec/ns3/named.conf
bin/tests/system/dnssec/ns3/named.conf
+1
-2
bin/tests/system/dnssec/ns4/named1.conf
bin/tests/system/dnssec/ns4/named1.conf
+1
-3
bin/tests/system/dnssec/ns4/named2.conf
bin/tests/system/dnssec/ns4/named2.conf
+1
-3
bin/tests/system/dnssec/ns4/named3.conf
bin/tests/system/dnssec/ns4/named3.conf
+1
-3
bin/tests/system/dnssec/ns4/named4.conf
bin/tests/system/dnssec/ns4/named4.conf
+44
-0
bin/tests/system/dnssec/ns5/named1.conf
bin/tests/system/dnssec/ns5/named1.conf
+0
-1
bin/tests/system/dnssec/ns6/named.conf
bin/tests/system/dnssec/ns6/named.conf
+0
-1
bin/tests/system/dnssec/tests.sh
bin/tests/system/dnssec/tests.sh
+2
-6
bin/tests/system/emptyzones/ns1/named1.conf
bin/tests/system/emptyzones/ns1/named1.conf
+0
-1
bin/tests/system/emptyzones/ns1/named2.conf
bin/tests/system/emptyzones/ns1/named2.conf
+0
-1
bin/tests/system/filter-aaaa/ns1/named1.conf
bin/tests/system/filter-aaaa/ns1/named1.conf
+1
-0
bin/tests/system/filter-aaaa/ns1/named2.conf
bin/tests/system/filter-aaaa/ns1/named2.conf
+1
-0
bin/tests/system/filter-aaaa/ns1/root.db
bin/tests/system/filter-aaaa/ns1/root.db
+8
-4
bin/tests/system/filter-aaaa/ns1/signed.db.in
bin/tests/system/filter-aaaa/ns1/signed.db.in
+6
-4
bin/tests/system/filter-aaaa/ns1/unsigned.db
bin/tests/system/filter-aaaa/ns1/unsigned.db
+6
-4
bin/tests/system/filter-aaaa/ns2/named1.conf
bin/tests/system/filter-aaaa/ns2/named1.conf
+1
-0
bin/tests/system/filter-aaaa/ns2/named2.conf
bin/tests/system/filter-aaaa/ns2/named2.conf
+1
-0
bin/tests/system/filter-aaaa/ns3/named1.conf
bin/tests/system/filter-aaaa/ns3/named1.conf
+1
-0
bin/tests/system/filter-aaaa/ns3/named2.conf
bin/tests/system/filter-aaaa/ns3/named2.conf
+1
-0
bin/tests/system/filter-aaaa/ns4/named1.conf
bin/tests/system/filter-aaaa/ns4/named1.conf
+1
-0
bin/tests/system/filter-aaaa/ns4/named2.conf
bin/tests/system/filter-aaaa/ns4/named2.conf
+1
-0
bin/tests/system/filter-aaaa/ns4/root.db
bin/tests/system/filter-aaaa/ns4/root.db
+10
-6
bin/tests/system/filter-aaaa/ns4/signed.db.in
bin/tests/system/filter-aaaa/ns4/signed.db.in
+6
-4
bin/tests/system/filter-aaaa/ns4/unsigned.db
bin/tests/system/filter-aaaa/ns4/unsigned.db
+6
-4
bin/tests/system/glue/ns1/root.db
bin/tests/system/glue/ns1/root.db
+0
-10
bin/tests/system/glue/tests.sh
bin/tests/system/glue/tests.sh
+0
-8
bin/tests/system/limits/ns1/named.conf
bin/tests/system/limits/ns1/named.conf
+1
-2
bin/tests/system/notify/ns3/named.conf
bin/tests/system/notify/ns3/named.conf
+0
-1
bin/tests/system/notify/ns4/named.conf
bin/tests/system/notify/ns4/named.conf
+0
-1
bin/tests/system/notify/ns5/named.conf
bin/tests/system/notify/ns5/named.conf
+0
-1
bin/tests/system/nsupdate/ns1/named.conf
bin/tests/system/nsupdate/ns1/named.conf
+1
-2
bin/tests/system/nsupdate/ns2/named.conf
bin/tests/system/nsupdate/ns2/named.conf
+0
-1
bin/tests/system/resolver/ns1/named.conf
bin/tests/system/resolver/ns1/named.conf
+0
-1
bin/tests/system/rpz/ns1/named.conf
bin/tests/system/rpz/ns1/named.conf
+1
-2
bin/tests/system/rpz/ns2/named.conf
bin/tests/system/rpz/ns2/named.conf
+1
-3
bin/tests/system/rpz/ns3/named.conf
bin/tests/system/rpz/ns3/named.conf
+1
-3
bin/tests/system/rpz/ns4/named.conf
bin/tests/system/rpz/ns4/named.conf
+1
-2
bin/tests/system/rpz/ns5/named.conf
bin/tests/system/rpz/ns5/named.conf
+1
-3
bin/tests/system/rpz/ns6/named.conf
bin/tests/system/rpz/ns6/named.conf
+1
-0
bin/tests/system/rpz/ns7/named.conf
bin/tests/system/rpz/ns7/named.conf
+1
-0
bin/tests/system/rrl/broken.conf
bin/tests/system/rrl/broken.conf
+0
-2
bin/tests/system/rrl/ns2/named.conf
bin/tests/system/rrl/ns2/named.conf
+0
-2
bin/tests/system/rrl/ns4/named.conf
bin/tests/system/rrl/ns4/named.conf
+0
-2
bin/tests/system/rrsetorder/clean.sh
bin/tests/system/rrsetorder/clean.sh
+1
-3
bin/tests/system/rrsetorder/ns1/root.db
bin/tests/system/rrsetorder/ns1/root.db
+5
-0
bin/tests/system/rrsetorder/ns3/named.conf
bin/tests/system/rrsetorder/ns3/named.conf
+0
-1
bin/tests/system/rrsetorder/ns4/named.conf
bin/tests/system/rrsetorder/ns4/named.conf
+0
-1
bin/tests/system/rrsetorder/tests.sh
bin/tests/system/rrsetorder/tests.sh
+5
-5
bin/tests/system/sfcache/ns5/named.conf
bin/tests/system/sfcache/ns5/named.conf
+0
-1
bin/tests/system/statschannel/ns2/named.conf
bin/tests/system/statschannel/ns2/named.conf
+1
-0
bin/tests/system/stress/ns3/named.conf
bin/tests/system/stress/ns3/named.conf
+0
-1
bin/tests/system/stress/ns4/named.conf
bin/tests/system/stress/ns4/named.conf
+0
-1
bin/tests/system/stub/ns1/named.conf
bin/tests/system/stub/ns1/named.conf
+1
-2
bin/tests/system/stub/ns2/named.conf
bin/tests/system/stub/ns2/named.conf
+1
-2
bin/tests/system/stub/ns3/named.conf
bin/tests/system/stub/ns3/named.conf
+1
-3
bin/tests/system/tkey/ns1/named.conf.in
bin/tests/system/tkey/ns1/named.conf.in
+0
-2
bin/tests/system/tkey/tests.sh
bin/tests/system/tkey/tests.sh
+2
-4
bin/tests/system/upforwd/ns1/named.conf
bin/tests/system/upforwd/ns1/named.conf
+0
-1
bin/tests/system/upforwd/ns2/named.conf
bin/tests/system/upforwd/ns2/named.conf
+0
-1
bin/tests/system/upforwd/ns3/named.conf
bin/tests/system/upforwd/ns3/named.conf
+0
-1
bin/tests/system/v6synth/ns2/named.conf
bin/tests/system/v6synth/ns2/named.conf
+0
-1
bin/tests/system/v6synth/ns3/named.conf
bin/tests/system/v6synth/ns3/named.conf
+0
-1
bin/tests/system/xfer/ns3/named.conf
bin/tests/system/xfer/ns3/named.conf
+0
-1
bin/tests/system/zero/ns1/named.conf
bin/tests/system/zero/ns1/named.conf
+0
-1
bin/tests/system/zero/ns2/named.conf
bin/tests/system/zero/ns2/named.conf
+0
-1
bin/tests/system/zero/ns3/named.conf
bin/tests/system/zero/ns3/named.conf
+0
-1
bin/tests/system/zero/ns4/named.conf
bin/tests/system/zero/ns4/named.conf
+0
-1
doc/arm/Bv9ARM-book.xml
doc/arm/Bv9ARM-book.xml
+34
-230
doc/misc/options
doc/misc/options
+10
-10
lib/bind9/check.c
lib/bind9/check.c
+2
-1
lib/dns/Makefile.in
lib/dns/Makefile.in
+2
-2
lib/dns/acache.c
lib/dns/acache.c
+0
-1790
lib/dns/compress.c
lib/dns/compress.c
+232
-61
lib/dns/ecdb.c
lib/dns/ecdb.c
+2
-4
lib/dns/include/dns/Makefile.in
lib/dns/include/dns/Makefile.in
+1
-1
lib/dns/include/dns/acache.h
lib/dns/include/dns/acache.h
+0
-440
lib/dns/include/dns/compress.h
lib/dns/include/dns/compress.h
+11
-6
lib/dns/include/dns/log.h
lib/dns/include/dns/log.h
+1
-1
lib/dns/include/dns/rdataset.h
lib/dns/include/dns/rdataset.h
+43
-119
lib/dns/include/dns/types.h
lib/dns/include/dns/types.h
+0
-3
lib/dns/include/dns/view.h
lib/dns/include/dns/view.h
+0
-3
lib/dns/include/dns/zone.h
lib/dns/include/dns/zone.h
+0
-13
lib/dns/log.c
lib/dns/log.c
+1
-1
lib/dns/message.c
lib/dns/message.c
+5
-3
lib/dns/name.c
lib/dns/name.c
+24
-16
lib/dns/ncache.c
lib/dns/ncache.c
+10
-12
lib/dns/order.c
lib/dns/order.c
+2
-4
lib/dns/rbtdb.c
lib/dns/rbtdb.c
+709
-422
lib/dns/rdatalist.c
lib/dns/rdatalist.c
+5
-7
lib/dns/rdataset.c
lib/dns/rdataset.c
+87
-150
lib/dns/rdataslab.c
lib/dns/rdataslab.c
+10
-12
lib/dns/sdb.c
lib/dns/sdb.c
+8
-10
lib/dns/sdlz.c
lib/dns/sdlz.c
+8
-10
lib/dns/ssu_external.c
lib/dns/ssu_external.c
+1
-1
lib/dns/view.c
lib/dns/view.c
+0
-20
lib/dns/win32/libdns.def.in
lib/dns/win32/libdns.def.in
+1
-19
lib/dns/win32/libdns.dsp.in
lib/dns/win32/libdns.dsp.in
+0
-8
lib/dns/win32/libdns.mak.in
lib/dns/win32/libdns.mak.in
+0
-24
lib/dns/win32/libdns.vcxproj.filters.in
lib/dns/win32/libdns.vcxproj.filters.in
+1
-7
lib/dns/win32/libdns.vcxproj.in
lib/dns/win32/libdns.vcxproj.in
+1
-3
lib/dns/zone.c
lib/dns/zone.c
+0
-46
lib/isc/hash.c
lib/isc/hash.c
+35
-26
lib/isc/include/isc/buffer.h
lib/isc/include/isc/buffer.h
+27
-23
lib/isc/include/isc/msgs.h
lib/isc/include/isc/msgs.h
+1
-0
lib/isc/mem.c
lib/isc/mem.c
+25
-18
lib/isc/rwlock.c
lib/isc/rwlock.c
+22
-3
lib/isccfg/namedconf.c
lib/isccfg/namedconf.c
+10
-5
util/copyrights
util/copyrights
+0
-2
No files found.
CHANGES
View file @
03be5a6b
4605. [performance] Improve performance for delegation heavy answers
and also general query performance. Removes the
acache feature that didn't significantly improve
performance. Adds a glue cache. Removes
additional-from-cache and additional-from-auth
features. Enables minimal-responses by
default. Improves performance of compression
code, owner case restoration, hash function,
etc. Uses inline buffer implementation by
default. Many other performance changes and fixes.
[RT #44029]
4604. [bug] Don't use ERR_load_crypto_strings() when building
with OpenSSL 1.1.0. [RT #45117]
...
...
bin/named/config.c
View file @
03be5a6b
...
...
@@ -94,7 +94,6 @@ options {\n\
"\
recursive-clients 1000;
\n
\
resolver-query-timeout 10;
\n
\
rrset-order { order random; };
\n
\
# serial-queries <obsolete>;
\n
\
serial-query-rate 20;
\n
\
server-id none;
\n
\
...
...
@@ -140,15 +139,13 @@ options {\n\
# topology <none>
\n
\
auth-nxdomain false;
\n
\
minimal-any false;
\n
\
minimal-responses
fals
e;
\n
\
minimal-responses
tru
e;
\n
\
recursion true;
\n
\
provide-ixfr true;
\n
\
request-ixfr true;
\n
\
request-expire true;
\n
\
# fetch-glue <obsolete>;
\n
\
# rfc2308-type1 <obsolete>;
\n
\
additional-from-auth true;
\n
\
additional-from-cache true;
\n
\
query-source address *;
\n
\
query-source-v6 address *;
\n
\
notify-source *;
\n
\
...
...
@@ -167,9 +164,6 @@ options {\n\
check-dup-records warn;
\n
\
check-mx warn;
\n
\
check-spf warn;
\n
\
acache-enable no;
\n
\
acache-cleaning-interval 60;
\n
\
max-acache-size 16M;
\n
\
dnssec-enable yes;
\n
\
dnssec-validation yes;
\n
\
dnssec-accept-expired no;
\n
\
...
...
bin/named/include/named/server.h
View file @
03be5a6b
...
...
@@ -108,8 +108,6 @@ struct ns_server {
unsigned
int
dispatchgen
;
ns_dispatchlist_t
dispatches
;
dns_acache_t
*
acache
;
ns_statschannellist_t
statschannels
;
dns_tsigkey_t
*
sessionkey
;
...
...
bin/named/query.c
View file @
03be5a6b
...
...
@@ -210,11 +210,6 @@ client_trace(ns_client_t *client, int level, const char *message) {
#define SAVE(a, b) do { INSIST(a == NULL); a = b; b = NULL; } while (0)
#define RESTORE(a, b) SAVE(a, b)
typedef
struct
client_additionalctx
{
ns_client_t
*
client
;
dns_rdataset_t
*
rdataset
;
}
client_additionalctx_t
;
static
isc_boolean_t
validate
(
ns_client_t
*
client
,
dns_db_t
*
db
,
dns_name_t
*
name
,
dns_rdataset_t
*
rdataset
,
dns_rdataset_t
*
sigrdataset
);
...
...
@@ -1032,10 +1027,11 @@ query_validatezonedb(ns_client_t *client, const dns_name_t *name,
* CNAMES or DNAMES into other zones and prevents returning
* additional data from other zones.
*/
if
(
!
client
->
view
->
additionalfromauth
&&
client
->
query
.
authdbset
&&
db
!=
client
->
query
.
authdb
)
if
(
client
->
query
.
rpz_st
==
NULL
&&
client
->
query
.
authdbset
&&
db
!=
client
->
query
.
authdb
)
{
return
(
DNS_R_REFUSED
);
}
/*
* Non recursive query to a static-stub zone is prohibited; its
...
...
@@ -1580,9 +1576,9 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
dns_rdataset_t
*
rdataset
,
*
sigrdataset
,
*
trdataset
;
isc_buffer_t
*
dbuf
;
isc_buffer_t
b
;
ns_dbversion_t
*
dbversion
;
dns_dbversion_t
*
version
;
isc_boolean_t
added_something
,
need_addname
;
dns_zone_t
*
zone
;
dns_rdatatype_t
type
;
dns_clientinfomethods_t
cm
;
dns_clientinfo_t
ci
;
...
...
@@ -1609,7 +1605,6 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
node
=
NULL
;
added_something
=
ISC_FALSE
;
need_addname
=
ISC_FALSE
;
zone
=
NULL
;
additionaltype
=
dns_rdatasetadditional_fromauth
;
dns_clientinfomethods_init
(
&
cm
,
ns_client_sourceip
);
...
...
@@ -1643,14 +1638,26 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
}
/*
* Look for a zone database that might contain authoritative
* If we want only minimal responses and are here, then it must
* be for glue.
*/
if
(
client
->
view
->
minimalresponses
==
dns_minimal_yes
)
goto
try_glue
;
/*
* Look within the same zone database for authoritative
* additional data.
*/
result
=
query_getzonedb
(
client
,
name
,
qtype
,
DNS_GETDB_NOLOG
,
&
zone
,
&
db
,
&
version
);
if
(
result
!=
ISC_R_SUCCESS
)
if
(
!
client
->
query
.
authdbset
||
client
->
query
.
authdb
==
NULL
)
goto
try_cache
;
dbversion
=
query_findversion
(
client
,
client
->
query
.
authdb
);
if
(
dbversion
==
NULL
)
goto
try_cache
;
dns_db_attach
(
client
->
query
.
authdb
,
&
db
);
version
=
dbversion
->
version
;
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional: db_find"
);
/*
...
...
@@ -1684,13 +1691,17 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
*/
try_cache:
if
(
!
client
->
view
->
recursion
)
goto
try_glue
;
additionaltype
=
dns_rdatasetadditional_fromcache
;
result
=
query_getcachedb
(
client
,
name
,
qtype
,
&
db
,
DNS_GETDB_NOLOG
);
if
(
result
!=
ISC_R_SUCCESS
)
if
(
result
!=
ISC_R_SUCCESS
)
{
/*
* Most likely the client isn't allowed to query the cache.
*/
goto
try_glue
;
}
/*
* Attempt to validate glue.
*/
...
...
@@ -1699,6 +1710,8 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
if
(
sigrdataset
==
NULL
)
goto
cleanup
;
}
version
=
NULL
;
result
=
dns_db_findext
(
db
,
name
,
version
,
type
,
client
->
query
.
dboptions
|
DNS_DBFIND_GLUEOK
|
DNS_DBFIND_ADDITIONALOK
,
...
...
@@ -1744,8 +1757,12 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
if
(
!
dns_name_issubdomain
(
name
,
dns_db_origin
(
client
->
query
.
gluedb
)))
goto
cleanup
;
dns_db_attach
(
client
->
query
.
gluedb
,
&
db
);
dbversion
=
query_findversion
(
client
,
client
->
query
.
gluedb
);
if
(
dbversion
==
NULL
)
goto
cleanup
;
dns_db_attach
(
client
->
query
.
gluedb
,
&
db
);
version
=
dbversion
->
version
;
additionaltype
=
dns_rdatasetadditional_fromglue
;
result
=
dns_db_findext
(
db
,
name
,
version
,
type
,
client
->
query
.
dboptions
|
DNS_DBFIND_GLUEOK
,
...
...
@@ -1826,15 +1843,14 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
dns_rdatatype_a
,
0
,
client
->
now
,
rdataset
,
sigrdataset
);
if
(
result
==
DNS_R_NCACHENXDOMAIN
)
if
(
result
==
DNS_R_NCACHENXDOMAIN
)
{
goto
addname
;
if
(
result
==
DNS_R_NCACHENXRRSET
)
{
}
else
if
(
result
==
DNS_R_NCACHENXRRSET
)
{
dns_rdataset_disassociate
(
rdataset
);
if
(
sigrdataset
!=
NULL
&&
dns_rdataset_isassociated
(
sigrdataset
))
dns_rdataset_disassociate
(
sigrdataset
);
}
if
(
result
==
ISC_R_SUCCESS
)
{
}
else
if
(
result
==
ISC_R_SUCCESS
)
{
mname
=
NULL
;
#ifdef ALLOW_FILTER_AAAA
have_a
=
ISC_TRUE
;
...
...
@@ -1887,15 +1903,14 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
dns_rdatatype_aaaa
,
0
,
client
->
now
,
rdataset
,
sigrdataset
);
if
(
result
==
DNS_R_NCACHENXDOMAIN
)
if
(
result
==
DNS_R_NCACHENXDOMAIN
)
{
goto
addname
;
if
(
result
==
DNS_R_NCACHENXRRSET
)
{
}
else
if
(
result
==
DNS_R_NCACHENXRRSET
)
{
dns_rdataset_disassociate
(
rdataset
);
if
(
sigrdataset
!=
NULL
&&
dns_rdataset_isassociated
(
sigrdataset
))
dns_rdataset_disassociate
(
sigrdataset
);
}
if
(
result
==
ISC_R_SUCCESS
)
{
}
else
if
(
result
==
ISC_R_SUCCESS
)
{
mname
=
NULL
;
/*
* There's an A; check whether we're filtering AAAA
...
...
@@ -1992,562 +2007,15 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
dns_db_detachnode
(
db
,
&
node
);
if
(
db
!=
NULL
)
dns_db_detach
(
&
db
);
if
(
zone
!=
NULL
)
dns_zone_detach
(
&
zone
);
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional: done"
);
return
(
eresult
);
}
static
inline
void
query_discardcache
(
ns_client_t
*
client
,
dns_rdataset_t
*
rdataset_base
,
dns_rdatasetadditional_t
additionaltype
,
dns_rdatatype_t
type
,
dns_zone_t
**
zonep
,
dns_db_t
**
dbp
,
dns_dbversion_t
**
versionp
,
dns_dbnode_t
**
nodep
,
dns_name_t
*
fname
)
{
dns_rdataset_t
*
rdataset
;
while
((
rdataset
=
ISC_LIST_HEAD
(
fname
->
list
))
!=
NULL
)
{
ISC_LIST_UNLINK
(
fname
->
list
,
rdataset
,
link
);
query_putrdataset
(
client
,
&
rdataset
);
}
if
(
*
versionp
!=
NULL
)
dns_db_closeversion
(
*
dbp
,
versionp
,
ISC_FALSE
);
if
(
*
nodep
!=
NULL
)
dns_db_detachnode
(
*
dbp
,
nodep
);
if
(
*
dbp
!=
NULL
)
dns_db_detach
(
dbp
);
if
(
*
zonep
!=
NULL
)
dns_zone_detach
(
zonep
);
(
void
)
dns_rdataset_putadditional
(
client
->
view
->
acache
,
rdataset_base
,
additionaltype
,
type
);
}
static
inline
isc_result_t
query_iscachevalid
(
dns_zone_t
*
zone
,
dns_db_t
*
db
,
dns_db_t
*
db0
,
dns_dbversion_t
*
version
)
{
isc_result_t
result
=
ISC_R_SUCCESS
;
dns_dbversion_t
*
version_current
=
NULL
;
dns_db_t
*
db_current
=
db0
;
if
(
db_current
==
NULL
)
{
result
=
dns_zone_getdb
(
zone
,
&
db_current
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
}
dns_db_currentversion
(
db_current
,
&
version_current
);
if
(
db_current
!=
db
||
version_current
!=
version
)
{
result
=
ISC_R_FAILURE
;
goto
cleanup
;
}
cleanup:
dns_db_closeversion
(
db_current
,
&
version_current
,
ISC_FALSE
);
if
(
db0
==
NULL
&&
db_current
!=
NULL
)
dns_db_detach
(
&
db_current
);
return
(
result
);
}
static
isc_result_t
query_addadditional2
(
void
*
arg
,
const
dns_name_t
*
name
,
dns_rdatatype_t
qtype
)
{
client_additionalctx_t
*
additionalctx
=
arg
;
dns_rdataset_t
*
rdataset_base
;
ns_client_t
*
client
;
isc_result_t
result
,
eresult
;
dns_dbnode_t
*
node
,
*
cnode
;
dns_db_t
*
db
,
*
cdb
;
dns_name_t
*
fname
,
*
mname0
,
cfname
;
dns_rdataset_t
*
rdataset
,
*
sigrdataset
;
dns_rdataset_t
*
crdataset
,
*
crdataset_next
;
isc_buffer_t
*
dbuf
;
isc_buffer_t
b
;
dns_dbversion_t
*
version
,
*
cversion
;
isc_boolean_t
added_something
,
need_addname
,
needadditionalcache
;
isc_boolean_t
need_sigrrset
;
dns_zone_t
*
zone
;
dns_rdatatype_t
type
;
dns_rdatasetadditional_t
additionaltype
;
dns_clientinfomethods_t
cm
;
dns_clientinfo_t
ci
;
/*
* If we don't have an additional cache call query_addadditional.
*/
client
=
additionalctx
->
client
;
REQUIRE
(
NS_CLIENT_VALID
(
client
));
if
(
qtype
!=
dns_rdatatype_a
||
client
->
view
->
acache
==
NULL
)
{
/*
* This function is optimized for "address" types. For other
* types, use a generic routine.
* XXX: ideally, this function should be generic enough.
*/
return
(
query_addadditional
(
additionalctx
->
client
,
name
,
qtype
));
}
/*
* Initialization.
*/
rdataset_base
=
additionalctx
->
rdataset
;
eresult
=
ISC_R_SUCCESS
;
fname
=
NULL
;
rdataset
=
NULL
;
sigrdataset
=
NULL
;
db
=
NULL
;
cdb
=
NULL
;
version
=
NULL
;
cversion
=
NULL
;
node
=
NULL
;
cnode
=
NULL
;
added_something
=
ISC_FALSE
;
need_addname
=
ISC_FALSE
;
zone
=
NULL
;
needadditionalcache
=
ISC_FALSE
;
POST
(
needadditionalcache
);
additionaltype
=
dns_rdatasetadditional_fromauth
;
dns_name_init
(
&
cfname
,
NULL
);
dns_clientinfomethods_init
(
&
cm
,
ns_client_sourceip
);
dns_clientinfo_init
(
&
ci
,
client
,
NULL
);
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2"
);
/*
* We treat type A additional section processing as if it
* were "any address type" additional section processing.
* To avoid multiple lookups, we do an 'any' database
* lookup and iterate over the node.
* XXXJT: this approach can cause a suboptimal result when the cache
* DB only has partial address types and the glue DB has remaining
* ones.
*/
type
=
dns_rdatatype_any
;
/*
* Get some resources.
*/
dbuf
=
query_getnamebuf
(
client
);
if
(
dbuf
==
NULL
)
goto
cleanup
;
fname
=
query_newname
(
client
,
dbuf
,
&
b
);
if
(
fname
==
NULL
)
goto
cleanup
;
dns_name_setbuffer
(
&
cfname
,
&
b
);
/* share the buffer */
/* Check additional cache */
result
=
dns_rdataset_getadditional
(
rdataset_base
,
additionaltype
,
type
,
client
->
view
->
acache
,
&
zone
,
&
cdb
,
&
cversion
,
&
cnode
,
&
cfname
,
client
->
message
,
client
->
now
);
if
(
result
!=
ISC_R_SUCCESS
)
goto
findauthdb
;
if
(
zone
==
NULL
)
{
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: auth zone not found"
);
goto
try_cache
;
}
/* Is the cached DB up-to-date? */
result
=
query_iscachevalid
(
zone
,
cdb
,
NULL
,
cversion
);
if
(
result
!=
ISC_R_SUCCESS
)
{
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: old auth additional cache"
);
query_discardcache
(
client
,
rdataset_base
,
additionaltype
,
type
,
&
zone
,
&
cdb
,
&
cversion
,
&
cnode
,
&
cfname
);
goto
findauthdb
;
}
if
(
cnode
==
NULL
)
{
/*
* We have a negative cache. We don't have to check the zone
* ACL, since the result (not using this zone) would be same
* regardless of the result.
*/
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: negative auth additional cache"
);
dns_db_closeversion
(
cdb
,
&
cversion
,
ISC_FALSE
);
dns_db_detach
(
&
cdb
);
dns_zone_detach
(
&
zone
);
goto
try_cache
;
}
result
=
query_validatezonedb
(
client
,
name
,
qtype
,
DNS_GETDB_NOLOG
,
zone
,
cdb
,
NULL
);
if
(
result
!=
ISC_R_SUCCESS
)
{
query_discardcache
(
client
,
rdataset_base
,
additionaltype
,
type
,
&
zone
,
&
cdb
,
&
cversion
,
&
cnode
,
&
cfname
);
goto
try_cache
;
}
/* We've got an active cache. */
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: auth additional cache"
);
dns_db_closeversion
(
cdb
,
&
cversion
,
ISC_FALSE
);
db
=
cdb
;
node
=
cnode
;
dns_name_clone
(
&
cfname
,
fname
);
query_keepname
(
client
,
fname
,
dbuf
);
goto
foundcache
;
/*
* Look for a zone database that might contain authoritative
* additional data.
*/
findauthdb:
result
=
query_getzonedb
(
client
,
name
,
qtype
,
DNS_GETDB_NOLOG
,
&
zone
,
&
db
,
&
version
);
if
(
result
!=
ISC_R_SUCCESS
)
{
/* Cache the negative result */
(
void
)
dns_rdataset_setadditional
(
rdataset_base
,
additionaltype
,
type
,
client
->
view
->
acache
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
goto
try_cache
;
}
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: db_find"
);
/*
* Since we are looking for authoritative data, we do not set
* the GLUEOK flag. Glue will be looked for later, but not
* necessarily in the same database.
*/
node
=
NULL
;
result
=
dns_db_findext
(
db
,
name
,
version
,
type
,
client
->
query
.
dboptions
,
client
->
now
,
&
node
,
fname
,
&
cm
,
&
ci
,
NULL
,
NULL
);
if
(
result
==
ISC_R_SUCCESS
)
goto
found
;
/* Cache the negative result */
(
void
)
dns_rdataset_setadditional
(
rdataset_base
,
additionaltype
,
type
,
client
->
view
->
acache
,
zone
,
db
,
version
,
NULL
,
fname
);
if
(
node
!=
NULL
)
dns_db_detachnode
(
db
,
&
node
);
version
=
NULL
;
dns_db_detach
(
&
db
);
/*
* No authoritative data was found. The cache is our next best bet.
*/
try_cache:
additionaltype
=
dns_rdatasetadditional_fromcache
;
result
=
query_getcachedb
(
client
,
name
,
qtype
,
&
db
,
DNS_GETDB_NOLOG
);
if
(
result
!=
ISC_R_SUCCESS
)
/*
* Most likely the client isn't allowed to query the cache.
*/
goto
try_glue
;
result
=
dns_db_findext
(
db
,
name
,
version
,
type
,
client
->
query
.
dboptions
|
DNS_DBFIND_GLUEOK
|
DNS_DBFIND_ADDITIONALOK
,
client
->
now
,
&
node
,
fname
,
&
cm
,
&
ci
,
NULL
,
NULL
);
if
(
result
==
ISC_R_SUCCESS
)
goto
found
;
if
(
node
!=
NULL
)
dns_db_detachnode
(
db
,
&
node
);
dns_db_detach
(
&
db
);
try_glue:
/*
* No cached data was found. Glue is our last chance.
* RFC1035 sayeth:
*
* NS records cause both the usual additional section
* processing to locate a type A record, and, when used
* in a referral, a special search of the zone in which
* they reside for glue information.
*
* This is the "special search". Note that we must search
* the zone where the NS record resides, not the zone it
* points to, and that we only do the search in the delegation
* case (identified by client->query.gluedb being set).
*/
if
(
client
->
query
.
gluedb
==
NULL
)
goto
cleanup
;
/*
* Don't poison caches using the bailiwick protection model.
*/
if
(
!
dns_name_issubdomain
(
name
,
dns_db_origin
(
client
->
query
.
gluedb
)))
goto
cleanup
;
/* Check additional cache */
additionaltype
=
dns_rdatasetadditional_fromglue
;
result
=
dns_rdataset_getadditional
(
rdataset_base
,
additionaltype
,
type
,
client
->
view
->
acache
,
NULL
,
&
cdb
,
&
cversion
,
&
cnode
,
&
cfname
,
client
->
message
,
client
->
now
);
if
(
result
!=
ISC_R_SUCCESS
)
goto
findglue
;
result
=
query_iscachevalid
(
zone
,
cdb
,
client
->
query
.
gluedb
,
cversion
);
if
(
result
!=
ISC_R_SUCCESS
)
{
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: old glue additional cache"
);
query_discardcache
(
client
,
rdataset_base
,
additionaltype
,
type
,
&
zone
,
&
cdb
,
&
cversion
,
&
cnode
,
&
cfname
);
goto
findglue
;
}
if
(
cnode
==
NULL
)
{
/* We have a negative cache. */
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: negative glue additional cache"
);
dns_db_closeversion
(
cdb
,
&
cversion
,
ISC_FALSE
);
dns_db_detach
(
&
cdb
);
goto
cleanup
;
}
/* Cache hit. */
CTRACE
(
ISC_LOG_DEBUG
(
3
),
"query_addadditional2: glue additional cache"
);
dns_db_closeversion
(
cdb
,
&
cversion
,
ISC_FALSE
);
db
=
cdb
;
node
=
cnode
;
dns_name_clone
(
&
cfname
,
fname
);
query_keepname
(
client
,
fname
,
dbuf
);
goto
foundcache
;
findglue:
dns_db_attach
(
client
->
query
.
gluedb
,
&
db
);
result
=
dns_db_findext
(
db
,
name
,
version
,
type
,
client
->
query
.
dboptions
|
DNS_DBFIND_GLUEOK
,
client
->
now
,
&
node
,
fname
,
&
cm
,
&
ci
,
NULL
,
NULL
);
if
(
!
(
result
==
ISC_R_SUCCESS
||
result
==
DNS_R_ZONECUT
||
result
==
DNS_R_GLUE
))
{
/* cache the negative result */
(
void
)
dns_rdataset_setadditional
(
rdataset_base
,
additionaltype
,
type
,
client
->
view
->
acache
,
NULL
,
db
,
version
,
NULL
,
fname
);
goto
cleanup
;
}
found:
/*
* We have found a DB node to iterate over from a DB.
* We are going to look for address RRsets (i.e., A and AAAA) in the DB
* node we've just found. We'll then store the complete information
* in the additional data cache.
*/
dns_name_clone
(
fname
,
&
cfname
);
query_keepname
(
client
,
fname
,
dbuf
);
needadditionalcache
=
ISC_TRUE
;
rdataset
=
query_newrdataset
(
client
);
if
(
rdataset
==
NULL
)
goto
cleanup
;
sigrdataset
=
query_newrdataset
(
client
);
if
(
sigrdataset
==
NULL
)
goto
cleanup
;
if
(
additionaltype
==
dns_rdatasetadditional_fromcache
&&
query_isduplicate
(
client
,
fname
,
dns_rdatatype_a
,
NULL
))
goto
aaaa_lookup
;
/*
* Find A RRset with sig RRset. Even if we don't find a sig RRset
* for a client using DNSSEC, we'll continue the process to make a
* complete list to be cached. However, we need to cancel the
* caching when something unexpected happens, in order to avoid
* caching incomplete information.