zone.c revision 6c90ca893c7f0f3088999333eb9826f5afc46d81
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * Copyright (C) 1999-2001 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5497de6931b5ac26f65c2343b0318614f73933baMark Andrews/* $Id: zone.c,v 1.297 2001/01/17 00:16:20 gson Exp $ */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define FORWARD_MAGIC ISC_MAGIC('F','o','r','w')
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define RANGE(a, b, c) (((a) < (b)) ? (b) : ((a) < (c) ? (a) : (c)))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Default values.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define MAX_XFER_TIME (2*3600) /* Documented default is 2 hours */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff do { (z)->locked = ISC_FALSE; UNLOCK(&(z)->lock); } while (0)
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence /* Unlocked */
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence unsigned int magic;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley /* Locked */
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley unsigned int erefs;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int irefs;
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley unsigned int flags;
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews unsigned int options;
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews unsigned int db_argc;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Access Control Lists */
08e57545c2b1068080f5bf317224160426801406Brian Wellington * Zones in certain states such as "waiting for zone transfer"
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence * or "zone transfer in progress" are kept on per-state linked lists
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence * in the zone manager using the 'statelink' field. The 'statelist'
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence * field points at the list the zone is currently on. It the zone
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence * is not on any such list, statelist is NULL.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Optional per-zone statistics counters (NULL if not present).
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews#define DNS_ZONE_FLAG(z,f) (ISC_TF(((z)->flags & (f)) != 0))
092b4e5359c5982a438e36ced3dbefc313f7fbfcDavid Lawrence#define DNS_ZONE_SETFLAG(z,f) do { \
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews (z)->flags |= (f); \
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONE_CLRFLAG(z,f) do { \
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence (z)->flags &= ~(f); \
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /* XXX MPA these may need to go back into zone.h */
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff#define DNS_ZONEFLG_REFRESH 0x00000001U /* refresh check in progress */
037b732f88edc943f3141e0342dc993156e3abf3Mark Andrews#define DNS_ZONEFLG_NEEDDUMP 0x00000002U /* zone need consolidation */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_USEVC 0x00000004U /* use tcp for refresh query */
1630fce031f7a3e33f0579e477a3e17d1993e1f9Bob Halley#define DNS_ZONEFLG_DUMPING 0x00000008U /* a dump is in progress */
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews#define DNS_ZONEFLG_HASINCLUDE 0x00000010U /* $INCLUDE in zone file */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_LOADED 0x00000020U /* database has loaded */
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews#define DNS_ZONEFLG_EXITING 0x00000040U /* zone is being destroyed */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_EXPIRED 0x00000080U /* zone has expired */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_NEEDREFRESH 0x00000100U /* refresh check needed */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_UPTODATE 0x00000200U /* zone contents are
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * uptodate */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_NEEDNOTIFY 0x00000400U /* need to send out notify
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * messages */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_DIFFONRELOAD 0x00000800U /* generate a journal diff on
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_NOMASTERS 0x00001000U /* an attempt to refresh a
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * zone with no masters
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_LOADING 0x00002000U /* load from disk in progress*/
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_HAVETIMERS 0x00004000U /* timer values have been set
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * from SOA (if not set, we
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * are still using
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * default timer values) */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONEFLG_FORCEXFER 0x00008000U /* Force a zone xfer */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0)
7554feaef6057f5ea2926076900ac7634b911456Mark Andrews unsigned int magic;
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /* Locked by rwlock. */
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews /* Locked by conflock. */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence /* Locked by iolock */
83e6eb0dfe7d3525dcf093f440e04e8971c4c5d2Brian Wellington * Hold notify state.
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence unsigned int flags;
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff * dns_stub holds state while performing a 'stub' transfer.
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence * 'db' is the zone's 'db' or a new one if this is the initial
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Hold load state.
ec80744ad68b97f15657b1fdf5591c30b559b57dDavid Lawrence * Hold forward state.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Hold IO request state.
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrencestatic void zone_settimer(dns_zone_t *, isc_stdtime_t);
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrencestatic void zone_log(dns_zone_t *zone, const char *, int, const char *msg,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void notify_log(dns_zone_t *zone, int level, const char *fmt, ...);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_iattach(dns_zone_t *source, dns_zone_t **target);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t zone_replacedb(dns_zone_t *zone, dns_db_t *db,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t default_journal(dns_zone_t *zone);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_xfrdone(dns_zone_t *zone, isc_result_t result);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t zone_postload(dns_zone_t *zone, dns_db_t *db,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_needdump(dns_zone_t *zone, unsigned int delay);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_shutdown(isc_task_t *, isc_event_t *);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_loaddone(void *arg, isc_result_t result);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t zone_startload(dns_db_t *db, dns_zone_t *zone,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff/* ondestroy example */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void dns_zonemgr_dbdestroyed(isc_task_t *task, isc_event_t *event);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void refresh_callback(isc_task_t *, isc_event_t *);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void stub_callback(isc_task_t *, isc_event_t *);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void soa_query(isc_task_t *, isc_event_t *);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic int message_count(dns_message_t *msg, dns_section_t section,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void notify_find_address(dns_notify_t *notify);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t notify_createmessage(dns_zone_t *zone,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int flags,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_notifyforward(dns_zone_t *zone);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#endif /* NOMINUM_PUBLIC */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void notify_done(isc_task_t *task, isc_event_t *event);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void notify_send_toaddr(isc_task_t *task, isc_event_t *event);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void got_transfer_quota(isc_task_t *task, isc_event_t *event);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t zmgr_start_xfrin_ifquota(dns_zonemgr_t *zmgr,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zmgr_resume_xfrs(dns_zonemgr_t *zmgr);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic isc_result_t zonemgr_getio(dns_zonemgr_t *zmgr, isc_boolean_t high,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_get_from_db(dns_db_t *db, dns_name_t *origin, unsigned int *nscount,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void forward_callback(isc_task_t *task, isc_event_t *event);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_saveunique(dns_zone_t *zone, const char *path,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff const char *templat);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffstatic void zone_maintenance(dns_zone_t *zone);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define ZONE_LOG(x,y) zone_log(zone, me, ISC_LOG_DEBUG(x), y)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_ENTER zone_log(zone, me, ISC_LOG_DEBUG(1), "enter")
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff#define DNS_LEAVE zone_log(zone, me, ISC_LOG_DEBUG(1), "leave")
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff *** Public functions.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "isc_mutex_init() failed: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* XXX MPA check that all elements are initialised */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Must be after magic is set. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_zone_setdbtype(zone, dbargc_default, dbargv_default);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff ISC_EVENT_INIT(&zone->ctlevent, sizeof(zone->ctlevent), 0, NULL,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_EVENT_ZONECONTROL, zone_shutdown, zone, zone,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Free a zone. Because we require that there be no more
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * outstanding events or references, no locking is necessary.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Managed objects. Order is important.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff dns_request_destroy(&zone->request); /* XXXMPA */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Unmanaged objects */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff dns_stats_freecounters(zone->mctx, &zone->counters);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff dns_zone_setmasterswithkeys(zone, NULL, NULL, 0);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* last stuff */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Single shot.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Test and set.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff REQUIRE(zone->rdclass == dns_rdataclass_none ||
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Single shot.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_settype(dns_zone_t *zone, dns_zonetype_t type) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Test and set.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff REQUIRE(zone->type == dns_zone_none || zone->type == type);
194f54f4da604a6601edefa2175d48412e01bf2fDavid Lawrence unsigned int i;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Free the old database argument list. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int dbargc, const char * const *dbargv) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int i;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Set up a new database argument list. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff new = isc_mem_get(zone->mctx, dbargc * sizeof *new);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < dbargc; i++)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < dbargc; i++) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff new[i] = isc_mem_strdup(zone->mctx, dbargv[i]);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Free the old list. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < dbargc; i++) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setview(dns_zone_t *zone, dns_view_t *view) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setorigin(dns_zone_t *zone, dns_name_t *origin) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_name_dup(origin, zone->mctx, &zone->origin);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setstring(dns_zone_t *zone, char **field, const char *value) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setfile(dns_zone_t *zone, const char *file) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_zone_setstring(zone, &zone->masterfile, file);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Calculate string length including '\0'. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff int len = strlen(zone->masterfile) + sizeof ".jnl";
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_zone_setstring(zone, &zone->journal, journal);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setjournal(dns_zone_t *zone, const char *journal) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_zone_setstring(zone, &zone->journal, journal);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Return true iff the zone is "dynamic", in the sense that the zone's
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * master file (if any) is written by the server, rather than being
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * updated manually and read by the server.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * This is true for slave zones, stub zones, and zones that allow
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * dynamic updates either by having an update policy ("ssutable")
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * or an "allow-update" ACL with a value other than exactly "{ none; }".
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff return (ISC_TF(zone->type == dns_zone_slave ||
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone->update_acl->elements[0].negative == ISC_TRUE
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (zone->db != NULL && zone->masterfile == NULL) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * The zone has no master file configured, but it already
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * has a database. It could be the built-in
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * version.bind. CH zone, a zone with a persistent
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * database being reloaded, or maybe a zone that
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * used to have a master file but whose configuration
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * was changed so that it no longer has one. Do nothing.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (zone->db != NULL && zone_isdynamic(zone)) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * This is a slave, stub, or dynamically updated
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * zone being reloaded. Do nothing - the database
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * we already have is guaranteed to be up-to-date.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, me, ISC_LOG_DEBUG(1), "start");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Don't do the load if the file that stores the zone is older
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * than the last time the zone was loaded. If the zone has not
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * been loaded yet, zone->loadtime will be the epoch.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff ! DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE)) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = isc_file_getmodtime(zone->masterfile, &filetime);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_time_compare(&filetime, &zone->loadtime) < 0) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "skipping: master file older"
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff " than last load");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Store the current time before the zone is loaded, so that if the
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * file changes between the time of the load and the time that
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * zone->loadtime is set, then the file will still be reloaded
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * the next time dns_zone_load is called.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_db_create(zone->mctx, zone->db_argv[0],
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff &zone->origin, (zone->type == dns_zone_stub) ?
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "creating database: %s", isc_result_totext(result));
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "no master file configured");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = zone_postload(zone, db, loadtime, result);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_gotreadhandle(isc_task_t *task, isc_event_t *event) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_master_loadfileinc(load->zone->masterfile,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (result != ISC_R_SUCCESS && result != DNS_R_CONTINUE &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (zone->zmgr != NULL && zone->db != NULL && zone->task != NULL) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff load = isc_mem_get(zone->mctx, sizeof(*load));
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_db_beginload(db, &load->callbacks.add,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = zonemgr_getio(zone->zmgr, ISC_TRUE, zone->task,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff } else if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_MANYERRORS)) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_master_loadfile(zone->masterfile, &zone->origin,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff tresult = dns_db_endload(db, &callbacks.add_private);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int soacount = 0;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int nscount = 0;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_uint32_t serial, refresh, retry, expire, minimum;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Initiate zone transfer? We may need a error code that
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * indicates that the "permanent" form does not exist.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * XXX better error feedback to log.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "no master file");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "loading master file %s: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "loading master file %s: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "number of nodes in database: %u",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, me, ISC_LOG_DEBUG(1), "loaded");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_HASINCLUDE);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_HASINCLUDE);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Apply update log, if any.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_journal_rollforward(zone->mctx, db,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result != DNS_R_UPTODATE && result != DNS_R_NOJOURNAL &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "dns_journal_rollforward returned: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (result == ISC_R_NOTFOUND || result == ISC_R_RANGE) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "journal out of sync with zone");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "dns_journal_rollforward: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Obtain ns and soa counts for top of zone.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = zone_get_from_db(db, &zone->origin, &nscount,
bd1190c84b08e61a12789c54f083318c36449e5eDavid Lawrence "could not find NS and/or SOA records");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Master / Slave / Stub zones require both NS and SOA records at
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * the top of the zone.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence zone_log(zone, me, ISC_LOG_ERROR, "no NS records");
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence "zone serial has gone backwards");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone->expire = RANGE(expire, zone->refresh + zone->retry,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_HAVETIMERS);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = isc_file_getmodtime(zone->journal, &t);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = isc_file_getmodtime(zone->masterfile,
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence /* destroy notification example. */
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence isc_event_t *e = isc_event_allocate(zone->mctx, NULL,
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence result = zone_replacedb(zone, db, ISC_FALSE);
a571ebca8b8c472e775d518e82b7335f93ea25c4Andreas Gustafsson zone_saveunique(zone, zone->journal, "jn-XXXXXXXX");
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence zone_saveunique(zone, zone->masterfile, "db-XXXXXXXX");
510f4bdcb66acbec3f276efaacecbebea891c868David Lawrence /* Mark the zone for immediate refresh. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_SHUTDOWN) &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * DNS_ZONEFLG_SHUTDOWN can only be set if erefs == 0.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_count_ns_rr(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int *nscount)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int count;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_db_findrdataset(db, node, version, dns_rdatatype_ns,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_load_soa_rr(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int *soacount,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int count;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_db_findrdataset(db, node, version, dns_rdatatype_soa,
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence * zone must be locked.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_get_from_db(dns_db_t *db, dns_name_t *origin, unsigned int *nscount,
a09c545af1ceb8eb6f3aa2bb6fae286208a72141David Lawrence result = dns_db_findnode(db, origin, ISC_FALSE, &node);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = zone_count_ns_rr(db, node, version, nscount);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (soacount != NULL || serial != NULL || refresh != NULL
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff || retry != NULL || expire != NULL || minimum != NULL) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = zone_load_soa_rr(db, node, version, soacount,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_attach(dns_zone_t *source, dns_zone_t **target) {
08e57545c2b1068080f5bf317224160426801406Brian Wellington REQUIRE(target != NULL && *target == NULL);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(source, "dns_zone_attach", ISC_LOG_DEBUG(10),
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "eref = %d, irefs = %d", source->erefs, source->irefs);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * We just detached the last external reference.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * This zone is being managed. Post
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * its control event and let it clean
c0bf2b179a199c50d2b50d43b18302ee5c3af6baAndreas Gustafsson * up synchronously in the context of
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * This zone is not being managed; it has
08e57545c2b1068080f5bf317224160426801406Brian Wellington * no task and can have no outstanding
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence * events. Free it immediately.
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence * Unmanaged zones should not have non-null views;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * we have no way of detaching from the view here
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence * without causing deadlock because this code is called
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * with the view already locked.
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence zone_log(zone, "dns_zone_detach", ISC_LOG_DEBUG(10),
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence "eref = %d, irefs = %d", zone->erefs, zone->irefs);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_iattach(dns_zone_t *source, dns_zone_t **target) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_iattach(dns_zone_t *source, dns_zone_t **target) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * 'source' locked by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(source, "zone_iattach", ISC_LOG_DEBUG(10),
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "eref = %d, irefs = %d", source->erefs, source->irefs);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * 'zone' locked by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, "zone_idetach", ISC_LOG_DEBUG(10),
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "eref = %d, irefs = %d", zone->erefs, zone->irefs);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
b65f2ab14abb4b6ef906d7d02064fba158f07b1eDavid Lawrence zone_log(zone, "dns_zone_idetach", ISC_LOG_DEBUG(10),
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "eref = %d, irefs = %d", zone->erefs, zone->irefs);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrencedns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value)
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrencedns_zone_setxfrsource4(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
5d4f11b265c396d71ec2162a632e620425481a9eDavid Lawrencedns_zone_setxfrsource6(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
c4c843edb3f4c609e3552ee77a43400852400467David Lawrencedns_zone_setnotifysrc4(dns_zone_t *zone, isc_sockaddr_t *notifysrc) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setnotifysrc6(dns_zone_t *zone, isc_sockaddr_t *notifysrc) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setalsonotify(dns_zone_t *zone, isc_sockaddr_t *notify,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff new = isc_mem_get(zone->mctx, count * sizeof *new);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setmasters(dns_zone_t *zone, isc_sockaddr_t *masters,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_zone_setmasterswithkeys(zone, masters, NULL, count);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setmasterswithkeys(dns_zone_t *zone, isc_sockaddr_t *masters,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int i;
0f5962ac3e4ef336faff68f1cb838505e64665e5David Lawrence isc_mem_put(zone->mctx, zone->masterkeynames,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * If count == 0, don't allocate any space for masters or keynames
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * so internally, those pointers are NULL if count == 0
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * masters must countain count elements!
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NOMASTERS);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * if keynames is non-NULL, it must contain count elements!
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < count; i++)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < count; i++) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_name_dup(keynames[i], zone->mctx,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff for (i = 0; i < count; i++)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_getdb(dns_zone_t *zone, dns_db_t **dpb) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Co-ordinates the starting of routine jobs.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Configuring the view of this zone may have
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * failed, for example because the config file
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * had a syntax error. In that case, the view
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * adb or resolver, and we had better not try
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * to do maintenance on it.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (zone->view == NULL || zone->view->adb == NULL)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Expire check.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Up to date check.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH) &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Do we need to consolidate the backing store?
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "failed: %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Do we need to send out notify messages?
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * 'zone' locked by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, "zone_expire", ISC_LOG_WARNING, "expired");
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_HAVETIMERS);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
d65db52903505c1bcbc6dd1651e9f9f347e48217David Lawrence if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
d65db52903505c1bcbc6dd1651e9f9f347e48217David Lawrence * Set DNS_ZONEFLG_REFRESH so that there is only one refresh operation
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * in progress at a time.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOMASTERS);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, "dns_zone_refresh", ISC_LOG_ERROR,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff "no masters");
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if ((oldflags & (DNS_ZONEFLG_REFRESH|DNS_ZONEFLG_LOADING)) != 0)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Set the next refresh time as if refresh check has failed.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Setting this to the retry time will do that. XXXMLG
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * If we are successful it will be reset using zone->refresh.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_random_jitter(zone->retry, zone->retry / 4);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone_log(zone, "dns_zone_refresh", ISC_LOG_DEBUG(20),
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews "refresh time (%u/%u), now %u",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * When lacking user-specified timer values from the SOA,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * do exponential backoff of the retry time up to a
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews * maximum of six hours.
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews if (! DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HAVETIMERS))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff zone->retry = ISC_MIN(zone->retry * 2, 6 * 3600);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* initiate soa query */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffzone_needdump(dns_zone_t *zone, unsigned int delay) {
83a56f1e4f2d11fa895ceff4342fff7157910036Mark Andrews * 'zone' locked by caller
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Do we have a place to dump to and are we loaded?
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* add some noise */
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * 'zone' locked by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_master_dump(zone->mctx, zone->db, version,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff dns_db_closeversion(zone->db, &version, ISC_FALSE);
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * Try again in a short while.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_master_dumptostream(zone->mctx, db, version,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * 'zone' locked by caller.
f389bc2c9e9e434380e10221778b7b548612a67fDavid Lawrence * 'zone' locked by caller.
5497de6931b5ac26f65c2343b0318614f73933baMark Andrewsdns_zone_setminrefreshtime(dns_zone_t *zone, isc_uint32_t val) {
5497de6931b5ac26f65c2343b0318614f73933baMark Andrewsdns_zone_setmaxrefreshtime(dns_zone_t *zone, isc_uint32_t val) {
c5944292e9ebee4a39fe939b9a16fe5596808556David Lawrencedns_zone_setminretrytime(dns_zone_t *zone, isc_uint32_t val) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffdns_zone_setmaxretrytime(dns_zone_t *zone, isc_uint32_t val) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffnotify_isqueued(dns_zone_t *zone, dns_name_t *name, isc_sockaddr_t *addr) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (name != NULL && dns_name_dynamic(¬ify->ns) &&
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (addr != NULL && isc_sockaddr_equal(addr, ¬ify->dst))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffnotify_destroy(dns_notify_t *notify, isc_boolean_t locked) {
33950f0a0262f4d49528c4adcf8be42807fa2576David Lawrence * Caller holds zone lock.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff ISC_LIST_UNLINK(notify->zone->notifies, notify, link);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_mem_put(notify->mctx, notify, sizeof *notify);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffnotify_create(isc_mem_t *mctx, unsigned int flags, dns_notify_t **notifyp) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * XXXAG should check for DNS_ZONEFLG_EXITING
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffprocess_adb_event(isc_task_t *task, isc_event_t *ev) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int options;
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff options = DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_INET |
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_adb_createfind(notify->zone->view->adb,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* Something failed? */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* More addresses pending? */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if ((notify->find->options & DNS_ADBFIND_WANTEVENT) != 0)
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff /* We have as many addresses as we can get. */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = isc_ratelimiter_enqueue(notify->zone->zmgr->rl,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graffnotify_send_toaddr(isc_task_t *task, isc_event_t *event) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_LOADED) == 0) {
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ||
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_EXITING) ||
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = notify_createmessage(notify->zone, notify->flags, &message);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_netaddr_fromsockaddr(&dstip, ¬ify->dst);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff (void)dns_view_getpeertsig(notify->zone->view, &dstip, &key);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf));
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff notify_log(notify->zone, ISC_LOG_DEBUG(3), "sending notify to %s",
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff result = dns_request_createvia(notify->zone->view->requestmgr, message,
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Zone lock held by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff if (notify_isqueued(notify->zone, NULL, &dst))
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff ISC_LIST_APPEND(new->zone->notifies, new, link);
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff unsigned int i;
1adfd0a9119434de35e1a6b6ddc65b28dd608308David Lawrence * Locked by caller.
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * Enqueue notify requests for 'also-notify' servers.
1adfd0a9119434de35e1a6b6ddc65b28dd608308David Lawrence result = notify_create(zone->mctx, DNS_NOTIFY_NOSOA, ¬ify);
1adfd0a9119434de35e1a6b6ddc65b28dd608308David Lawrence ISC_LIST_APPEND(zone->notifies, notify, link);
5f50687f61057f7f0acb161d5803f4a48e40b3a8David Lawrence#endif /* NOMINUM_PUBLIC */
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
unsigned int flags = 0;
goto cleanup1;
goto cleanup2;
goto cleanup3;
goto cleanup3;
if (isqueued) {
static inline isc_result_t
goto fail;
goto fail;
goto fail;
&rdataset);
goto fail;
goto fail;
&rdataset);
goto fail;
goto fail;
&rdataset);
goto fail;
goto fail;
goto fail;
return (ISC_R_SUCCESS);
fail:
return (result);
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto same_master;
goto next_master;
if (cnamecnt != 0) {
goto next_master;
if (nscnt == 0) {
goto next_master;
goto next_master;
goto free_stub;
goto free_stub;
goto free_stub;
goto done;
done:
goto same_master;
master);
goto next_master;
goto next_master;
goto next_master;
goto next_master;
master);
goto tcp_transfer;
master);
goto next_master;
goto same_master;
goto next_master;
if (cnamecnt != 0) {
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
isc_time_t t;
goto next_master;
goto next_master;
goto detach;
goto detach;
goto detach;
isc_event_t *e;
if (e == NULL) {
isc_event_free(&e);
static inline isc_result_t
&message);
goto cleanup;
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
goto cleanup;
goto cleanup;
DNS_REQUESTOPT_TCP : 0;
case PF_INET:
case PF_INET6:
goto cleanup;
goto cleanup;
if (cancel)
goto cleanup;
goto cleanup;
&node);
goto cleanup;
goto cleanup;
case PF_INET:
case PF_INET6:
goto cleanup;
goto cleanup;
goto unlock;
if (free_needed)
case dns_zone_master:
case dns_zone_slave:
case dns_zone_stub:
if (next == 0) {
static isc_result_t
isc_region_t r;
&message);
return (result);
goto cleanup;
goto cleanup;
goto done;
goto soa_cleanup;
goto soa_cleanup;
goto soa_cleanup;
goto soa_cleanup;
goto soa_cleanup;
NULL);
goto soa_cleanup;
goto soa_cleanup;
goto soa_cleanup;
isc_buffer_usedregion(b, &r);
goto soa_cleanup;
goto soa_cleanup;
done:
return (ISC_R_SUCCESS);
return (result);
int match = 0;
#ifndef NOMINUM_PUBLIC
return (DNS_R_FORMERR);
return (DNS_R_NOTIMP);
return (ISC_R_SUCCESS);
#ifndef NOMINUM_PUBLIC
return (DNS_R_REFUSED);
&rdataset);
fromtext);
return (ISC_R_SUCCESS);
#ifndef NOMINUM_PUBLIC
if (forward) {
return (ISC_R_SUCCESS);
fromtext);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
int count = 0;
count++;
return (count);
if (idlein == 0)
return (result);
static isc_result_t
goto fail;
goto fail;
return (ISC_R_SUCCESS);
fail:
return (result);
unsigned int soacount;
unsigned int nscount;
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_UPTODATE:
goto same_master;
isc_time_t t;
nscount = 0;
soacount = 0;
if (nscount == 0)
goto cleanup;
static isc_result_t
return (ISC_R_NOMORE);
case PF_INET:
case PF_INET6:
goto unlock;
return (result);
goto next_master;
goto next_master;
goto next_master;
case dns_rcode_noerror:
case dns_rcode_yxdomain:
case dns_rcode_yxrrset:
case dns_rcode_nxrrset:
case dns_rcode_refused:
case dns_rcode_nxdomain:
case dns_rcode_notzone:
case dns_rcode_notauth: {
goto next_master;
case dns_rcode_formerr:
case dns_rcode_servfail:
case dns_rcode_notimp:
case dns_rcode_badvers:
goto next_master;
return (ISC_R_NOMEMORY);
goto cleanup;
goto cleanup;
goto cleanup;
return (result);
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
goto free_mem;
goto free_rwlock;
goto free_conflock;
goto free_taskpool;
goto free_task;
goto free_rl;
return (ISC_R_SUCCESS);
return (result);
goto cleanup_task;
goto unlock;
return (result);
if (free_now)
if (free_now)
dns_zone_t *p;
p != NULL;
return (ISC_R_SUCCESS);
static isc_result_t
dns_zone_t *x;
isc_event_t *e;
x != NULL;
nxfrsin++;
nxfrsperns++;
return (ISC_R_QUOTA);
return (ISC_R_QUOTA);
sizeof(isc_event_t));
if (e == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
if (queue) {
if (!queue) {
return (ISC_R_SUCCESS);
if (send_event) {
char *buf;
int buflen;
goto cleanup;
goto cleanup;
if (on) {
goto done;
goto done;
done:
return (result);
switch (dialup) {
case dns_dialuptype_no:
case dns_dialuptype_yes:
case dns_dialuptype_notify:
case dns_dialuptype_refresh:
case dns_dialuptype_passive:
INSIST(0);