Commit 94b50bce authored by Michael Sawyer's avatar Michael Sawyer
Browse files

Add zone-specific reload and refresh capability to server and rndc

parent 3c0a8189
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.c,v 1.118 2000/10/11 17:44:04 mws Exp $ */
/* $Id: client.c,v 1.119 2000/10/12 21:51:42 mws Exp $ */
#include <config.h>
......@@ -30,6 +30,7 @@
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/message.h>
#include <dns/opt.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.h,v 1.44 2000/10/11 17:44:07 mws Exp $ */
/* $Id: client.h,v 1.45 2000/10/12 21:51:48 mws Exp $ */
#ifndef NAMED_CLIENT_H
#define NAMED_CLIENT_H 1
......@@ -69,10 +69,8 @@
#include <dns/name.h>
#include <dns/types.h>
#include <dns/tcpmsg.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/fixedname.h>
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <named/types.h>
#include <named/query.h>
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: omapi.h,v 1.11 2000/10/05 10:42:38 marka Exp $ */
/* $Id: omapi.h,v 1.12 2000/10/12 21:51:49 mws Exp $ */
#ifndef NAMED_OMAPI_H
#define NAMED_OMAPI_H 1
......@@ -38,6 +38,7 @@
#define NS_OMAPI_COMMAND_RELOAD "reload"
#define NS_OMAPI_COMMAND_RELOADCONFIG "reload-config"
#define NS_OMAPI_COMMAND_RELOADZONES "reload-zones"
#define NS_OMAPI_COMMAND_REFRESH "refresh"
isc_result_t
ns_omapi_init(void);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.h,v 1.39 2000/10/05 23:48:49 marka Exp $ */
/* $Id: server.h,v 1.40 2000/10/12 21:51:50 mws Exp $ */
#ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1
......@@ -100,4 +100,10 @@ ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
* Inform the server that the zones should be flushed to disk on shutdown.
*/
isc_result_t
ns_server_reloadzone(ns_server_t *server, char *args);
isc_result_t
ns_server_refreshzone(ns_server_t *server, char *args);
#endif /* NAMED_SERVER_H */
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: omapi.c,v 1.19 2000/10/11 21:21:46 marka Exp $ */
/* $Id: omapi.c,v 1.20 2000/10/12 21:51:43 mws Exp $ */
/*
* Principal Author: DCL
......@@ -78,16 +78,33 @@ control_setvalue(omapi_object_t *handle, omapi_string_t *name,
*/
if (omapi_string_strcmp(name, NS_OMAPI_COMMAND_RELOAD) == 0) {
result = ISC_R_SUCCESS;
args = omapi_data_strdup(ns_g_mctx, value);
if (args == NULL)
result = ISC_R_NOMEMORY;
else if (strcmp(args, NS_OMAPI_COMMAND_RELOAD) == 0)
if (value != NULL) {
args = omapi_data_strdup(ns_g_mctx, value);
if (args == NULL)
result = ISC_R_NOMEMORY;
else if (strcmp(args, NS_OMAPI_COMMAND_RELOAD) == 0)
ns_server_reloadwanted(ns_g_server);
/* XXX Can the previous case ever happen??? */
else
result = ns_server_reloadzone(ns_g_server,
args);
if (args != NULL)
isc_mem_free(ns_g_mctx, args);
} else {
ns_server_reloadwanted(ns_g_server);
else
ns_server_reloadzone(ns_g_server, args);
if (args != NULL)
isc_mem_free(ns_g_mctx, args);
}
} else if (omapi_string_strcmp(name, NS_OMAPI_COMMAND_REFRESH) == 0) {
result = ISC_R_SUCCESS;
if (value != NULL) {
args = omapi_data_strdup(ns_g_mctx, value);
if (args == NULL)
result = ISC_R_NOMEMORY;
else if (strcmp(args, NS_OMAPI_COMMAND_RELOAD) != 0)
result = ns_server_refreshzone(ns_g_server,
args);
if (args != NULL)
isc_mem_free(ns_g_mctx, args);
}
} else if (omapi_string_strcmp(name,NS_OMAPI_COMMAND_HALT) == 0) {
ns_server_flushonshutdown(ns_g_server, ISC_FALSE);
isc_app_shutdown();
......@@ -105,7 +122,6 @@ control_setvalue(omapi_object_t *handle, omapi_string_t *name,
"control_setvalue: '%.*s' not yet implemented",
REGION_FMT(&region));
result = ISC_R_NOTIMPLEMENTED;
} else {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_OMAPI, ISC_LOG_WARNING,
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: query.c,v 1.136 2000/10/11 18:00:08 mws Exp $ */
/* $Id: query.c,v 1.137 2000/10/12 21:51:45 mws Exp $ */
#include <config.h>
......@@ -25,6 +25,7 @@
#include <dns/db.h>
#include <dns/events.h>
#include <dns/message.h>
#include <dns/opt.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
......@@ -2102,7 +2103,6 @@ query_find(ns_client_t *client, dns_fetchevent_t *event) {
dns_namereln_t namereln;
int order;
isc_buffer_t *dbuf;
isc_region_t r;
isc_buffer_t b;
isc_result_t result, eresult;
dns_fixedname_t fixed;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.227 2000/10/11 21:21:47 marka Exp $ */
/* $Id: server.c,v 1.228 2000/10/12 21:51:46 mws Exp $ */
#include <config.h>
......@@ -50,6 +50,7 @@
#include <dns/view.h>
#include <dns/zone.h>
#include <dns/zoneconf.h>
#include <dns/zt.h>
#include <dst/dst.h>
......@@ -705,6 +706,7 @@ create_bind_view(dns_view_t **viewp)
}
/*
* Create the zone that handles queries for
* "version.bind. CH". The version string returned is that
......@@ -1877,11 +1879,98 @@ ns_server_reloadwanted(ns_server_t *server) {
UNLOCK(&server->reload_event_lock);
}
void
ns_server_reloadzone(ns_server_t *server, char *args) {
static char *
next_token(char **stringp, const char *delim) {
char *res;
do {
res = strsep(stringp, delim);
if (res == NULL)
break;
} while (*res == '\0');
return (res);
}
static isc_result_t
zone_from_args(char *args, dns_zone_t **zone) {
char *input, *ptr;
const char *zonetxt = NULL, *viewtxt = NULL;
dns_fixedname_t name;
isc_result_t result;
isc_buffer_t buf;
dns_view_t *view;
input = args;
ptr = next_token(&input, " \t");
while (ptr != NULL) {
switch (ptr[0]) {
case 'Z':
zonetxt = ptr+1;
break;
case 'V':
viewtxt = ptr+1;
break;
}
ptr = next_token(&input, " \t");
}
if (zonetxt == NULL)
return DNS_R_BADZONE; /* Nothing to do! */
isc_buffer_init(&buf, zonetxt, strlen(zonetxt));
isc_buffer_add(&buf, strlen(zonetxt));
dns_fixedname_init(&name);
result = dns_name_fromtext(&(name.name), &buf, dns_rootname,
ISC_FALSE, NULL);
if (result != ISC_R_SUCCESS)
goto fail1;
if (viewtxt == NULL)
viewtxt = "_default";
result = dns_viewlist_find(&ns_g_server->viewlist, viewtxt,
dns_rdataclass_in, &view);
if (result != ISC_R_SUCCESS)
goto fail1;
result = dns_zt_find(view->zonetable, &(name.name), 0, NULL,
zone);
if (result != ISC_R_SUCCESS)
goto fail2;
fail2:
dns_view_detach(&view);
fail1:
isc_buffer_invalidate(&buf);
return (result);
}
isc_result_t
ns_server_reloadzone(ns_server_t *server, char *args) {
isc_result_t result;
dns_zone_t *zone = NULL;
UNUSED(server);
result = zone_from_args(args, &zone);
if (result != ISC_R_SUCCESS)
return (result);
if (zone != NULL) {
dns_zone_forcereload(zone);
dns_zone_detach(&zone);
}
return (ISC_R_SUCCESS);
}
isc_result_t
ns_server_refreshzone(ns_server_t *server, char *args) {
isc_result_t result;
dns_zone_t *zone = NULL;
UNUSED(server);
result = zone_from_args(args, &zone);
if (result != ISC_R_SUCCESS)
return (result);
if (zone != NULL) {
dns_zone_refresh(zone);
dns_zone_detach(&zone);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
dns_aclconfctx_t *actx,
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rndc.c,v 1.26 2000/10/11 21:22:29 marka Exp $ */
/* $Id: rndc.c,v 1.27 2000/10/12 21:51:51 mws Exp $ */
/*
* Principal Author: DCL
......@@ -237,6 +237,7 @@ ndc_setvalue(omapi_object_t *handle, omapi_string_t *name,
isc_result_t result;
char *message;
*/
UNUSED(value);
INSIST(handle == (omapi_object_t *)&ndc_g_ndc);
......@@ -303,6 +304,8 @@ main(int argc, char **argv) {
unsigned int algorithm;
int ch;
int len;
char *zonename = NULL;
char *viewname = NULL;
progname = strrchr(*argv, '/');
if (progname != NULL)
......@@ -310,7 +313,8 @@ main(int argc, char **argv) {
else
progname = *argv;
while ((ch = isc_commandline_parse(argc, argv, "c:Mmp:s:vy:")) != -1) {
while ((ch = isc_commandline_parse(argc, argv, "c:Mmp:s:Vv:y:z:"))
!= -1) {
switch (ch) {
case 'c':
conffile = isc_commandline_argument;
......@@ -336,18 +340,18 @@ main(int argc, char **argv) {
case 's':
servername = isc_commandline_argument;
break;
case 'v':
/*
* Undocumented, for testing.
*/
case 'V':
verbose = ISC_TRUE;
break;
case 'v':
viewname = isc_commandline_argument;
break;
case 'y':
keyname = isc_commandline_argument;
break;
case 'z':
zonename = isc_commandline_argument;
break;
case '?':
usage();
exit(1);
......@@ -504,8 +508,51 @@ main(int argc, char **argv) {
result = ISC_R_NOTIMPLEMENTED;
} else if (strcmp(command, "reload") == 0) {
result = send_command(omapimgr, command, args);
char omapiargs[DNS_NAME_MAXTEXT];
omapiargs[0]=0;
if (zonename != NULL) {
strncat(omapiargs, "Z", 1);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
strncat(omapiargs, zonename,
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
if (zonename != NULL && viewname != NULL) {
strncat(omapiargs, " ",
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
if (viewname != NULL) {
strncat(omapiargs, "V", 1);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
strncat(omapiargs, viewname,
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
result = send_command(omapimgr, command, omapiargs);
} else if (strcmp(command, "refresh") == 0) {
char omapiargs[DNS_NAME_MAXTEXT];
omapiargs[0]=0;
if (zonename != NULL) {
strncat(omapiargs, "Z", 1);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
strncat(omapiargs, zonename,
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
if (zonename != NULL && viewname != NULL) {
strncat(omapiargs, " ",
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
if (viewname != NULL) {
strncat(omapiargs, "V", 1);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
strncat(omapiargs, viewname,
DNS_NAME_MAXTEXT);
omapiargs[DNS_NAME_MAXTEXT-1] = 0;
}
result = send_command(omapimgr, command, omapiargs);
} else if (strcmp(command, "restart") == 0) {
result = ISC_R_NOTIMPLEMENTED;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: opt.h,v 1.1 2000/10/11 17:44:18 mws Exp $ */
/* $Id: opt.h,v 1.2 2000/10/12 21:51:57 mws Exp $ */
#ifndef DNS_OPT_H
#define DNS_OPT_H 1
......@@ -29,6 +29,14 @@
#include <dns/rdataset.h>
#include <dns/message.h>
#ifndef NOMINUM_PUBLIC
/*
* XXX For GNS, We're enabling the new option codes. This is
* internal use only.
*/
#define DNS_OPT_NEWCODES
#endif /* NOMINUM_PUBLIC */
/*
* XXX WARNING XXX These codes have not yet been assigned by IANA.
* These are here as placekeepers ONLY.
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.h,v 1.78 2000/10/05 06:39:25 marka Exp $ */
/* $Id: zone.h,v 1.79 2000/10/12 21:51:58 mws Exp $ */
#ifndef DNS_ZONE_H
#define DNS_ZONE_H 1
......@@ -1156,6 +1156,23 @@ dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
* 'zmgr' to be a valid zone manager.
*/
void
dns_zone_forcereload(dns_zone_t *zone);
/*
* Force a reload of specified zone.
*
* Requires:
* 'zone' to be a valid zone.
*/
isc_boolean_t
dns_zone_isforced(dns_zone_t *zone);
/*
* Check if the zone is waiting a forced reload.
*
* Requires:
* 'zone' to be a valid zone.
*/
ISC_LANG_ENDDECLS
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: xfrin.c,v 1.100 2000/10/12 03:32:14 marka Exp $ */
/* $Id: xfrin.c,v 1.101 2000/10/12 21:51:53 mws Exp $ */
#include <config.h>
......@@ -409,7 +409,8 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, isc_uint32_t ttl,
case XFRST_SOAQUERY:
xfr->end_serial = dns_soa_getserial(rdata);
if (!DNS_SERIAL_GT(xfr->end_serial,
xfr->ixfr.request_serial)) {
xfr->ixfr.request_serial) &&
!dns_zone_isforced(xfr->zone)) {
xfrin_log(xfr, ISC_LOG_DEBUG(3),
"requested serial %u, "
"master has %u, not updating",
......@@ -437,7 +438,8 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, isc_uint32_t ttl,
*/
xfr->end_serial = dns_soa_getserial(rdata);
if (xfr->reqtype == dns_rdatatype_ixfr &&
! DNS_SERIAL_GT(xfr->end_serial, xfr->ixfr.request_serial))
! DNS_SERIAL_GT(xfr->end_serial, xfr->ixfr.request_serial)
&& !dns_zone_isforced(xfr->zone))
{
/*
* This must be the single SOA record that is
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.c,v 1.229 2000/10/10 22:00:12 bwelling Exp $ */
/* $Id: zone.c,v 1.230 2000/10/12 21:51:55 mws Exp $ */
#include <config.h>
......@@ -208,10 +208,12 @@ struct dns_zone {
#define DNS_ZONEFLG_NOMASTERS 0x00001000U /* an attempt to refresh a
* zone with no masters
* occured */
#define DNS_ZONEFLG_LOADING 0x00002000U /* load from disk in progress */
#define DNS_ZONEFLG_HAVETIMERS 0x00004000U /* timer values have been set from
SOA (if not set, we are still using
default timer values) */
#define DNS_ZONEFLG_LOADING 0x00002000U /* load from disk in progress*/
#define DNS_ZONEFLG_HAVETIMERS 0x00004000U /* timer values have been set
* from SOA (if not set, we
* are still using
* default timer values) */
#define DNS_ZONEFLG_FORCELOAD 0x00008000U /* Force a reload */
#define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0)
......@@ -2967,6 +2969,9 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
zone_log(zone, me, ISC_LOG_DEBUG(1), "Serial: new %u, old %u",
serial, zone->serial);
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) ||
#ifndef NOMINUM_PUBLIC
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FORCELOAD) ||
#endif /* NOMINUM_PUBLIC */
isc_serial_gt(serial, zone->serial)) {
tcp_transfer:
isc_event_free(&event);
......@@ -4283,6 +4288,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
zone->flags |= DNS_ZONEFLG_NEEDNOTIFY;
/*FALLTHROUGH*/
case DNS_R_UPTODATE:
zone->flags &= ~DNS_ZONEFLG_FORCELOAD;
/*
* Has the zone expired underneath us?
*/
......@@ -4535,6 +4541,11 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) {
"no database exists yet, requesting AXFR of "
"initial version from %s", mastertext);
xfrtype = dns_rdatatype_axfr;
} else if (dns_zone_isforced(zone)) {
zone_log(zone, me, ISC_LOG_DEBUG(3),
"forced reload, requesting AXFR of "
"initial version from %s", mastertext);
xfrtype = dns_rdatatype_axfr;
} else {
isc_boolean_t use_ixfr = ISC_TRUE;
if (peer != NULL &&
......@@ -5410,3 +5421,18 @@ dns_zonemgr_dbdestroyed(isc_task_t *task, isc_event_t *event) {
"database (%p) destroyed", (void*) db);
}
#endif
void
dns_zone_forcereload(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
zone->flags |= DNS_ZONEFLG_FORCELOAD;
dns_zone_refresh(zone);
}
isc_boolean_t
dns_zone_isforced(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
return (DNS_ZONE_FLAG(zone,DNS_ZONEFLG_FORCELOAD));
}
......@@ -15,7 +15,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: sanitize_all.sh,v 1.7 2000/09/29 21:31:02 mws Exp $
# $Id: sanitize_all.sh,v 1.8 2000/10/12 21:52:00 mws Exp $
PERL=perl5
......@@ -23,9 +23,9 @@ PERL=perl5
# sanitize all of the files in that tree.
find . -name '*.[ch]' | xargs $PERL util/sanitize.pl -kNOMINUM_PUBLIC \
-kISC_PLATFORM_USETHREADS $*
-kISC_PLATFORM_USETHREADS -iNOMINUM_GNS $*
find . -name '*.in' | xargs $PERL util/sanitize.pl -kNOMINUM_PUBLIC \
-kISC_PLATFORM_USETHREADS $*
-kISC_PLATFORM_USETHREADS -iNOMINUM_GNS $*
for file in `find . -name '*.dirty'`
do
clean=`echo $file | sed 's/\.dirty$//'`
......
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