2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

1132. [func] Improve UPDATE prerequisite failure diagnotic messages.

This commit is contained in:
Mark Andrews
2001-11-20 05:04:41 +00:00
parent 945f7311ca
commit 4072dfb9b8
2 changed files with 68 additions and 26 deletions

View File

@@ -1,3 +1,5 @@
1132. [func] Improve UPDATE prerequisite failure diagnotic messages.
1131. [bug] The match-destinations view option did not work with 1131. [bug] The match-destinations view option did not work with
IPv6 destinations. [RT #2073, #2074] IPv6 destinations. [RT #2073, #2074]

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: update.c,v 1.89 2001/09/19 23:08:23 gson Exp $ */ /* $Id: update.c,v 1.90 2001/11/20 05:04:41 marka Exp $ */
#include <config.h> #include <config.h>
@@ -36,6 +36,7 @@
#include <dns/rdataclass.h> #include <dns/rdataclass.h>
#include <dns/rdataset.h> #include <dns/rdataset.h>
#include <dns/rdatasetiter.h> #include <dns/rdatasetiter.h>
#include <dns/rdatatype.h>
#include <dns/soa.h> #include <dns/soa.h>
#include <dns/ssu.h> #include <dns/ssu.h>
#include <dns/view.h> #include <dns/view.h>
@@ -106,6 +107,34 @@
if (result != ISC_R_SUCCESS) goto failure; \ if (result != ISC_R_SUCCESS) goto failure; \
} while (0) } while (0)
#define FAILN(code, name, msg) \
do { \
result = (code); \
if (isc_log_wouldlog(ns_g_lctx, LOGLEVEL_PROTOCOL)) { \
char _nbuf[DNS_NAME_FORMATSIZE]; \
dns_name_format(name, _nbuf, sizeof(_nbuf)); \
update_log(client, zone, LOGLEVEL_PROTOCOL, \
"update failed: %s: %s (%s)", _nbuf, \
msg, isc_result_totext(result)); \
} \
if (result != ISC_R_SUCCESS) goto failure; \
} while (0)
#define FAILNT(code, name, type, msg) \
do { \
result = (code); \
if (isc_log_wouldlog(ns_g_lctx, LOGLEVEL_PROTOCOL)) { \
char _nbuf[DNS_NAME_FORMATSIZE]; \
char _tbuf[DNS_RDATATYPE_FORMATSIZE]; \
dns_name_format(name, _nbuf, sizeof(_nbuf)); \
dns_rdatatype_format(type, _tbuf, sizeof(_tbuf)); \
update_log(client, zone, LOGLEVEL_PROTOCOL, \
"update failed: %s/%s: %s (%s)", \
_nbuf, _tbuf, msg, \
isc_result_totext(result)); \
} \
if (result != ISC_R_SUCCESS) goto failure; \
} while (0)
/* /*
* Fail unconditionally and log as a server error. * Fail unconditionally and log as a server error.
* The test against ISC_R_SUCCESS is there to keep the Solaris compiler * The test against ISC_R_SUCCESS is there to keep the Solaris compiler
@@ -721,11 +750,13 @@ temp_order(const void *av, const void *bv) {
* *
* Return ISC_R_SUCCESS if the prerequisites are satisfied, * Return ISC_R_SUCCESS if the prerequisites are satisfied,
* rcode(dns_rcode_nxrrset) if not. * rcode(dns_rcode_nxrrset) if not.
*
* 'temp' must be pre-sorted.
*/ */
static isc_result_t static isc_result_t
temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db, temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db,
dns_dbversion_t *ver) dns_dbversion_t *ver, dns_name_t *tmpname, dns_rdatatype_t *typep)
{ {
isc_result_t result; isc_result_t result;
dns_name_t *name; dns_name_t *name;
@@ -733,18 +764,6 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db,
dns_difftuple_t *t; dns_difftuple_t *t;
dns_diff_t trash; dns_diff_t trash;
/* Exit early if the list is empty (for efficiency only). */
if (ISC_LIST_HEAD(temp->tuples) == NULL)
return (ISC_R_SUCCESS);
/*
* Sort the prerequisite records by owner name,
* type, and rdata.
*/
result = dns_diff_sort(temp, temp_order);
if (result != ISC_R_SUCCESS)
return (result);
dns_diff_init(mctx, &trash); dns_diff_init(mctx, &trash);
/* /*
@@ -755,6 +774,8 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db,
t = ISC_LIST_HEAD(temp->tuples); t = ISC_LIST_HEAD(temp->tuples);
while (t != NULL) { while (t != NULL) {
name = &t->name; name = &t->name;
(void)dns_name_copy(name, tmpname, NULL);
*typep = t->rdata.type;
/* A new unique name begins here. */ /* A new unique name begins here. */
node = NULL; node = NULL;
@@ -773,7 +794,7 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db,
dns_diff_t u_rrs; /* Update RRs with dns_diff_t u_rrs; /* Update RRs with
this name and type */ this name and type */
type = t->rdata.type; *typep = type = t->rdata.type;
if (type == dns_rdatatype_sig) if (type == dns_rdatatype_sig)
covers = dns_rdata_covers(&t->rdata); covers = dns_rdata_covers(&t->rdata);
else else
@@ -2006,6 +2027,8 @@ update_action(isc_task_t *task, isc_event_t *event) {
dns_rdataclass_t zoneclass; dns_rdataclass_t zoneclass;
dns_name_t *zonename; dns_name_t *zonename;
dns_ssutable_t *ssutable = NULL; dns_ssutable_t *ssutable = NULL;
dns_fixedname_t tmpnamefixed;
dns_name_t *tmpname = NULL;
INSIST(event->ev_type == DNS_EVENT_UPDATE); INSIST(event->ev_type == DNS_EVENT_UPDATE);
@@ -2040,7 +2063,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
FAILC(DNS_R_FORMERR, "prerequisite TTL is not zero"); FAILC(DNS_R_FORMERR, "prerequisite TTL is not zero");
if (! dns_name_issubdomain(name, zonename)) if (! dns_name_issubdomain(name, zonename))
FAILC(DNS_R_NOTZONE, FAILN(DNS_R_NOTZONE, name,
"prerequisite name is out of zone"); "prerequisite name is out of zone");
if (update_class == dns_rdataclass_any) { if (update_class == dns_rdataclass_any) {
@@ -2051,7 +2074,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
if (rdata.type == dns_rdatatype_any) { if (rdata.type == dns_rdatatype_any) {
CHECK(name_exists(db, ver, name, &flag)); CHECK(name_exists(db, ver, name, &flag));
if (! flag) { if (! flag) {
FAILC(DNS_R_NXDOMAIN, FAILN(DNS_R_NXDOMAIN, name,
"'name in use' prerequisite " "'name in use' prerequisite "
"not satisfied"); "not satisfied");
} }
@@ -2060,7 +2083,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
rdata.type, covers, &flag)); rdata.type, covers, &flag));
if (! flag) { if (! flag) {
/* RRset does not exist. */ /* RRset does not exist. */
FAILC(DNS_R_NXRRSET, FAILNT(DNS_R_NXRRSET, name, rdata.type,
"'rrset exists (value independent)' " "'rrset exists (value independent)' "
"prerequisite not satisfied"); "prerequisite not satisfied");
} }
@@ -2073,7 +2096,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
if (rdata.type == dns_rdatatype_any) { if (rdata.type == dns_rdatatype_any) {
CHECK(name_exists(db, ver, name, &flag)); CHECK(name_exists(db, ver, name, &flag));
if (flag) { if (flag) {
FAILC(DNS_R_YXDOMAIN, FAILN(DNS_R_YXDOMAIN, name,
"'name not in use' prerequisite " "'name not in use' prerequisite "
"not satisfied"); "not satisfied");
} }
@@ -2082,9 +2105,9 @@ update_action(isc_task_t *task, isc_event_t *event) {
rdata.type, covers, &flag)); rdata.type, covers, &flag));
if (flag) { if (flag) {
/* RRset exists. */ /* RRset exists. */
FAILC(DNS_R_YXRRSET, FAILNT(DNS_R_YXRRSET, name, rdata.type,
"'rrset does not exist' " "'rrset does not exist' "
"prerequisite not satisfied"); "prerequisite not satisfied");
} }
} }
} else if (update_class == zoneclass) { } else if (update_class == zoneclass) {
@@ -2103,14 +2126,31 @@ update_action(isc_task_t *task, isc_event_t *event) {
if (result != ISC_R_NOMORE) if (result != ISC_R_NOMORE)
FAIL(result); FAIL(result);
/* /*
* Perform the final check of the "rrset exists (value dependent)" * Perform the final check of the "rrset exists (value dependent)"
* prerequisites. * prerequisites.
*/ */
result = temp_check(mctx, &temp, db, ver); if (ISC_LIST_HEAD(temp.tuples) != NULL) {
if (result != ISC_R_SUCCESS) dns_rdatatype_t type;
FAILC(result, "'RRset exists (value dependent)' "
"prerequisite not satisfied"); /*
* Sort the prerequisite records by owner name,
* type, and rdata.
*/
result = dns_diff_sort(&temp, temp_order);
if (result != ISC_R_SUCCESS)
FAILC(result, "'RRset exists (value dependent)' "
"prerequisite not satisfied");
dns_fixedname_init(&tmpnamefixed);
tmpname = dns_fixedname_name(&tmpnamefixed);
result = temp_check(mctx, &temp, db, ver, tmpname, &type);
if (result != ISC_R_SUCCESS)
FAILNT(result, tmpname, type,
"'RRset exists (value dependent)' "
"prerequisite not satisfied");
}
update_log(client, zone, LOGLEVEL_DEBUG, update_log(client, zone, LOGLEVEL_DEBUG,
"prerequisites are OK"); "prerequisites are OK");