summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/dns/ncache.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/dns/ncache.c')
-rw-r--r--contrib/bind9/lib/dns/ncache.c64
1 files changed, 9 insertions, 55 deletions
diff --git a/contrib/bind9/lib/dns/ncache.c b/contrib/bind9/lib/dns/ncache.c
index cfa4783..420a118 100644
--- a/contrib/bind9/lib/dns/ncache.c
+++ b/contrib/bind9/lib/dns/ncache.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007, 2008, 2010 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2008, 2010, 2011 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: ncache.c,v 1.43.48.7.6.1 2011-05-27 00:19:19 each Exp $ */
+/* $Id: ncache.c,v 1.50.124.1.2.3 2011-06-21 20:15:47 each Exp $ */
/*! \file */
@@ -35,7 +35,7 @@
#define DNS_NCACHE_RDATA 20U
/*
- * The format of an ncache rdata is a sequence of one or more records of
+ * The format of an ncache rdata is a sequence of zero or more records of
* the following format:
*
* owner name
@@ -223,42 +223,6 @@ dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
return (result);
if (trust == 0xffff) {
- /*
- * We didn't find any authority data from which to create a
- * negative cache rdataset. In particular, we have no SOA.
- *
- * We trust that the caller wants negative caching, so this
- * means we have a "type 3 nxdomain" or "type 3 nodata"
- * response (see RFC2308 for details).
- *
- * We will now build a suitable negative cache rdataset that
- * will cause zero bytes to be emitted when converted to
- * wire format.
- */
-
- /*
- * The ownername must exist, but it doesn't matter what value
- * it has. We use the root name.
- */
- dns_name_toregion(dns_rootname, &r);
- result = isc_buffer_copyregion(&buffer, &r);
- if (result != ISC_R_SUCCESS)
- return (result);
- /*
- * Copy the type and a zero rdata count to the buffer.
- */
- isc_buffer_availableregion(&buffer, &r);
- if (r.length < 5)
- return (ISC_R_NOSPACE);
- isc_buffer_putuint16(&buffer, 0); /* type */
- /*
- * RFC2308, section 5, says that negative answers without
- * SOAs should not be cached.
- */
- ttl = 0;
- /*
- * Set trust.
- */
if ((message->flags & DNS_MESSAGEFLAG_AA) != 0 &&
message->counts[DNS_SECTION_ANSWER] == 0) {
/*
@@ -268,22 +232,7 @@ dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
trust = dns_trust_authauthority;
} else
trust = dns_trust_additional;
- isc_buffer_putuint8(&buffer, (unsigned char)trust); /* trust */
- isc_buffer_putuint16(&buffer, 0); /* count */
-
- /*
- * Now add it to the cache.
- */
- if (next >= DNS_NCACHE_RDATA)
- return (ISC_R_NOSPACE);
- dns_rdata_init(&rdata[next]);
- isc_buffer_remainingregion(&buffer, &r);
- rdata[next].data = r.base;
- rdata[next].length = r.length;
- rdata[next].rdclass = ncrdatalist.rdclass;
- rdata[next].type = 0;
- rdata[next].flags = 0;
- ISC_LIST_APPEND(ncrdatalist.rdata, &rdata[next], link);
+ ttl = 0;
}
INSIST(trust != 0xffff);
@@ -294,6 +243,7 @@ dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
RUNTIME_CHECK(dns_rdatalist_tordataset(&ncrdatalist, &ncrdataset)
== ISC_R_SUCCESS);
ncrdataset.trust = trust;
+ ncrdataset.attributes |= DNS_RDATASETATTR_NEGATIVE;
if (message->rcode == dns_rcode_nxdomain)
ncrdataset.attributes |= DNS_RDATASETATTR_NXDOMAIN;
if (optout)
@@ -324,6 +274,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
REQUIRE(rdataset != NULL);
REQUIRE(rdataset->type == 0);
+ REQUIRE((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
savedbuffer = *target;
count = 0;
@@ -552,6 +503,7 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == 0);
+ REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
REQUIRE(name != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
REQUIRE(type != dns_rdatatype_rrsig);
@@ -628,6 +580,7 @@ dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == 0);
+ REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
REQUIRE(name != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
@@ -727,6 +680,7 @@ dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == 0);
+ REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
REQUIRE(found != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
OpenPOWER on IntegriCloud