From e549eb1242b69ee050440e7205a5633cb56199b3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 28 Sep 2000 06:43:36 +0000 Subject: [PATCH] 494. [func] Do not cache NXDOMAIN responses for SOA queries. --- CHANGES | 2 ++ lib/dns/resolver.c | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index c500740618..0e770f4ccc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 494. [func] Do not cache NXDOMAIN responses for SOA queries. + 493. [func] Return non-cachable (ttl = 0) NXDOMAIN responses for SOA queries. This makes it easier to locate the containing zone without polluting intermediate diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index c2edc36bfd..1597bda692 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.168 2000/09/15 22:41:07 bwelling Exp $ */ +/* $Id: resolver.c,v 1.169 2000/09/28 06:43:36 marka Exp $ */ #include @@ -2272,6 +2272,7 @@ validated(isc_task_t *task, isc_event_t *event) { dns_dbnode_t *node = NULL; isc_boolean_t negative; isc_boolean_t sentresponse; + isc_uint32_t ttl; UNUSED(task); /* for now */ @@ -2365,10 +2366,19 @@ validated(isc_task_t *task, isc_event_t *event) { if (result != ISC_R_SUCCESS) goto noanswer_response; + /* + * If we are asking for a SOA record set the cache time + * to zero to facilitate locating the containing zone of + * a arbitary zone. + */ + ttl = fctx->res->view->maxncachettl; + if (fctx->type == dns_rdatatype_soa && + covers == dns_rdatatype_any) + ttl = 0; + result = ncache_adderesult(fctx->rmessage, fctx->res->view->cachedb, node, - covers, now, - fctx->res->view->maxncachettl, + covers, now, ttl, ardataset, &eresult); if (result != ISC_R_SUCCESS) goto noanswer_response; @@ -2860,6 +2870,7 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) { isc_boolean_t need_validation, secure_domain; dns_name_t *aname; dns_fetchevent_t *event; + isc_uint32_t ttl; FCTXTRACE("ncache_message"); @@ -2959,9 +2970,18 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) { if (result != ISC_R_SUCCESS) goto unlock; + /* + * If we are asking for a SOA record set the cache time + * to zero to facilitate locating the containing zone of + * a arbitary zone. + */ + ttl = fctx->res->view->maxncachettl; + if (fctx->type == dns_rdatatype_soa && + covers == dns_rdatatype_any) + ttl = 0; + result = ncache_adderesult(fctx->rmessage, res->view->cachedb, node, - covers, now, res->view->maxncachettl, - ardataset, &eresult); + covers, now, ttl, ardataset, &eresult); if (result != ISC_R_SUCCESS) goto unlock;