On 9.5.2016 16:25, Petr Spacek wrote:
> Hello,
>
> following patch should cover most misleading warnings produced by new code
> handling empty zones.
>
> If it is okay I will release version 9.0 with it.
>
> Please review it ASAP. Thank you very much!
... and here are patches :-)
--
Petr^2 Spacek
From 058810cfb88aca05dfdaee59760c715377b2d7d7 Mon Sep 17 00:00:00 2001
From: Petr Spacek
Date: Mon, 9 May 2016 15:35:37 +0200
Subject: [PATCH] Do not log warning about empty zones which are already
disabled or unloaded.
https://fedorahosted.org/bind-dyndb-ldap/ticket/160
---
src/empty_zones.c | 39 ---
src/empty_zones.h | 9 -
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/empty_zones.c b/src/empty_zones.c
index 3d5f0329599d170c4d79bc821737fd1f282b6664..fe3a4b93a655f65c4de727fd2936b7cb4a6aa72f 100644
--- a/src/empty_zones.c
+++ b/src/empty_zones.c
@@ -6,6 +6,7 @@
#include
#include
+#include
#include "empty_zones.h"
#include "util.h"
@@ -151,6 +152,8 @@ empty_zone_search_next(empty_zone_search_t *iter) {
isc_buffer_t buffer;
int order;
unsigned int nlabels;
+ dns_zone_t *zone = NULL;
+ isc_boolean_t isempty;
REQUIRE(iter != NULL);
REQUIRE(iter->nextidx < sizeof(empty_zones));
@@ -174,6 +177,20 @@ empty_zone_search_next(empty_zone_search_t *iter) {
/* empty zone and domain in question are not related */
continue;
} else {
+ /* verify if the zone exists and is empty */
+ result = dns_zt_find(iter->zonetable, &iter->ezname,
+ 0, NULL, &zone);
+ if (result == ISC_R_SUCCESS)
+isempty = zone_isempty(zone);
+ else if (result == DNS_R_PARTIALMATCH
+ || result == ISC_R_NOTFOUND)
+isempty = ISC_FALSE;
+ else
+goto cleanup;
+ if (zone != NULL)
+dns_zone_detach(&zone);
+ if (isempty == ISC_FALSE)
+continue;
++iter->nextidx;
CLEANUP_WITH(ISC_R_SUCCESS);
}
@@ -185,19 +202,32 @@ cleanup:
return result;
};
+/**
+ * Invalidate iterator and detach its internal pointers.
+ */
+void
+empty_zone_search_stop(empty_zone_search_t *iter) {
+ REQUIRE(iter != NULL);
+
+ if (iter->zonetable)
+ dns_zt_detach(&iter->zonetable);
+}
/**
* Start search for qname among automatic empty zones.
+ * The search must be finished by calling empty_zone_search_stop().
*
* @param[in] qname Name to compare with list of automatic empty zones.
+ * @param[in] ztable Zone table for affected view.
* @param[out] iter Intermediate state which must be passed to subsequent
* empty_zone_search_next() call. At the same time,
* the structure contains name of first matching
* automatic empty zone and relation between names.
* @returns @see empty_zone_search_next
*/
isc_result_t
-empty_zone_search_init(empty_zone_search_t *iter, dns_name_t *qname) {
+empty_zone_search_init(empty_zone_search_t *iter, dns_name_t *qname,
+ dns_zt_t *ztable) {
isc_result_t result;
REQUIRE(iter != NULL);
@@ -210,7 +240,9 @@ empty_zone_search_init(empty_zone_search_t *iter, dns_name_t *qname) {
iter->nextidx = 0;
iter->namerel = dns_namereln_none;
- CHECK(empty_zone_search_next(iter));
+ dns_zt_attach(ztable, &iter->zonetable);
+
+ return empty_zone_search_next(iter);
cleanup:
return result;
@@ -275,7 +307,7 @@ empty_zone_handle_conflicts(dns_name_t *name, dns_zt_t *zonetable,
char name_char[DNS_NAME_FORMATSIZE];
char ezname_char[DNS_NAME_FORMATSIZE];
- for (result = empty_zone_search_init(&eziter, name);
+ for (result = empty_zone_search_init(&eziter, name, zonetable);
result == ISC_R_SUCCESS;
result = empty_zone_search_next(&eziter))
{
@@ -309,6 +341,7 @@ empty_zone_handle_conflicts(dns_name_t *name, dns_zt_t *zonetable,
result = ISC_R_SUCCESS;
cleanup:
+ empty_zone_search_stop(&eziter);
return result;
}
diff --git a/src/empty_zones.h b/src/empty_zones.h
index 513f95d87c97d5db975d8686d48c7efecf3a0c16..27129427c1c17b72c2c6e0268352a18480f4ec8e 100644
--- a/src/empty_zones.h
+++ b/src/empty_zones.h
@@ -1,21 +1,28 @@
#include
+#include
+
#include "util.h"
extern const char *empty_zones[];
typedef struct empty_zone_search {
DECLARE_BUFFERED_NAME(qname);
DECLARE_BUFFERED_NAME(ezname);
unsigned int nextidx;
dns_namereln_t namerel;
+ dns_zt_t *zonetable;
} empty_zone_search_t;
isc_result_t
empty_zone_search_next(empty_zone_search_t *iter) ATTR_NONNULLS ATTR_CHECKRESULT;
+void
+empty_zone_search_stop(empty_zone_search_t *iter) ATTR_NONNULLS;
+
isc_result_t
-empty_zone_search_init(empty_zone_search_t *iter, dns_name_t *qname) ATTR_NONNULLS ATTR_CHECKRESULT;
+empty_zone_search_init(empty_zone_search_t *iter, dns_name_t *qname,
+ dns_zt_t *ztable) ATTR_NONNULLS ATTR_CHECKRESULT;
isc_result_t
empty_zone_handle_conflicts(dns_name_t *name, dns_zt_t *zonetable,
--
2.5.5
From 87f01b88377427053d29375a142b8dbcb1a9a122 Mon Sep 17 00:00:00 2001
From: Petr Spacek
Date: Mon, 9 May 2