diff --git a/bin/named/control.c b/bin/named/control.c index 14f26b43d3..77f65e5282 100644 --- a/bin/named/control.c +++ b/bin/named/control.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: control.c,v 1.3 2001/04/11 20:37:33 bwelling Exp $ */ +/* $Id: control.c,v 1.4 2001/05/07 23:33:58 gson Exp $ */ #include @@ -79,6 +79,8 @@ ns_control_docommand(isccc_sexpr_t *message) { */ if (command_compare(command, NS_COMMAND_RELOAD)) { result = ns_server_reloadcommand(ns_g_server, command); + } else if (command_compare(command, NS_COMMAND_RECONFIG)) { + result = ns_server_reconfigcommand(ns_g_server, command); } else if (command_compare(command, NS_COMMAND_REFRESH)) { result = ns_server_refreshcommand(ns_g_server, command); } else if (command_compare(command, NS_COMMAND_HALT)) { @@ -89,13 +91,6 @@ ns_control_docommand(isccc_sexpr_t *message) { ns_server_flushonshutdown(ns_g_server, ISC_TRUE); isc_app_shutdown(); result = ISC_R_SUCCESS; - } else if (command_compare(command, NS_COMMAND_RELOADCONFIG) || - command_compare(command, NS_COMMAND_RELOADZONES)) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, - NS_LOGMODULE_CONTROL, ISC_LOG_WARNING, - "unimplemented channel command '%s'", - command); - result = ISC_R_NOTIMPLEMENTED; } else if (command_compare(command, NS_COMMAND_DUMPSTATS)) { result = ns_server_dumpstats(ns_g_server); } else if (command_compare(command, NS_COMMAND_QUERYLOG)) { diff --git a/bin/named/include/named/control.h b/bin/named/include/named/control.h index d2697f357a..291c4e18d3 100644 --- a/bin/named/include/named/control.h +++ b/bin/named/include/named/control.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: control.h,v 1.3 2001/04/11 20:37:36 bwelling Exp $ */ +/* $Id: control.h,v 1.4 2001/05/07 23:34:01 gson Exp $ */ #ifndef NAMED_CONTROL_H #define NAMED_CONTROL_H 1 @@ -29,8 +29,7 @@ #define NS_COMMAND_STOP "stop" #define NS_COMMAND_HALT "halt" #define NS_COMMAND_RELOAD "reload" -#define NS_COMMAND_RELOADCONFIG "reload-config" -#define NS_COMMAND_RELOADZONES "reload-zones" +#define NS_COMMAND_RECONFIG "reconfig" #define NS_COMMAND_REFRESH "refresh" #define NS_COMMAND_DUMPSTATS "stats" #define NS_COMMAND_QUERYLOG "querylog" diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h index 629ef531e0..7c2ad5ff42 100644 --- a/bin/named/include/named/server.h +++ b/bin/named/include/named/server.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.h,v 1.53 2001/04/11 20:37:37 bwelling Exp $ */ +/* $Id: server.h,v 1.54 2001/05/07 23:34:02 gson Exp $ */ #ifndef NAMED_SERVER_H #define NAMED_SERVER_H 1 @@ -118,6 +118,12 @@ ns_server_reloadcommand(ns_server_t *server, char *args); * Act on a "reload" command from the command channel. */ +isc_result_t +ns_server_reconfigcommand(ns_server_t *server, char *args); +/* + * Act on a "reconfig" command from the command channel. + */ + isc_result_t ns_server_refreshcommand(ns_server_t *server, char *args); /* diff --git a/bin/named/server.c b/bin/named/server.c index 69fd42c216..92d55bfe16 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.318 2001/04/19 23:38:32 bwelling Exp $ */ +/* $Id: server.c,v 1.319 2001/05/07 23:34:00 gson Exp $ */ #include @@ -2065,6 +2065,28 @@ load_zones(ns_server_t *server, isc_boolean_t stop) { return (result); } +static isc_result_t +load_new_zones(ns_server_t *server, isc_boolean_t stop) { + isc_result_t result; + dns_view_t *view; + + result = isc_task_beginexclusive(server->task); + RUNTIME_CHECK(result == ISC_R_SUCCESS); + + /* + * Load zone data from disk. + */ + for (view = ISC_LIST_HEAD(server->viewlist); + view != NULL; + view = ISC_LIST_NEXT(view, link)) + { + CHECK(dns_view_loadnew(view, stop)); + } + cleanup: + isc_task_endexclusive(server->task); + return (result); +} + static void run_server(isc_task_t *task, isc_event_t *event) { isc_result_t result; @@ -2309,6 +2331,54 @@ fatal(const char *msg, isc_result_t result) { exit(1); } +static isc_result_t +loadconfig(ns_server_t *server) { + isc_result_t result; + result = load_configuration(ns_g_lwresdonly ? + lwresd_g_conffile : ns_g_conffile, + server, + ISC_FALSE); + if (result != ISC_R_SUCCESS) + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, ISC_LOG_ERROR, + "reloading configuration failed: %s", + isc_result_totext(result)); + return (result); +} + +static void +reload(ns_server_t *server) { + isc_result_t result; + CHECK(loadconfig(server)); + + result = load_zones(server, ISC_FALSE); + if (result != ISC_R_SUCCESS) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, ISC_LOG_ERROR, + "reloading zones failed: %s", + isc_result_totext(result)); + } + cleanup: ; +} + +static void +reconfig(ns_server_t *server) { + isc_result_t result; + CHECK(loadconfig(server)); + + result = load_new_zones(server, ISC_FALSE); + if (result != ISC_R_SUCCESS) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, ISC_LOG_ERROR, + "loading new zones failed: %s", + isc_result_totext(result)); + } + cleanup: ; +} + +/* + * Handle a reload event (from SIGHUP). + */ static void ns_server_reload(isc_task_t *task, isc_event_t *event) { isc_result_t result; @@ -2317,24 +2387,8 @@ ns_server_reload(isc_task_t *task, isc_event_t *event) { INSIST(task = server->task); UNUSED(task); - if (ns_g_lwresdonly) - result = load_configuration(lwresd_g_conffile, server, - ISC_FALSE); - else - result = load_configuration(ns_g_conffile, server, ISC_FALSE); - if (result != ISC_R_SUCCESS) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, - NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "reloading configuration failed: %s", - isc_result_totext(result)); - } - result = load_zones(server, ISC_FALSE); - if (result != ISC_R_SUCCESS) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, - NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "reloading zones failed: %s", - isc_result_totext(result)); - } + reload(server); + LOCK(&server->reload_event_lock); INSIST(server->reload_event == NULL); server->reload_event = event; @@ -2446,12 +2500,11 @@ ns_server_reloadcommand(ns_server_t *server, char *args) { dns_zone_t *zone = NULL; dns_zonetype_t type; - UNUSED(server); result = zone_from_args(server, args, &zone); if (result != ISC_R_SUCCESS) return (result); if (zone == NULL) { - ns_server_reloadwanted(server); + reload(server); } else { type = dns_zone_gettype(zone); if (type == dns_zone_slave || type == dns_zone_stub) @@ -2463,6 +2516,17 @@ ns_server_reloadcommand(ns_server_t *server, char *args) { return (ISC_R_SUCCESS); } +/* + * Act on a "reconfig" command from the command channel. + */ +isc_result_t +ns_server_reconfigcommand(ns_server_t *server, char *args) { + UNUSED(args); + + reconfig(server); + return (ISC_R_SUCCESS); +} + /* * Act on a "refresh" command from the command channel. */ diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index 6884eccf3d..24ee6f2238 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -2,7 +2,7 @@ - + BIND 9 Administrator Reference Manual @@ -729,20 +729,33 @@ of a server. reload - Reload configuration file and zones. + Reload configuration file and zones. + reload zone class view - Reload the given zone. + Reload the given zone. + refresh zone class view - Schedule zone maintenance for the given zone. + Schedule zone maintenance for the given zone. + + + reconfig + Reload the configuration file and load new zones, + but do not reload existing zone files even if they have changed. + This is faster than a full reload when there + is a large number of zones because it avoids the need to examine the + modification times of the zones files. + + stats - Write server statistics to the statistics file. + Write server statistics to the statistics file. + querylog Toggle query logging. diff --git a/doc/arm/Bv9ARM.ch03.html b/doc/arm/Bv9ARM.ch03.html index 983f613690..c8e668b226 100644 --- a/doc/arm/Bv9ARM.ch03.html +++ b/doc/arm/Bv9ARM.ch03.html @@ -949,6 +949,25 @@ CLASS="replaceable" >reconfig

Reload the configuration file and load new zones, + but do not reload existing zone files even if they have changed. + This is faster than a full reload when there + is a large number of zones because it avoids the need to examine the + modification times of the zones files. +

stats

3.4.2. Signals

4.3. Split DNS
4.5. TKEY
4.6. SIG(0)
4.8. IPv6 Support in BIND

4.3. Split DNS

4.4.1. Generate Shared Keys for Each Pair of Hosts

4.4.1.1. Automatic Generation

4.4.1.2. Manual Generation

4.4.2. Copying the Shared Secret to Both Machines

4.4.3. Informing the Servers of the Key's Existence

4.4.4. Instructing the Server to Use the Key

4.4.5. TSIG Key Based Access Control

4.4.6. Errors

4.5. TKEY

4.6. SIG(0)

4.7.1. Generating Keys

4.7.2. Creating a Keyset

4.7.3. Signing the Child's Keyset

4.7.4. Signing the Zone

4.7.5. Configuring Servers

4.8. IPv6 Support in BIND

4.8.1. Address Lookups Using AAAA Records

4.8.2. Address Lookups Using A6 Records

4.8.2.1. A6 Chains

4.8.2.2. A6 Records for DNS Servers

4.8.3. Address to Name Lookups Using Nibble Format

4.8.4. Address to Name Lookups Using Bitstring Format

4.8.5. Using DNAME for Delegation of IPv6 Reverse Addresses

5.1. The Lightweight Resolver Library

5.1. The Lightweight Resolver Library

6.3. Zone File

6.1.1.1. Syntax

6.1.1.2. Definition and Usage

6.1.2. Comment Syntax

6.1.2.1. Syntax

6.1.2.2. Definition and Usage

6.2.1. acl

6.2.3. controls

6.2.4. controls

6.2.5. include

6.2.6. include

6.2.7. key

6.2.8. key

6.2.9. logging

6.2.10. logging

6.2.10.1. The channel

6.2.11. lwres

6.2.12. lwres

6.2.13. options

6.2.14. options

6.2.14.2. Forwarding

6.2.14.4. Interfaces

6.2.14.5. Query Address

6.2.14.7. Resource Limits

6.2.14.8. Periodic Task Intervals

6.2.17. trusted-keys

6.2.18. trusted-keys

6.2.19. view

6.2.20. view

6.2.22. zone

6.2.22.1. Zone Types

6.2.22.2. Class

6.2.22.3. Zone Options

6.3. Zone File

6.3.1.1. Resource Records

6.3.1.2. Textual expression of RRs

6.3.2. Discussion of MX Records

6.3.4. Inverse Mapping in IPv4

6.3.5. Other Zone File Directives

6.3.5.1. The $ORIGIN

6.3.5.2. The $INCLUDE

6.3.5.3. The $TTL

6.3.6. BIND

7.2. chroot

7.2. chroot

7.2.1. The chroot

7.2.2. Using the setuid

8.1. Common Problems
8.2. Incrementing and Changing the Serial Number
8.3. Where Can I Get Help?

8.1. Common Problems

8.1.1. It's not working; how can I figure out what's wrong?

8.2. Incrementing and Changing the Serial Number

8.3. Where Can I Get Help?

A.1. Acknowledgements
A.3. General DNS

A.1. Acknowledgements

A.1.1. A Brief History of the DNS

A.2.1.1. HS = hesiod

A.2.1.2. CH = chaos

A.3. General DNS

Bibliography

Standards

[RFC974] 

[RFC1034] 

[RFC1035] 

[RFC2181] 

[RFC2308] 

[RFC1995] 

[RFC1996] 

[RFC2136] 

[RFC2845] 

Proposed Standards Still Under Development

[RFC1886] 

[RFC2065] 

[RFC2137] 

Other Important RFCs About DNS

[RFC1535] 

[RFC1536] 

[RFC1982] 

Resource Record Types

[RFC1183] 

[RFC1706] 

[RFC2168] 

[RFC1876] 

[RFC2052] 

[RFC2163] 

[RFC2230] 

DNS

[RFC1101] 

[RFC1123] 

[RFC1591] 

[RFC2317] 

DNS

[RFC1537] 

[RFC1912] 

[RFC1912] 

[RFC2010] 

[RFC2219] 

Other DNS

[RFC1464] 

[RFC1713] 

3.4.2. Signals
4.3. Split DNS
4.4.1. Generate Shared Keys for Each Pair of Hosts
4.4.2. Copying the Shared Secret to Both Machines
4.4.3. Informing the Servers of the Key's Existence
4.4.4. Instructing the Server to Use the Key
4.4.5. TSIG Key Based Access Control
4.4.6. Errors
4.5. TKEY
4.6. SIG(0)
4.7.1. Generating Keys
4.7.2. Creating a Keyset
4.7.3. Signing the Child's Keyset
4.7.4. Signing the Zone
4.7.5. Configuring Servers
4.8. IPv6 Support in BIND
4.8.1. Address Lookups Using AAAA Records
4.8.2. Address Lookups Using A6 Records
4.8.3. Address to Name Lookups Using Nibble Format
4.8.4. Address to Name Lookups Using Bitstring Format
4.8.5. Using DNAME for Delegation of IPv6 Reverse Addresses
5.1. The Lightweight Resolver Library
6.1.2. Comment Syntax
6.2.1. acl
6.2.3. controls
6.2.4. controls
6.2.5. include
6.2.6. include
6.2.7. key
6.2.8. key
6.2.9. logging
6.2.10. logging
6.2.11. lwres
6.2.12. lwres
6.2.13. options
6.2.14. options
6.2.17. trusted-keys
6.2.18. trusted-keys
6.2.19. view
6.2.20. view
6.2.22. zone
6.3. Zone File
6.3.2. Discussion of MX Records
6.3.4. Inverse Mapping in IPv4
6.3.5. Other Zone File Directives
6.3.6. BIND
7.2. chroot
7.2.1. The chroot
7.2.2. Using the setuid
8.1. Common Problems
8.1.1. It's not working; how can I figure out what's wrong?
8.2. Incrementing and Changing the Serial Number
8.3. Where Can I Get Help?
A.1. Acknowledgements
A.1.1. A Brief History of the DNS
A.3. General DNS
A.4.3. Other Documents About BIND @@ -1035,6 +1035,14 @@ dns_view_load(dns_view_t *view, isc_boolean_t stop) { return (dns_zt_load(view->zonetable, stop)); } +isc_result_t +dns_view_loadnew(dns_view_t *view, isc_boolean_t stop) { + + REQUIRE(DNS_VIEW_VALID(view)); + + return (dns_zt_loadnew(view->zonetable, stop)); +} + isc_result_t dns_view_gettsig(dns_view_t *view, dns_name_t *keyname, dns_tsigkey_t **keyp) { diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 4e998d6077..9fd88dcf8e 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.320 2001/04/27 02:34:18 marka Exp $ */ +/* $Id: zone.c,v 1.321 2001/05/07 23:34:05 gson Exp $ */ #include @@ -254,6 +254,9 @@ struct dns_zone { #define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0) +/* Flags for zone_load() */ +#define DNS_ZONELOADFLAG_NOSTAT 0x00000001U /* Do not stat() master files */ + struct dns_zonemgr { unsigned int magic; isc_mem_t * mctx; @@ -876,8 +879,8 @@ zone_isdynamic(dns_zone_t *zone) { } -isc_result_t -dns_zone_load(dns_zone_t *zone) { +static isc_result_t +zone_load(dns_zone_t *zone, unsigned int flags) { isc_result_t result; isc_stdtime_t now; isc_time_t loadtime, filetime; @@ -918,27 +921,36 @@ dns_zone_load(dns_zone_t *zone) { goto cleanup; } - dns_zone_log(zone, ISC_LOG_DEBUG(1), "starting load"); - /* * Don't do the load if the file that stores the zone is older * than the last time the zone was loaded. If the zone has not * been loaded yet, zone->loadtime will be the epoch. */ - if (zone->masterfile != NULL && - ! DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE)) { - result = isc_file_getmodtime(zone->masterfile, &filetime); - if (result == ISC_R_SUCCESS && - !isc_time_isepoch(&zone->loadtime) && - isc_time_compare(&filetime, &zone->loadtime) < 0) { - dns_zone_log(zone, ISC_LOG_DEBUG(1), - "skipping load: master file older " - "than last load"); + if (zone->masterfile != NULL && ! isc_time_isepoch(&zone->loadtime)) { + /* + * The file is already loaded. If we are just doing a + * "rndc reconfig", we are done. + */ + if ((flags & DNS_ZONELOADFLAG_NOSTAT) != 0) { result = ISC_R_SUCCESS; goto cleanup; } + if (! DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE)) { + result = isc_file_getmodtime(zone->masterfile, + &filetime); + if (result == ISC_R_SUCCESS && + isc_time_compare(&filetime, &zone->loadtime) < 0) { + dns_zone_log(zone, ISC_LOG_DEBUG(1), + "skipping load: master file older " + "than last load"); + result = ISC_R_SUCCESS; + goto cleanup; + } + } } + dns_zone_log(zone, ISC_LOG_DEBUG(1), "starting load"); + /* * Store the current time before the zone is loaded, so that if the * file changes between the time of the load and the time that @@ -995,6 +1007,16 @@ dns_zone_load(dns_zone_t *zone) { return (result); } +isc_result_t +dns_zone_load(dns_zone_t *zone) { + return (zone_load(zone, 0)); +} + +isc_result_t +dns_zone_loadnew(dns_zone_t *zone) { + return (zone_load(zone, DNS_ZONELOADFLAG_NOSTAT)); +} + static void zone_gotreadhandle(isc_task_t *task, isc_event_t *event) { dns_load_t *load = event->ev_arg; diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 15634a8133..c5c52c7d17 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zt.c,v 1.29 2001/02/27 02:54:11 bwelling Exp $ */ +/* $Id: zt.c,v 1.30 2001/05/07 23:34:07 gson Exp $ */ #include @@ -48,6 +48,9 @@ auto_detach(void *, void *); static isc_result_t load(dns_zone_t *zone, void *uap); +static isc_result_t +loadnew(dns_zone_t *zone, void *uap); + isc_result_t dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) { dns_zt_t *zt; @@ -235,6 +238,24 @@ load(dns_zone_t *zone, void *uap) { return (dns_zone_load(zone)); } +isc_result_t +dns_zt_loadnew(dns_zt_t *zt, isc_boolean_t stop) { + isc_result_t result; + + REQUIRE(VALID_ZT(zt)); + + RWLOCK(&zt->rwlock, isc_rwlocktype_read); + result = dns_zt_apply(zt, stop, loadnew, NULL); + RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); + return (result); +} + +static isc_result_t +loadnew(dns_zone_t *zone, void *uap) { + UNUSED(uap); + return (dns_zone_loadnew(zone)); +} + isc_result_t dns_zt_apply(dns_zt_t *zt, isc_boolean_t stop, isc_result_t (*action)(dns_zone_t *, void *), void *uap)