Commit 9e53cbca authored by Mark Andrews's avatar Mark Andrews
Browse files

Add UDP refresh queries.

Generate NOTIFY messages.
parent 9069fc60
63 [func] generate NOTIFY messages.
62. [func] add UDP refresh support.
61. [cleanup] use single quotes consistently in log messages.
60. [func] Catch and disallow singleton types on message
......
......@@ -169,13 +169,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
if (result == ISC_R_SUCCESS)
dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, boolean);
else
dns_zone_clearoption(zone, DNS_ZONE_O_DIALUP);
dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, ISC_FALSE);
result = dns_c_zone_getnotify(czone, &boolean);
if (result == ISC_R_SUCCESS)
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
else
dns_zone_clearoption(zone, DNS_ZONE_O_NOTIFY);
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, ISC_TRUE);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
......
......@@ -80,6 +80,7 @@ struct dns_view {
dns_zt_t * zonetable;
dns_resolver_t * resolver;
dns_adb_t * adb;
dns_requestmgr_t * requestmgr;
dns_cache_t * cache;
dns_db_t * cachedb;
dns_db_t * hints;
......@@ -91,6 +92,7 @@ struct dns_view {
isc_task_t * task;
isc_event_t resevent;
isc_event_t adbevent;
isc_event_t reqevent;
/* Configurable data, locked by conflock. */
dns_tsig_keyring_t * statickeys;
dns_tsig_keyring_t * dynamickeys;
......@@ -121,6 +123,7 @@ struct dns_view {
#define DNS_VIEWATTR_RESSHUTDOWN 0x01
#define DNS_VIEWATTR_ADBSHUTDOWN 0x02
#define DNS_VIEWATTR_REQSHUTDOWN 0x04
isc_result_t
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
......
......@@ -27,6 +27,7 @@
#include <isc/sockaddr.h>
#include <isc/types.h>
#include <dns/adb.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/name.h>
......@@ -436,16 +437,12 @@ void dns_zone_clearoption(dns_zone_t *zone, unsigned int option);
* 'zone' to be a valid initalised zone.
*/
void dns_zone_getoptions(dns_zone_t *zone, unsigned int *options,
unsigned int *optionsmask);
unsigned int dns_zone_getoptions(dns_zone_t *zone);
/*
* Return which options a set ('options') and which are active
* ('optionsmask').
* Return which options a set.
*
* Require:
* 'zone' to be a valid initalised zone.
* 'options' to be non NULL.
* 'optionsmask' to be non NULL.
*/
void dns_zone_setrefresh(dns_zone_t *zone, isc_uint32_t refresh,
......@@ -614,6 +611,9 @@ void dns_zone_setmasterport(dns_zone_t *zone, isc_uint16_t port);
isc_uint16_t dns_zone_getmasterport(dns_zone_t *zone);
void dns_zone_setresolver(dns_zone_t *zone, dns_resolver_t *resolver);
void dns_zone_setrequestmgr(dns_zone_t *zone, dns_requestmgr_t *requestmgr);
void dns_zone_setadb(dns_zone_t *zone, dns_adb_t *adb);
isc_result_t dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
dns_message_t *msg);
......
......@@ -39,6 +39,7 @@
#include <dns/rbt.h>
#include <dns/rdataset.h>
#include <dns/resolver.h>
#include <dns/request.h>
#include <dns/tsig.h>
#include <dns/view.h>
#include <dns/zone.h>
......@@ -46,9 +47,11 @@
#define RESSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_RESSHUTDOWN) != 0)
#define ADBSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_ADBSHUTDOWN) != 0)
#define REQSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_REQSHUTDOWN) != 0)
static void resolver_shutdown(isc_task_t *task, isc_event_t *event);
static void adb_shutdown(isc_task_t *task, isc_event_t *event);
static void req_shutdown(isc_task_t *task, isc_event_t *event);
isc_result_t
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
......@@ -121,12 +124,14 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
view->hints = NULL;
view->resolver = NULL;
view->adb = NULL;
view->requestmgr = NULL;
view->mctx = mctx;
view->rdclass = rdclass;
view->frozen = ISC_FALSE;
view->task = NULL;
view->references = 1;
view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN);
view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
DNS_VIEWATTR_REQSHUTDOWN);
view->statickeys = NULL;
view->dynamickeys = NULL;
view->matchclients = NULL;
......@@ -154,6 +159,9 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
ISC_EVENT_INIT(&view->adbevent, sizeof view->adbevent, 0, NULL,
DNS_EVENT_VIEWADBSHUTDOWN, adb_shutdown,
view, NULL, NULL, NULL);
ISC_EVENT_INIT(&view->reqevent, sizeof view->reqevent, 0, NULL,
DNS_EVENT_VIEWREQSHUTDOWN, req_shutdown,
view, NULL, NULL, NULL);
view->magic = DNS_VIEW_MAGIC;
*viewp = view;
......@@ -214,6 +222,7 @@ destroy(dns_view_t *view) {
REQUIRE(view->references == 0);
REQUIRE(RESSHUTDOWN(view));
REQUIRE(ADBSHUTDOWN(view));
REQUIRE(REQSHUTDOWN(view));
if (view->peers != NULL)
dns_peerlist_detach(&view->peers);
......@@ -225,6 +234,8 @@ destroy(dns_view_t *view) {
dns_adb_detach(&view->adb);
if (view->resolver != NULL)
dns_resolver_detach(&view->resolver);
if (view->requestmgr != NULL)
dns_requestmgr_detach(&view->requestmgr);
if (view->task != NULL)
isc_task_detach(&view->task);
if (view->hints != NULL)
......@@ -253,7 +264,8 @@ all_done(dns_view_t *view) {
* Caller must be holding the view lock.
*/
if (view->references == 0 && RESSHUTDOWN(view) && ADBSHUTDOWN(view))
if (view->references == 0 && RESSHUTDOWN(view) &&
ADBSHUTDOWN(view) && REQSHUTDOWN(view))
return (ISC_TRUE);
return (ISC_FALSE);
......@@ -281,6 +293,8 @@ dns_view_detach(dns_view_t **viewp) {
dns_resolver_shutdown(view->resolver);
if (!ADBSHUTDOWN(view))
dns_adb_shutdown(view->adb);
if (!REQSHUTDOWN(view))
dns_requestmgr_shutdown(view->requestmgr);
done = all_done(view);
}
UNLOCK(&view->lock);
......@@ -335,6 +349,28 @@ adb_shutdown(isc_task_t *task, isc_event_t *event) {
destroy(view);
}
static void
req_shutdown(isc_task_t *task, isc_event_t *event) {
dns_view_t *view = event->ev_arg;
isc_boolean_t done;
REQUIRE(event->ev_type == DNS_EVENT_VIEWREQSHUTDOWN);
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->task == task);
LOCK(&view->lock);
view->attributes |= DNS_VIEWATTR_REQSHUTDOWN;
done = all_done(view);
UNLOCK(&view->lock);
isc_event_free(&event);
if (done)
destroy(view);
}
isc_result_t
dns_view_createresolver(dns_view_t *view,
isc_taskmgr_t *taskmgr, unsigned int ntasks,
......@@ -381,6 +417,19 @@ dns_view_createresolver(dns_view_t *view,
dns_adb_whenshutdown(view->adb, view->task, &event);
view->attributes &= ~DNS_VIEWATTR_ADBSHUTDOWN;
result = dns_requestmgr_create(view->mctx, timermgr, socketmgr,
dns_resolver_dispatchv4(view->resolver),
dns_resolver_dispatchv6(view->resolver),
&view->requestmgr);
if (result != ISC_R_SUCCESS) {
dns_adb_shutdown(view->adb);
dns_resolver_shutdown(view->resolver);
return (result);
}
event = &view->reqevent;
dns_requestmgr_whenshutdown(view->requestmgr, view->task, &event);
view->attributes &= ~DNS_VIEWATTR_REQSHUTDOWN;
return (ISC_R_SUCCESS);
}
......@@ -447,6 +496,24 @@ dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
return (result);
}
static isc_result_t
set_resolver(dns_zone_t *zone, void *ptr) {
dns_zone_setresolver(zone, ptr);
return (ISC_R_SUCCESS);
}
static isc_result_t
set_requestmgr(dns_zone_t *zone, void *ptr) {
dns_zone_setrequestmgr(zone, ptr);
return (ISC_R_SUCCESS);
}
static isc_result_t
set_adb(dns_zone_t *zone, void *ptr) {
dns_zone_setadb(zone, ptr);
return (ISC_R_SUCCESS);
}
void
dns_view_freeze(dns_view_t *view) {
......@@ -460,6 +527,16 @@ dns_view_freeze(dns_view_t *view) {
if (view->resolver != NULL) {
INSIST(view->cachedb != NULL);
dns_resolver_freeze(view->resolver);
(void)dns_zt_apply(view->zonetable, ISC_FALSE,
set_resolver, view->resolver);
}
if (view->requestmgr != NULL) {
(void)dns_zt_apply(view->zonetable, ISC_FALSE,
set_requestmgr, view->requestmgr);
}
if (view->adb != NULL) {
(void)dns_zt_apply(view->zonetable, ISC_FALSE,
set_adb, view->adb);
}
view->frozen = ISC_TRUE;
}
......
This diff is collapsed.
......@@ -169,13 +169,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
if (result == ISC_R_SUCCESS)
dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, boolean);
else
dns_zone_clearoption(zone, DNS_ZONE_O_DIALUP);
dns_zone_setoption(zone, DNS_ZONE_O_DIALUP, ISC_FALSE);
result = dns_c_zone_getnotify(czone, &boolean);
if (result == ISC_R_SUCCESS)
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
else
dns_zone_clearoption(zone, DNS_ZONE_O_NOTIFY);
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, ISC_TRUE);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
......
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