Commit bfcdcde5 authored by Mark Andrews's avatar Mark Andrews
Browse files

implement lame-ttl.

parent ae97c3e7
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.239 2000/11/07 23:49:19 mws Exp $ */
/* $Id: server.c,v 1.240 2000/11/08 03:53:05 marka Exp $ */
#include <config.h>
......@@ -385,6 +385,7 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
isc_result_t result;
isc_uint32_t cleaning_interval;
isc_uint32_t max_cache_size;
isc_uint32_t lame_ttl;
dns_tsig_keyring_t *ring;
dns_c_iplist_t *forwarders;
dns_view_t *pview = NULL; /* Production view */
......@@ -499,6 +500,18 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
if (dispatch6 != NULL)
dns_dispatch_detach(&dispatch6);
/*
* Set resolver's lame-ttl.
*/
result = dns_c_view_getlamettl(cctx, &lame_ttl);
if (result == ISC_R_NOTFOUND)
result = dns_c_ctx_getlamettl(cctx, &lame_ttl);
if (result == ISC_R_NOTFOUND)
lame_ttl = 600;
if (lame_ttl > 18000)
lame_ttl = 18000;
dns_resolver_setlamettl(view->resolver, lame_ttl);
/*
* Set resolver forwarding policy.
*/
......
......@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<!-- File: $Id: Bv9ARM-book.xml,v 1.32 2000/11/06 23:48:48 gson Exp $ -->
<!-- File: $Id: Bv9ARM-book.xml,v 1.33 2000/11/08 03:53:07 marka Exp $ -->
<book>
......@@ -3389,8 +3389,6 @@ lame server indication. 0 disables caching. (This is
<emphasis role="bold">NOT</emphasis> recommended.)
Default is <literal>600</literal> (10 minutes). Maximum value is
<literal>1800</literal> (30 minutes).</para>
<note>
<simpara>Not yet implemented in <acronym>BIND</acronym> 9.</simpara></note>
</entry>
</row>
<row rowsep = "0">
......
Copyright (C) 2000 Internet Software Consortium.
See COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
$Id: options,v 1.39 2000/11/04 02:20:57 bwelling Exp $
$Id: options,v 1.40 2000/11/08 03:53:10 marka Exp $
This is a summary of the implementation status of the various named.conf
options in BIND 9.
......@@ -65,7 +65,7 @@ options {
[ listen-on-v6 [ port ip_port ] { address_match_list }; ] Yes*
[ query-source ... ] Yes
[ query-source-v6 ... ] Yes*
[ lame-ttl number; ] No
[ lame-ttl number; ] Yes
[ max-transfer-time-in number; ] Yes
[ max-transfer-idle-in number; ] Yes*
[ max-transfer-time-out number; ] Yes*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confctx.c,v 1.98 2000/11/07 23:49:31 mws Exp $ */
/* $Id: confctx.c,v 1.99 2000/11/08 03:53:13 marka Exp $ */
#include <config.h>
......@@ -446,13 +446,6 @@ dns_c_checkconfig(dns_c_ctx_t *cfg)
"option 'check-names' is not yet implemented");
}
if (dns_c_ctx_getlamettl(cfg, &uintval) != ISC_R_NOTFOUND) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_WARNING,
"option 'lame-ttl' is not yet "
"implemented");
}
if (dns_c_ctx_getminroots(cfg, &uintval) != ISC_R_NOTFOUND) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_WARNING,
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confview.c,v 1.54 2000/11/07 23:49:36 mws Exp $ */
/* $Id: confview.c,v 1.55 2000/11/08 03:53:14 marka Exp $ */
#include <config.h>
......@@ -411,12 +411,6 @@ dns_c_viewtable_checkviews(dns_c_viewtable_t *viewtable) {
"view 'max-cache-ttl' is not yet "
"implemented");
if (dns_c_view_getlamettl(elem, &buival) != ISC_R_NOTFOUND)
isc_log_write(dns_lctx,DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_WARNING,
"view 'lame-ttl' is not yet "
"implemented");
if (dns_c_view_getminroots(elem, &buival) != ISC_R_NOTFOUND)
isc_log_write(dns_lctx,DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG, ISC_LOG_WARNING,
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.h,v 1.32 2000/08/24 22:15:36 bwelling Exp $ */
/* $Id: resolver.h,v 1.33 2000/11/08 03:53:16 marka Exp $ */
#ifndef DNS_RESOLVER_H
#define DNS_RESOLVER_H 1
......@@ -331,6 +331,24 @@ dns_resolver_socketmgr(dns_resolver_t *resolver);
isc_taskmgr_t *
dns_resolver_taskmgr(dns_resolver_t *resolver);
isc_uint32_t
dns_resolver_getlamettl(dns_resolver_t *resolver);
/*
* Get the resolver's lame-ttl. zero => no lame processing.
*
* Requires:
* 'resolver' to be valid.
*/
void
dns_resolver_setlamettl(dns_resolver_t *resolver, isc_uint32_t lame_ttl);
/*
* Set the resolver's lame-ttl. zero => no lame processing.
*
* Requires:
* 'resolver' to be valid.
*/
ISC_LANG_ENDDECLS
#endif /* DNS_RESOLVER_H */
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.c,v 1.178 2000/11/04 02:20:58 bwelling Exp $ */
/* $Id: resolver.c,v 1.179 2000/11/08 03:53:11 marka Exp $ */
#include <config.h>
......@@ -237,6 +237,7 @@ struct dns_resolver {
dns_dispatch_t * dispatchv6;
unsigned int nbuckets;
fctxbucket_t * buckets;
isc_uint32_t lame_ttl;
/* Locked by lock. */
unsigned int references;
isc_boolean_t exiting;
......@@ -2179,6 +2180,64 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
/*
* Handle Responses
*/
static inline isc_boolean_t
is_lame(fetchctx_t *fctx) {
dns_message_t *message = fctx->rmessage;
dns_name_t *name;
dns_rdataset_t *rdataset;
isc_result_t result;
if (message->rcode != dns_rcode_noerror &&
message->rcode != dns_rcode_nxdomain)
return (ISC_FALSE);
if (message->counts[DNS_SECTION_ANSWER] != 0)
return (ISC_FALSE);
if (message->counts[DNS_SECTION_AUTHORITY] == 0)
return (ISC_FALSE);
result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
while (result == ISC_R_SUCCESS) {
name = NULL;
dns_message_currentname(message, DNS_SECTION_AUTHORITY, &name);
for (rdataset = ISC_LIST_HEAD(name->list);
rdataset != NULL;
rdataset = ISC_LIST_NEXT(rdataset, link)) {
dns_namereln_t namereln;
int order;
unsigned int labels, bits;
if (rdataset->type != dns_rdatatype_ns)
continue;
namereln = dns_name_fullcompare(name, &fctx->domain,
&order, &labels, &bits);
if (namereln == dns_namereln_equal &&
(message->flags & DNS_MESSAGEFLAG_AA) == 0)
return (ISC_TRUE);
if (namereln == dns_namereln_subdomain)
return (ISC_FALSE);
return (ISC_TRUE);
}
result = dns_message_nextname(message, DNS_SECTION_AUTHORITY);
}
return (ISC_FALSE);
}
static inline void
log_lame(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo) {
char namebuf[1024];
char domainbuf[1024];
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
dns_name_format(&fctx->name, namebuf, sizeof(namebuf));
dns_name_format(&fctx->domain, domainbuf, sizeof(domainbuf));
isc_sockaddr_format(&addrinfo->sockaddr, addrbuf, sizeof(addrbuf));
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER, ISC_LOG_INFO,
"Lame server on '%s' (in '%s'?): %s",
namebuf, domainbuf, addrbuf);
}
static inline isc_result_t
same_question(fetchctx_t *fctx) {
......@@ -4087,6 +4146,19 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
goto done;
}
/*
* Is the server lame?
*/
if (fctx->res->lame_ttl != 0 && !ISFORWARDER(query->addrinfo) &&
is_lame(fctx)) {
log_lame(fctx, query->addrinfo);
dns_adb_marklame(fctx->res->view->adb, query->addrinfo,
&fctx->domain, now + fctx->res->lame_ttl);
broken_server = ISC_TRUE;
keep_trying = ISC_TRUE;
goto done;
}
/*
* Did we get any answers?
*/
......@@ -4369,6 +4441,7 @@ dns_resolver_create(dns_view_t *view,
res->dispatchmgr = dispatchmgr;
res->view = view;
res->options = options;
res->lame_ttl = 0;
res->nbuckets = ntasks;
res->activebuckets = ntasks;
......@@ -4952,3 +5025,15 @@ dns_resolver_taskmgr(dns_resolver_t *resolver) {
REQUIRE(VALID_RESOLVER(resolver));
return (resolver->taskmgr);
}
isc_uint32_t
dns_resolver_getlamettl(dns_resolver_t *resolver) {
REQUIRE(VALID_RESOLVER(resolver));
return (resolver->lame_ttl);
}
void
dns_resolver_setlamettl(dns_resolver_t *resolver, isc_uint32_t lame_ttl) {
REQUIRE(VALID_RESOLVER(resolver));
resolver->lame_ttl = lame_ttl;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment