1999-09-09 08:21:45 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
1999-09-09 08:21:45 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
|
|
|
|
/*! \file */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-09-09 08:21:45 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2012-12-19 09:55:02 +11:00
|
|
|
#include <isc/log.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/string.h>
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-09-09 08:21:45 +00:00
|
|
|
|
|
|
|
#include <dns/db.h>
|
2003-09-30 06:00:40 +00:00
|
|
|
#include <dns/nsec.h>
|
1999-09-09 08:21:45 +00:00
|
|
|
#include <dns/rdata.h>
|
2000-05-02 03:54:17 +00:00
|
|
|
#include <dns/rdatalist.h>
|
1999-09-09 08:21:45 +00:00
|
|
|
#include <dns/rdataset.h>
|
|
|
|
#include <dns/rdatasetiter.h>
|
2000-10-07 00:09:28 +00:00
|
|
|
#include <dns/rdatastruct.h>
|
2000-05-02 03:54:17 +00:00
|
|
|
#include <dns/result.h>
|
1999-09-09 08:21:45 +00:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
#include <dst/dst.h>
|
|
|
|
|
2000-10-28 01:25:14 +00:00
|
|
|
#define RETERR(x) do { \
|
|
|
|
result = (x); \
|
|
|
|
if (result != ISC_R_SUCCESS) \
|
|
|
|
goto failure; \
|
1999-09-09 08:21:45 +00:00
|
|
|
} while (0)
|
|
|
|
|
2012-06-25 13:57:32 +10:00
|
|
|
void
|
|
|
|
dns_nsec_setbit(unsigned char *array, unsigned int type, unsigned int bit) {
|
2000-05-13 20:39:17 +00:00
|
|
|
unsigned int shift, mask;
|
|
|
|
|
2012-06-25 13:57:32 +10:00
|
|
|
shift = 7 - (type % 8);
|
1999-09-09 08:21:45 +00:00
|
|
|
mask = 1 << shift;
|
|
|
|
|
2000-05-13 20:39:17 +00:00
|
|
|
if (bit != 0)
|
2012-06-25 13:57:32 +10:00
|
|
|
array[type / 8] |= mask;
|
1999-09-09 08:21:45 +00:00
|
|
|
else
|
2012-06-25 13:57:32 +10:00
|
|
|
array[type / 8] &= (~mask & 0xFF);
|
1999-09-09 08:21:45 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 23:46:00 +00:00
|
|
|
isc_boolean_t
|
2012-06-25 13:57:32 +10:00
|
|
|
dns_nsec_isset(const unsigned char *array, unsigned int type) {
|
1999-09-09 08:21:45 +00:00
|
|
|
unsigned int byte, shift, mask;
|
2000-05-13 20:39:17 +00:00
|
|
|
|
2012-06-25 13:57:32 +10:00
|
|
|
byte = array[type / 8];
|
|
|
|
shift = 7 - (type % 8);
|
1999-09-09 08:21:45 +00:00
|
|
|
mask = 1 << shift;
|
2000-05-13 20:39:17 +00:00
|
|
|
|
2012-06-25 13:57:32 +10:00
|
|
|
return (ISC_TF(byte & mask));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
dns_nsec_compressbitmap(unsigned char *map, const unsigned char *raw,
|
|
|
|
unsigned int max_type)
|
|
|
|
{
|
|
|
|
unsigned char *start = map;
|
|
|
|
unsigned int window;
|
|
|
|
int octet;
|
|
|
|
|
|
|
|
if (raw == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
for (window = 0; window < 256; window++) {
|
|
|
|
if (window * 256 > max_type)
|
|
|
|
break;
|
|
|
|
for (octet = 31; octet >= 0; octet--)
|
|
|
|
if (*(raw + octet) != 0)
|
|
|
|
break;
|
|
|
|
if (octet < 0) {
|
|
|
|
raw += 32;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*map++ = window;
|
|
|
|
*map++ = octet + 1;
|
|
|
|
/*
|
|
|
|
* Note: potential overlapping move.
|
|
|
|
*/
|
|
|
|
memmove(map, raw, octet + 1);
|
|
|
|
map += octet + 1;
|
|
|
|
raw += 32;
|
|
|
|
}
|
2013-12-04 12:47:23 +11:00
|
|
|
return (unsigned int)(map - start);
|
1999-09-09 08:21:45 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version,
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_dbnode_t *node, const dns_name_t *target,
|
2003-09-30 06:00:40 +00:00
|
|
|
unsigned char *buffer, dns_rdata_t *rdata)
|
1999-09-09 08:21:45 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
dns_rdataset_t rdataset;
|
|
|
|
isc_region_t r;
|
2012-06-25 13:57:32 +10:00
|
|
|
unsigned int i;
|
1999-09-09 08:21:45 +00:00
|
|
|
|
2003-12-13 04:20:44 +00:00
|
|
|
unsigned char *nsec_bits, *bm;
|
1999-09-09 08:21:45 +00:00
|
|
|
unsigned int max_type;
|
|
|
|
dns_rdatasetiter_t *rdsiter;
|
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
memset(buffer, 0, DNS_NSEC_BUFFERSIZE);
|
1999-09-09 08:21:45 +00:00
|
|
|
dns_name_toregion(target, &r);
|
2014-01-08 16:27:10 -08:00
|
|
|
memmove(buffer, r.base, r.length);
|
1999-09-09 08:21:45 +00:00
|
|
|
r.base = buffer;
|
2003-12-13 04:20:44 +00:00
|
|
|
/*
|
|
|
|
* Use the end of the space for a raw bitmap leaving enough
|
|
|
|
* space for the window identifiers and length octets.
|
|
|
|
*/
|
|
|
|
bm = r.base + r.length + 512;
|
2003-09-30 06:00:40 +00:00
|
|
|
nsec_bits = r.base + r.length;
|
2012-06-25 13:57:32 +10:00
|
|
|
dns_nsec_setbit(bm, dns_rdatatype_rrsig, 1);
|
|
|
|
dns_nsec_setbit(bm, dns_rdatatype_nsec, 1);
|
2003-09-30 06:00:40 +00:00
|
|
|
max_type = dns_rdatatype_nsec;
|
1999-09-09 08:21:45 +00:00
|
|
|
dns_rdataset_init(&rdataset);
|
|
|
|
rdsiter = NULL;
|
|
|
|
result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-09-09 08:21:45 +00:00
|
|
|
return (result);
|
|
|
|
for (result = dns_rdatasetiter_first(rdsiter);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdatasetiter_next(rdsiter))
|
|
|
|
{
|
|
|
|
dns_rdatasetiter_current(rdsiter, &rdataset);
|
2008-09-24 02:46:23 +00:00
|
|
|
if (rdataset.type != dns_rdatatype_nsec &&
|
|
|
|
rdataset.type != dns_rdatatype_nsec3 &&
|
|
|
|
rdataset.type != dns_rdatatype_rrsig) {
|
1999-09-09 08:21:45 +00:00
|
|
|
if (rdataset.type > max_type)
|
|
|
|
max_type = rdataset.type;
|
2012-06-25 13:57:32 +10:00
|
|
|
dns_nsec_setbit(bm, rdataset.type, 1);
|
1999-09-09 08:21:45 +00:00
|
|
|
}
|
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
}
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* At zone cuts, deny the existence of glue in the parent zone.
|
|
|
|
*/
|
2012-06-25 13:57:32 +10:00
|
|
|
if (dns_nsec_isset(bm, dns_rdatatype_ns) &&
|
|
|
|
! dns_nsec_isset(bm, dns_rdatatype_soa)) {
|
2003-12-13 04:20:44 +00:00
|
|
|
for (i = 0; i <= max_type; i++) {
|
2012-06-25 13:57:32 +10:00
|
|
|
if (dns_nsec_isset(bm, i) &&
|
1999-10-08 23:38:22 +00:00
|
|
|
! dns_rdatatype_iszonecutauth((dns_rdatatype_t)i))
|
2012-06-25 13:57:32 +10:00
|
|
|
dns_nsec_setbit(bm, i, 0);
|
1999-09-09 08:21:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_rdatasetiter_destroy(&rdsiter);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
1999-09-09 08:21:45 +00:00
|
|
|
return (result);
|
|
|
|
|
2012-06-25 13:57:32 +10:00
|
|
|
nsec_bits += dns_nsec_compressbitmap(nsec_bits, bm, max_type);
|
|
|
|
|
2013-12-04 12:47:23 +11:00
|
|
|
r.length = (unsigned int)(nsec_bits - r.base);
|
2003-09-30 06:00:40 +00:00
|
|
|
INSIST(r.length <= DNS_NSEC_BUFFERSIZE);
|
2000-08-01 01:33:37 +00:00
|
|
|
dns_rdata_fromregion(rdata,
|
1999-09-09 08:21:45 +00:00
|
|
|
dns_db_class(db),
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdatatype_nsec,
|
1999-09-09 08:21:45 +00:00
|
|
|
&r);
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-09-09 08:21:45 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_nsec_build(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
|
2016-12-30 15:45:08 +11:00
|
|
|
const dns_name_t *target, dns_ttl_t ttl)
|
1999-09-09 08:21:45 +00:00
|
|
|
{
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2003-09-30 06:00:40 +00:00
|
|
|
unsigned char data[DNS_NSEC_BUFFERSIZE];
|
1999-09-09 08:21:45 +00:00
|
|
|
dns_rdatalist_t rdatalist;
|
|
|
|
dns_rdataset_t rdataset;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-09-09 08:21:45 +00:00
|
|
|
dns_rdataset_init(&rdataset);
|
2000-10-20 02:21:58 +00:00
|
|
|
dns_rdata_init(&rdata);
|
1999-09-09 08:21:45 +00:00
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
RETERR(dns_nsec_buildrdata(db, version, node, target, data, &rdata));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2015-03-03 16:43:42 +11:00
|
|
|
dns_rdatalist_init(&rdatalist);
|
2000-09-12 09:55:32 +00:00
|
|
|
rdatalist.rdclass = dns_db_class(db);
|
2003-09-30 06:00:40 +00:00
|
|
|
rdatalist.type = dns_rdatatype_nsec;
|
2000-02-08 19:02:24 +00:00
|
|
|
rdatalist.ttl = ttl;
|
1999-09-09 08:21:45 +00:00
|
|
|
ISC_LIST_APPEND(rdatalist.rdata, &rdata, link);
|
2000-10-28 01:25:14 +00:00
|
|
|
RETERR(dns_rdatalist_tordataset(&rdatalist, &rdataset));
|
1999-09-09 08:21:45 +00:00
|
|
|
result = dns_db_addrdataset(db, node, version, 0, &rdataset,
|
2000-01-25 19:30:51 +00:00
|
|
|
0, NULL);
|
1999-09-09 08:21:45 +00:00
|
|
|
if (result == DNS_R_UNCHANGED)
|
|
|
|
result = ISC_R_SUCCESS;
|
2011-03-11 06:11:27 +00:00
|
|
|
|
1999-09-09 08:21:45 +00:00
|
|
|
failure:
|
|
|
|
if (dns_rdataset_isassociated(&rdataset))
|
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
return (result);
|
|
|
|
}
|
2000-04-13 18:08:07 +00:00
|
|
|
|
|
|
|
isc_boolean_t
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_nsec_typepresent(dns_rdata_t *nsec, dns_rdatatype_t type) {
|
|
|
|
dns_rdata_nsec_t nsecstruct;
|
2000-10-07 00:09:28 +00:00
|
|
|
isc_result_t result;
|
|
|
|
isc_boolean_t present;
|
2003-12-13 04:20:44 +00:00
|
|
|
unsigned int i, len, window;
|
2000-04-13 18:08:07 +00:00
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
REQUIRE(nsec != NULL);
|
|
|
|
REQUIRE(nsec->type == dns_rdatatype_nsec);
|
2000-04-13 18:08:07 +00:00
|
|
|
|
2000-10-07 00:09:28 +00:00
|
|
|
/* This should never fail */
|
2003-09-30 06:00:40 +00:00
|
|
|
result = dns_rdata_tostruct(nsec, &nsecstruct, NULL);
|
2000-10-07 00:09:28 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2003-12-13 04:20:44 +00:00
|
|
|
present = ISC_FALSE;
|
|
|
|
for (i = 0; i < nsecstruct.len; i += len) {
|
|
|
|
INSIST(i + 2 <= nsecstruct.len);
|
|
|
|
window = nsecstruct.typebits[i];
|
|
|
|
len = nsecstruct.typebits[i + 1];
|
|
|
|
INSIST(len > 0 && len <= 32);
|
|
|
|
i += 2;
|
|
|
|
INSIST(i + len <= nsecstruct.len);
|
|
|
|
if (window * 256 > type)
|
|
|
|
break;
|
|
|
|
if ((window + 1) * 256 <= type)
|
|
|
|
continue;
|
|
|
|
if (type < (window * 256) + len * 8)
|
2012-06-25 13:57:32 +10:00
|
|
|
present = ISC_TF(dns_nsec_isset(&nsecstruct.typebits[i],
|
2012-06-25 23:46:00 +00:00
|
|
|
type % 256));
|
2003-12-13 04:20:44 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-01-06 09:06:02 +00:00
|
|
|
dns_rdata_freestruct(&nsecstruct);
|
2000-10-07 00:09:28 +00:00
|
|
|
return (present);
|
2000-04-13 18:08:07 +00:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version,
|
|
|
|
isc_boolean_t *answer)
|
|
|
|
{
|
|
|
|
dns_dbnode_t *node = NULL;
|
|
|
|
dns_rdataset_t rdataset;
|
|
|
|
dns_rdata_dnskey_t dnskey;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
REQUIRE(answer != NULL);
|
|
|
|
|
|
|
|
dns_rdataset_init(&rdataset);
|
|
|
|
|
|
|
|
result = dns_db_getoriginnode(db, &node);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2008-09-25 04:02:39 +00:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey,
|
|
|
|
0, 0, &rdataset, NULL);
|
|
|
|
dns_db_detachnode(db, &node);
|
|
|
|
|
2011-06-10 01:51:09 +00:00
|
|
|
if (result == ISC_R_NOTFOUND)
|
2008-09-24 02:46:23 +00:00
|
|
|
*answer = ISC_FALSE;
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
for (result = dns_rdataset_first(&rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(&rdataset)) {
|
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
|
|
|
|
|
|
|
dns_rdataset_current(&rdataset, &rdata);
|
|
|
|
result = dns_rdata_tostruct(&rdata, &dnskey, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
if (dnskey.algorithm == DST_ALG_RSAMD5 ||
|
|
|
|
dnskey.algorithm == DST_ALG_RSASHA1 ||
|
|
|
|
dnskey.algorithm == DST_ALG_DSA ||
|
|
|
|
dnskey.algorithm == DST_ALG_ECC)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
*answer = ISC_TRUE;
|
|
|
|
if (result == ISC_R_NOMORE) {
|
|
|
|
*answer = ISC_FALSE;
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
2012-12-19 09:55:02 +11:00
|
|
|
|
|
|
|
/*%
|
|
|
|
* Return ISC_R_SUCCESS if we can determine that the name doesn't exist
|
|
|
|
* or we can determine whether there is data or not at the name.
|
|
|
|
* If the name does not exist return the wildcard name.
|
|
|
|
*
|
|
|
|
* Return ISC_R_IGNORE when the NSEC is not the appropriate one.
|
|
|
|
*/
|
|
|
|
isc_result_t
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name,
|
|
|
|
const dns_name_t *nsecname, dns_rdataset_t *nsecset,
|
2012-12-19 09:55:02 +11:00
|
|
|
isc_boolean_t *exists, isc_boolean_t *data,
|
|
|
|
dns_name_t *wild, dns_nseclog_t logit, void *arg)
|
|
|
|
{
|
|
|
|
int order;
|
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
|
|
|
isc_result_t result;
|
|
|
|
dns_namereln_t relation;
|
|
|
|
unsigned int olabels, nlabels, labels;
|
|
|
|
dns_rdata_nsec_t nsec;
|
|
|
|
isc_boolean_t atparent;
|
|
|
|
isc_boolean_t ns;
|
|
|
|
isc_boolean_t soa;
|
|
|
|
|
|
|
|
REQUIRE(exists != NULL);
|
|
|
|
REQUIRE(data != NULL);
|
|
|
|
REQUIRE(nsecset != NULL &&
|
|
|
|
nsecset->type == dns_rdatatype_nsec);
|
|
|
|
|
|
|
|
result = dns_rdataset_first(nsecset);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3), "failure processing NSEC set");
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
dns_rdataset_current(nsecset, &rdata);
|
|
|
|
|
2013-01-10 23:09:08 +11:00
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3), "looking for relevant NSEC");
|
2012-12-19 09:55:02 +11:00
|
|
|
relation = dns_name_fullcompare(name, nsecname, &order, &olabels);
|
|
|
|
|
|
|
|
if (order < 0) {
|
|
|
|
/*
|
|
|
|
* The name is not within the NSEC range.
|
|
|
|
*/
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"NSEC does not cover name, before NSEC");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (order == 0) {
|
|
|
|
/*
|
|
|
|
* The names are the same. If we are validating "."
|
|
|
|
* then atparent should not be set as there is no parent.
|
|
|
|
*/
|
|
|
|
atparent = (olabels != 1) && dns_rdatatype_atparent(type);
|
|
|
|
ns = dns_nsec_typepresent(&rdata, dns_rdatatype_ns);
|
|
|
|
soa = dns_nsec_typepresent(&rdata, dns_rdatatype_soa);
|
|
|
|
if (ns && !soa) {
|
|
|
|
if (!atparent) {
|
|
|
|
/*
|
|
|
|
* This NSEC record is from somewhere higher in
|
|
|
|
* the DNS, and at the parent of a delegation.
|
|
|
|
* It can not be legitimately used here.
|
|
|
|
*/
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"ignoring parent nsec");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
} else if (atparent && ns && soa) {
|
|
|
|
/*
|
|
|
|
* This NSEC record is from the child.
|
|
|
|
* It can not be legitimately used here.
|
|
|
|
*/
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"ignoring child nsec");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
if (type == dns_rdatatype_cname || type == dns_rdatatype_nxt ||
|
|
|
|
type == dns_rdatatype_nsec || type == dns_rdatatype_key ||
|
|
|
|
!dns_nsec_typepresent(&rdata, dns_rdatatype_cname)) {
|
|
|
|
*exists = ISC_TRUE;
|
|
|
|
*data = dns_nsec_typepresent(&rdata, type);
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"nsec proves name exists (owner) data=%d",
|
|
|
|
*data);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3), "NSEC proves CNAME exists");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (relation == dns_namereln_subdomain &&
|
2018-07-05 12:58:49 +02:00
|
|
|
(dns_nsec_typepresent(&rdata, dns_rdatatype_dname) ||
|
|
|
|
dns_nsec_typepresent(&rdata, dns_rdatatype_ns)) &&
|
2012-12-19 09:55:02 +11:00
|
|
|
!dns_nsec_typepresent(&rdata, dns_rdatatype_soa))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This NSEC record is from somewhere higher in
|
2018-07-05 12:58:49 +02:00
|
|
|
* the DNS, and at the parent of a delegation or
|
|
|
|
* at a DNAME.
|
2012-12-19 09:55:02 +11:00
|
|
|
* It can not be legitimately used here.
|
|
|
|
*/
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3), "ignoring parent nsec");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_rdata_tostruct(&rdata, &nsec, NULL);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
relation = dns_name_fullcompare(&nsec.next, name, &order, &nlabels);
|
|
|
|
if (order == 0) {
|
|
|
|
dns_rdata_freestruct(&nsec);
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"ignoring nsec matches next name");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (order < 0 && !dns_name_issubdomain(nsecname, &nsec.next)) {
|
|
|
|
/*
|
|
|
|
* The name is not within the NSEC range.
|
|
|
|
*/
|
|
|
|
dns_rdata_freestruct(&nsec);
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"ignoring nsec because name is past end of range");
|
|
|
|
return (ISC_R_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (order > 0 && relation == dns_namereln_subdomain) {
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"nsec proves name exist (empty)");
|
|
|
|
dns_rdata_freestruct(&nsec);
|
|
|
|
*exists = ISC_TRUE;
|
|
|
|
*data = ISC_FALSE;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
if (wild != NULL) {
|
|
|
|
dns_name_t common;
|
|
|
|
dns_name_init(&common, NULL);
|
|
|
|
if (olabels > nlabels) {
|
|
|
|
labels = dns_name_countlabels(nsecname);
|
|
|
|
dns_name_getlabelsequence(nsecname, labels - olabels,
|
|
|
|
olabels, &common);
|
|
|
|
} else {
|
|
|
|
labels = dns_name_countlabels(&nsec.next);
|
|
|
|
dns_name_getlabelsequence(&nsec.next, labels - nlabels,
|
|
|
|
nlabels, &common);
|
|
|
|
}
|
|
|
|
result = dns_name_concatenate(dns_wildcardname, &common,
|
2014-09-05 12:10:55 +10:00
|
|
|
wild, NULL);
|
2012-12-19 09:55:02 +11:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
dns_rdata_freestruct(&nsec);
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3),
|
|
|
|
"failure generating wildcard name");
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dns_rdata_freestruct(&nsec);
|
|
|
|
(*logit)(arg, ISC_LOG_DEBUG(3), "nsec range ok");
|
|
|
|
*exists = ISC_FALSE;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|