bind9/lib
Michał Kępień 7c58cbd31a Restore zone database and zone node if cache search results are to be ignored
When query processing hits a delegation from a locally configured zone,
an attempt may be made to look for a better answer in the cache.  In
such a case, the zone-sourced delegation data is set aside and the
lookup is retried using the cache database.  When that lookup is
completed, a decision is made whether the answer found in the cache is
better than the answer found in the zone.

Currently, if the zone-sourced answer turns out to be better than the
one found in the cache:

  - qctx->zdb is not restored into qctx->db,
  - qctx->node, holding the zone database node found, is not even saved.

Thus, in such a case both qctx->db and qctx->node will point at cache
data.  This is not an issue for BIND versions which do not support
mirror zones because in these versions non-recursive queries always
cause the zone-sourced delegation to be returned and thus the
non-recursive part of query_delegation() is never reached if the
delegation is coming from a zone.  With mirror zones, however,
non-recursive queries may cause cache lookups even after a zone
delegation is found.  Leaving qctx->db assigned to the cache database
when query_delegation() determines that the zone-sourced delegation is
the best answer to the client's query prevents DS records from being
added to delegations coming from mirror zones.  Fix this issue by
keeping the zone database and zone node in qctx while the cache is
searched for an answer and then restoring them into qctx->db and
qctx->node, respectively, if the zone-sourced delegation turns out to be
the best answer.  Since this change means that qctx->zdb cannot be used
as the glue database any more as it will be reset to NULL by RESTORE(),
ensure that qctx->db is not a cache database before attaching it to
qctx->client->query.gluedb.

If qctx->zdb is not NULL, qctx->zfname will also not be NULL;
qctx->zsigrdataset may be NULL in such a case, but query_putrdataset()
handles pointers to NULL pointers gracefully.  Remove redundant
conditional expressions to make the cleanup code in query_freedata()
match the corresponding sequences of SAVE() / RESTORE() macros more
closely.

(cherry picked from commit b6c77202cb)
2018-08-08 08:09:25 +02:00
..
bind9 prep 9.12.2rc2 2018-06-28 04:42:37 +00:00
dns Define and use new DNS_RDATASET_COUNT_UNDEFINED equals ISC_UINT32_MAX to make the code more readable 2018-08-06 13:03:28 +02:00
irs prepare 9.12.1rc1 2018-06-21 18:46:32 +02:00
isc remove dead code 2018-08-03 09:50:25 +10:00
isccc prepare 9.12.1rc1 2018-06-21 18:46:32 +02:00
isccfg prep 9.12.2rc2 2018-06-28 04:42:37 +00:00
ns Restore zone database and zone node if cache search results are to be ignored 2018-08-08 08:09:25 +02:00
samples Remove $Id markers, Principal Author and Reviewed tags from the full source tree 2018-05-11 14:19:35 +02:00
win32/bindevt Remove $Id markers, Principal Author and Reviewed tags from the full source tree 2018-05-11 14:19:35 +02:00
.gitignore added gitignore, removed cvsignore 2012-03-03 23:10:05 -08:00
Atffile [master] add libns and remove liblwres 2017-09-08 13:47:34 -07:00
Kyuafile regen v9_12 2017-12-29 02:16:29 +00:00
Makefile.in remove lib/tests as nothing uses it anymore 2018-03-09 14:39:57 -08:00