zt.c File Reference

#include <config.h>
#include <isc/file.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/name.h>
#include <dns/rbt.h>
#include <dns/rdataclass.h>
#include <dns/result.h>
#include <dns/view.h>
#include <dns/zone.h>
#include <dns/zt.h>

Go to the source code of this file.

Data Structures

struct  dns_zt

Defines

#define ZTMAGIC   ISC_MAGIC('Z', 'T', 'b', 'l')
#define VALID_ZT(zt)   ISC_MAGIC_VALID(zt, ZTMAGIC)

Functions

static void auto_detach (void *, void *)
static isc_result_t load (dns_zone_t *zone, void *uap)
static isc_result_t asyncload (dns_zone_t *zone, void *callback)
static isc_result_t loadnew (dns_zone_t *zone, void *uap)
static isc_result_t freezezones (dns_zone_t *zone, void *uap)
static isc_result_t doneloading (dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task)
isc_result_t dns_zt_create (isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp)
 Creates a new zone table.
isc_result_t dns_zt_mount (dns_zt_t *zt, dns_zone_t *zone)
 Mounts the zone on the zone table.
isc_result_t dns_zt_unmount (dns_zt_t *zt, dns_zone_t *zone)
 Unmount the given zone from the table.
isc_result_t dns_zt_find (dns_zt_t *zt, dns_name_t *name, unsigned int options, dns_name_t *foundname, dns_zone_t **zonep)
 Find the best match for 'name' in 'zt'. If foundname is non NULL then the name of the zone found is returned.
void dns_zt_attach (dns_zt_t *zt, dns_zt_t **ztp)
 Attach 'zt' to '*ztp'.
static isc_result_t flush (dns_zone_t *zone, void *uap)
static void zt_destroy (dns_zt_t *zt)
static void zt_flushanddetach (dns_zt_t **ztp, isc_boolean_t need_flush)
void dns_zt_flushanddetach (dns_zt_t **ztp)
 Detach the given zonetable, if the reference count goes to zero the zonetable will be flushed and then freed. In either case 'ztp' is set to NULL.
void dns_zt_detach (dns_zt_t **ztp)
 Detach the given zonetable, if the reference count goes to zero the zonetable will be freed. In either case 'ztp' is set to NULL.
isc_result_t dns_zt_load (dns_zt_t *zt, isc_boolean_t stop)
isc_result_t dns_zt_asyncload (dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg)
 Load all zones in the table. If 'stop' is ISC_TRUE, stop on the first error and return it. If 'stop' is ISC_FALSE, ignore errors.
isc_result_t dns_zt_loadnew (dns_zt_t *zt, isc_boolean_t stop)
isc_result_t dns_zt_freezezones (dns_zt_t *zt, isc_boolean_t freeze)
 Freeze/thaw updates to master zones. Any pending updates will be flushed. Zones will be reloaded on thaw.
isc_result_t dns_zt_apply (dns_zt_t *zt, isc_boolean_t stop, isc_result_t(*action)(dns_zone_t *, void *), void *uap)
isc_result_t dns_zt_apply2 (dns_zt_t *zt, isc_boolean_t stop, isc_result_t *sub, isc_result_t(*action)(dns_zone_t *, void *), void *uap)
 Apply a given 'action' to all zone zones in the table. If 'stop' is 'ISC_TRUE' then walking the zone tree will stop if 'action' does not return ISC_R_SUCCESS.


Detailed Description

Definition in file zt.c.


Define Documentation

#define ZTMAGIC   ISC_MAGIC('Z', 'T', 'b', 'l')

Definition at line 55 of file zt.c.

Referenced by dns_zt_create().

#define VALID_ZT ( zt   )     ISC_MAGIC_VALID(zt, ZTMAGIC)

Definition at line 56 of file zt.c.

Referenced by asyncload(), dns_zt_apply2(), dns_zt_asyncload(), dns_zt_attach(), dns_zt_find(), dns_zt_freezezones(), dns_zt_load(), dns_zt_loadnew(), dns_zt_mount(), dns_zt_unmount(), doneloading(), and zt_flushanddetach().


Function Documentation

static void auto_detach ( void *  data,
void *  arg 
) [static]

Definition at line 532 of file zt.c.

References dns_zone_detach(), UNUSED, and zone.

static isc_result_t load ( dns_zone_t zone,
void *  uap 
) [static]

Definition at line 264 of file zt.c.

References DNS_R_CONTINUE, DNS_R_UPTODATE, dns_zone_load(), ISC_R_SUCCESS, and UNUSED.

Referenced by ATF_TP_ADD_TCS(), dns_zt_load(), ISC_LIST(), zone_gotreadhandle(), zone_loaddone(), and zone_startload().

static isc_result_t asyncload ( dns_zone_t zone,
void *  callback 
) [static]

Definition at line 308 of file zt.c.

References dns_zone_asyncload(), dns_zone_getview(), INSIST, ISC_R_SUCCESS, dns_zt::loads_pending, dns_zt::references, REQUIRE, VALID_ZT, and dns_view::zonetable.

Referenced by dns_zt_asyncload().

static isc_result_t loadnew ( dns_zone_t zone,
void *  uap 
) [static]

Definition at line 340 of file zt.c.

References DNS_R_CONTINUE, DNS_R_DYNAMIC, DNS_R_UPTODATE, dns_zone_loadnew(), ISC_R_SUCCESS, and UNUSED.

Referenced by dns_zt_loadnew().

static isc_result_t freezezones ( dns_zone_t zone,
void *  uap 
) [static]

Definition at line 366 of file zt.c.

References dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_R_CONTINUE, DNS_R_FROZEN, DNS_R_UPTODATE, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_zone_detach(), dns_zone_flush(), dns_zone_getclass(), dns_zone_getorigin(), dns_zone_getraw(), dns_zone_gettype(), dns_zone_getupdatedisabled(), dns_zone_getview(), dns_zone_isdynamic(), dns_zone_loadandthaw(), dns_zone_master, dns_zone_setupdatedisabled(), ISC_LOG_DEBUG, ISC_LOG_ERROR, isc_log_write(), ISC_R_SUCCESS, isc_result_totext(), ISC_TRUE, and dns_view::name.

Referenced by dns_zt_freezezones().

static isc_result_t doneloading ( dns_zt_t zt,
dns_zone_t zone,
isc_task_t task 
) [static]

Definition at line 493 of file zt.c.

References arg, destroy(), dns_zt_allloaded_t, INSIST, ISC_FALSE, ISC_R_SUCCESS, isc_rwlocktype_write, ISC_TRUE, dns_zt::loaddone, dns_zt::loaddone_arg, dns_zt::loads_pending, dns_zt::references, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, UNUSED, VALID_ZT, and zt_destroy().

Referenced by dns_zt_asyncload().

isc_result_t dns_zt_create ( isc_mem_t mctx,
dns_rdataclass_t  rdclass,
dns_zt_t **  zt 
)

Creates a new zone table.

Requires:

Returns:

Definition at line 77 of file zt.c.

References auto_detach(), dns_rbt_create(), dns_rbt_destroy(), dns_zt::flush, ISC_FALSE, isc_mem_attach(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_rwlock_init(), dns_zt::loaddone, dns_zt::loaddone_arg, dns_zt::loads_pending, dns_zt::magic, dns_zt::mctx, dns_zt::rdclass, dns_zt::references, REQUIRE, dns_zt::rwlock, dns_zt::table, and ZTMAGIC.

Referenced by dns_view_create(), and dns_view_createzonetable().

isc_result_t dns_zt_mount ( dns_zt_t zt,
dns_zone_t zone 
)

Mounts the zone on the zone table.

Requires:

Returns:

Definition at line 119 of file zt.c.

References dns_rbt_addname(), dns_zone_attach(), dns_zone_getorigin(), dummy, ISC_R_SUCCESS, isc_rwlocktype_write, name, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, dns_zt::table, and VALID_ZT.

Referenced by dns_view_addzone().

isc_result_t dns_zt_unmount ( dns_zt_t zt,
dns_zone_t zone 
)

Unmount the given zone from the table.

Requires: 'zt' to be valid

Returns:

Definition at line 140 of file zt.c.

References dns_rbt_deletename(), dns_zone_getorigin(), ISC_FALSE, isc_rwlocktype_write, name, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, dns_zt::table, and VALID_ZT.

Referenced by do_addzone(), do_modzone(), and ns_server_delzone().

isc_result_t dns_zt_find ( dns_zt_t zt,
dns_name_t name,
unsigned int  options,
dns_name_t foundname,
dns_zone_t **  zone 
)

Find the best match for 'name' in 'zt'. If foundname is non NULL then the name of the zone found is returned.

Notes:

Requires: Returns:

Definition at line 158 of file zt.c.

References DNS_R_PARTIALMATCH, dns_rbt_findname(), DNS_RBTFIND_NOEXACT, dns_zone_attach(), DNS_ZTFIND_NOEXACT, dummy, ISC_R_SUCCESS, isc_rwlocktype_read, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, dns_zt::table, and VALID_ZT.

Referenced by dns_view_find2(), dns_view_findzone(), dns_view_findzonecut2(), dns_viewlist_findzone(), do_addzone(), do_modzone(), ns_notify_start(), ns_update_start(), ns_xfr_start(), query_getzonedb(), and zone_from_args().

void dns_zt_attach ( dns_zt_t zt,
dns_zt_t **  ztp 
)

Attach 'zt' to '*ztp'.

Requires:

Definition at line 183 of file zt.c.

References INSIST, isc_rwlocktype_write, dns_zt::references, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, and VALID_ZT.

static isc_result_t flush ( dns_zone_t zone,
void *  uap 
) [static]

Definition at line 200 of file zt.c.

References dns_zone_flush(), and UNUSED.

Referenced by shutdown_server(), and zt_destroy().

static void zt_destroy ( dns_zt_t zt  )  [static]

Definition at line 206 of file zt.c.

References dns_rbt_destroy(), dns_zt_apply(), flush(), dns_zt::flush, ISC_FALSE, isc_mem_putanddetach, isc_rwlock_destroy(), dns_zt::magic, dns_zt::mctx, dns_zt::rwlock, and dns_zt::table.

Referenced by doneloading(), and zt_flushanddetach().

static void zt_flushanddetach ( dns_zt_t **  ztp,
isc_boolean_t  need_flush 
) [static]

Definition at line 216 of file zt.c.

References destroy(), dns_zt::flush, INSIST, ISC_FALSE, isc_rwlocktype_write, ISC_TRUE, dns_zt::references, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, VALID_ZT, and zt_destroy().

Referenced by dns_zt_detach(), and dns_zt_flushanddetach().

void dns_zt_flushanddetach ( dns_zt_t **  ztp  ) 

Detach the given zonetable, if the reference count goes to zero the zonetable will be flushed and then freed. In either case 'ztp' is set to NULL.

Requires:

Definition at line 242 of file zt.c.

References ISC_TRUE, and zt_flushanddetach().

Referenced by view_flushanddetach().

void dns_zt_detach ( dns_zt_t **  ztp  ) 

Detach the given zonetable, if the reference count goes to zero the zonetable will be freed. In either case 'ztp' is set to NULL.

Requires:

Definition at line 247 of file zt.c.

References ISC_FALSE, and zt_flushanddetach().

Referenced by dns_view_create(), and view_flushanddetach().

isc_result_t dns_zt_load ( dns_zt_t zt,
isc_boolean_t  stop 
)

Definition at line 252 of file zt.c.

References dns_zt_apply(), isc_rwlocktype_read, load(), REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, and VALID_ZT.

Referenced by dns_view_load().

isc_result_t dns_zt_asyncload ( dns_zt_t zt,
dns_zt_allloaded_t  alldone,
void *  arg 
)

Load all zones in the table. If 'stop' is ISC_TRUE, stop on the first error and return it. If 'stop' is ISC_FALSE, ignore errors.

dns_zt_loadnew() only loads zones that are not yet loaded. dns_zt_load() also loads zones that are already loaded and and whose master file has changed since the last load. dns_zt_asyncload() loads zones asynchronously; when all zones in the zone table have finished loaded (or failed due to errors), the caller is informed by calling 'alldone' with an argument of 'arg'.

Requires:

Definition at line 276 of file zt.c.

References asyncload(), dns_zt_apply2(), doneloading(), INSIST, ISC_FALSE, isc_rwlocktype_write, dns_zt::loaddone, dns_zt::loaddone_arg, dns_zt::loads_pending, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, and VALID_ZT.

Referenced by dns_view_asyncload(), and start_zt_asyncload().

isc_result_t dns_zt_loadnew ( dns_zt_t zt,
isc_boolean_t  stop 
)

Definition at line 328 of file zt.c.

References dns_zt_apply(), isc_rwlocktype_read, loadnew(), REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, and VALID_ZT.

Referenced by dns_view_loadnew().

isc_result_t dns_zt_freezezones ( dns_zt_t zt,
isc_boolean_t  freeze 
)

Freeze/thaw updates to master zones. Any pending updates will be flushed. Zones will be reloaded on thaw.

Definition at line 352 of file zt.c.

References dns_zt_apply2(), freezezones(), ISC_FALSE, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_rwlocktype_read, REQUIRE, dns_zt::rwlock, RWLOCK, RWUNLOCK, and VALID_ZT.

Referenced by dns_view_freezezones().

isc_result_t dns_zt_apply ( dns_zt_t zt,
isc_boolean_t  stop,
isc_result_t(*)(dns_zone_t *, void *)  action,
void *  uap 
)

Definition at line 433 of file zt.c.

References dns_zt_apply2().

Referenced by add_view_tolist(), ATF_TC_BODY(), dns_view_dialup(), dns_zt_load(), dns_zt_loadnew(), load_configuration(), ns_server_sync(), and zt_destroy().

isc_result_t dns_zt_apply2 ( dns_zt_t zt,
isc_boolean_t  stop,
isc_result_t sub,
isc_result_t(*)(dns_zone_t *, void *)  action,
void *  uap 
)

Apply a given 'action' to all zone zones in the table. If 'stop' is 'ISC_TRUE' then walking the zone tree will stop if 'action' does not return ISC_R_SUCCESS.

Requires:

Returns:

Definition at line 440 of file zt.c.

References cleanup(), dns_rbtnode::data, DNS_R_NEWORIGIN, dns_rbtnodechain_current(), dns_rbtnodechain_first(), dns_rbtnodechain_init(), dns_rbtnodechain_invalidate(), dns_rbtnodechain_next(), ISC_R_NOMORE, ISC_R_NOTFOUND, ISC_R_SUCCESS, dns_zt::mctx, REQUIRE, dns_zt::table, VALID_ZT, and zone.

Referenced by dns_zt_apply(), dns_zt_asyncload(), and dns_zt_freezezones().


Generated on Tue Apr 28 17:41:14 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha