server.c revision 2e097e67d87630bbefb5c1b0bea6f1bc8b2ec86d
ee980d3fc4c23b7f87fed96d3ba5e928937c9ed4Tinderbox User * Copyright (C) 1999, 2000 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
83f8c56f43852bf9a9c6964eae285284b23f9d8dMichael Graff * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews * Check an operation for failure. Assumes that the function
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews * using it has a 'result' variable and a 'cleanup' label.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein } while (0) \
46993e1d9d18410a5852b7d990338b70b158855cMichael Grafftypedef struct {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinstatic void fatal(char *msg, isc_result_t result);
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Huntstatic void ns_server_reload(isc_task_t *task, isc_event_t *event);
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Huntns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_mem_t *mctx, ns_listenelt_t **target);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_mem_t *mctx, ns_listenlist_t **target);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure a single view ACL at '*aclp'. Get its configuration by
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * calling 'getvcacl' (for per-view configuration) and maybe 'getscacl'
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * (for a global default).
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (dns_c_view_t *, dns_c_ipmatchlist_t **),
a8dcebd0419f27234664e89b9cd48bc54cad08a7Michael Graff /* No value available. *aclp == NULL. */
83f8c56f43852bf9a9c6964eae285284b23f9d8dMichael Graff result = dns_acl_fromconfig(cacl, cctx, actx, mctx, aclp);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure 'view' according to 'cctx'.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6)
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_view_t *pview = NULL; /* Production view */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 unsigned int i;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 RWLOCK(&view->conflock, isc_rwlocktype_write);
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * Configure the view's cache. Try to reuse an existing
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * cache if possible, otherwise create a new cache.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Note that the ADB is not preserved in either case.
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * XXX Determining when it is safe to reuse a cache is
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * tricky. When the view's configuration changes, the cached
83f8c56f43852bf9a9c6964eae285284b23f9d8dMichael Graff * data may become invalid because it reflects our old
ab0e5066083abcbec62513a3cc041d1f1eb9098aMichael Graff * view of the world. As more view attributes become
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * configurable, we will have to add code here to check
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * whether they have changed in ways that could
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * invalidate the cache.
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews result = dns_viewlist_find(&ns_g_server->viewlist,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_cache_create(mctx, ns_g_taskmgr, ns_g_timermgr,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 cleaning_interval = 3600; /* Default is 1 hour. */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_getcleaninterval(cctx, &cleaning_interval);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_cache_setcleaninginterval(cache, cleaning_interval);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * XXXRTH Temporary support for loading cache contents.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_db_load(view->cachedb, ns_g_cachefile));
83f8c56f43852bf9a9c6964eae285284b23f9d8dMichael Graff * XXXRTH Hardwired number of tasks.
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt CHECK(dns_view_createresolver(view, ns_g_taskmgr, 31,
ca9739800f045cd4d39014f98b920d4354b5bd14Michael Graff * Set resolver forwarding policy.
ce5bd92088923d1c76e26d313d1d8c0b8bbe38feMichael Graff if (dns_c_ctx_getforwarders(cctx, &forwarders) == ISC_R_SUCCESS) {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * Ugh. Convert between list formats.
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews CHECK(dns_resolver_setforwarders(view->resolver, &addresses));
83f8c56f43852bf9a9c6964eae285284b23f9d8dMichael Graff * XXXRTH The configuration type 'dns_c_forw_t' should be
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews if (dns_c_ctx_getforward(cctx, &forward) == ISC_R_SUCCESS) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_resolver_setfwdpolicy(view->resolver, fwdpolicy));
a8dcebd0419f27234664e89b9cd48bc54cad08a7Michael Graff * We have default hints for class IN if we need them.
ca9739800f045cd4d39014f98b920d4354b5bd14Michael Graff if (view->rdclass == dns_rdataclass_in && view->hints == NULL)
a8dcebd0419f27234664e89b9cd48bc54cad08a7Michael Graff dns_view_sethints(view, ns_g_server->in_roothints);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * If we still have no hints, this is a non-IN view with no
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * "hints zone" configured. That's an error.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "no root hints for view '%s'", cview->name);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure the view's TSIG keys.
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff CHECK(dns_tsigkeyring_fromconfig(cctx, view->mctx, &ring));
35f06ab0e6d5ad26176b7584de7b4d405272ba68Brian Wellington * Configure the view's peer list.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_peerlist_attach(cctx->peers, &newpeers);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_peerlist_new(mctx, &newpeers));
0a9fedafec59fd3ec2eeadc3f123db163e71c0fbMichael Graff view->peers = newpeers; /* Transfer ownership. */
d8c2b1787119de43dd6b7e3927ff193ed5df682fMark Andrews * Configure the "match-clients" ACL.
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews CHECK(configure_view_acl(cview, cctx, actx, ns_g_mctx,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure other configurable data.
f07b2fccaf6be13d9440d323e9e79ee84fe345e2Evan Hunt (void) dns_c_ctx_getrecursion(cctx, &view->recursion);
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff (void) dns_c_view_getrecursion(cview, &view->recursion);
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff view->auth_nxdomain = ISC_FALSE; /* Was true in BIND 8 */
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff (void) dns_c_ctx_getauthnxdomain(cctx, &view->auth_nxdomain);
f07b2fccaf6be13d9440d323e9e79ee84fe345e2Evan Hunt (void) dns_c_view_getauthnxdomain(cview, &view->auth_nxdomain);
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff (void) dns_c_ctx_gettransferformat(cctx, &view->transfer_format);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_view_gettransferformat(cview, &view->transfer_format);
8affb49a70de247206cb04aae87730f2b4c90dd0Mark Andrews CHECK(configure_view_acl(cview, cctx, actx, ns_g_mctx,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(configure_view_acl(cview, cctx, actx, ns_g_mctx,
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson RWUNLOCK(&view->conflock, isc_rwlocktype_write);
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff * Create the special view that handles queries for
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff * "version.bind. CH". The version string returned is that
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff * configured in 'configctx', or a compiled-in default if
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff * there is no "version" configuration option.
870a748bae74b9c4b264da96cfbcb4e90d7a2c1dMark Andrewscreate_version_view(dns_c_ctx_t *configctx, dns_view_t **viewp) {
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff static unsigned char origindata[] = "\007version\004bind";
20c266cbc999c724e03e6edd437fb4181b92f095Michael Graff (void) dns_c_ctx_getversion(configctx, &versiontext);
20c266cbc999c724e03e6edd437fb4181b92f095Michael Graff dns_rdata_fromregion(&rdata, dns_rdataclass_ch, dns_rdatatype_txt, &r);
f6579931b38b357013736ce3efc79a34480af5ceBrian Wellington CHECK(dns_db_create(ns_g_mctx, "rbt", &origin, ISC_FALSE,
20c266cbc999c724e03e6edd437fb4181b92f095Michael Graff CHECK(dns_difftuple_create(ns_g_mctx, DNS_DIFFOP_ADD, &origin,
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff CHECK(dns_view_create(ns_g_mctx, dns_rdataclass_ch, "_version",
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff CHECK(dns_zone_replacedb(zone, db, ISC_FALSE));
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 /* Transfer ownership. */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_db_closeversion(db, &dbver, ISC_FALSE);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉configure_hints(dns_view_t *view, const char *filename) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = dns_rootns_create(view->mctx, view->rdclass, filename, &db);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Find an existing view matching the name and class of 'cview'
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * in 'viewlist', or create a new one and add it to the list.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * If 'cview' is NULL, find or create the default view.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * The view found or created is attached to '*viewp'.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉find_or_create_view(dns_c_view_t *cview, dns_viewlist_t *viewlist,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = dns_c_view_getviewclass(cview, &viewclass);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = dns_view_create(ns_g_mctx, viewclass, viewname, &view);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure or reconfigure a zone. This callback function
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * is called after parsing each "zone" statement in named.conf.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉configure_zone(dns_c_ctx_t *cctx, dns_c_zone_t *czone, dns_c_view_t *cview,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_view_t *pview = NULL; /* Production view */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_zone_t *zone = NULL; /* New or reused zone */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_zone_t *tzone = NULL; /* Temporary zone */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Get the zone origin as a dns_name_t.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 /* XXX casting away const */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_c_zone_getname(czone, (const char **) &corigin));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_buffer_init(&buffer, corigin, strlen(corigin),
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_buffer_add(&buffer, strlen(corigin));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(dns_name_fromtext(dns_fixedname_name(&fixorigin),
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 &buffer, dns_rootname, ISC_FALSE, NULL));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Find or create the view in the new view list.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(find_or_create_view(cview, &lctx->viewlist, &view));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "zone '%s': wrong class for view '%s'",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 corigin, cview ? cview->name : "<default view>");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * Master zones must have 'file' set.
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "zone '%s': 'file' not specified",
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * "hints zones" aren't zones. If we've got one,
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * configure it and return.
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "zone '%s': 'file' not specified",
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 if (dns_name_equal(origin, dns_rootname)) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 result = configure_hints(view, czone->u.hzone.file);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "ignoring non-root hint zone '%s'",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * "stub zones" aren't zones either. Eventually we'll
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * create a "cache freshener" to keep the stub data in the
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "stub zone '%s': stub zones are not supported in this release",
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * "forward zones" aren't zones either. Eventually we'll
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * translate this syntax into the appropriate selective forwarding
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * configuration.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if (czone->ztype == dns_c_zone_forward) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff "forward zone '%s': forward zones are not supported in this release",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Check for duplicates in the new zone table.
0941f35ad9b4f48a5324af405a730c3cb3e0aad8Michael Graff result = dns_view_findzone(view, origin, &tzone);
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews * We already have this zone!
3530e10080e5a7d95c7d13abdc02c1d8bd12ec18Andreas Gustafsson * See if we can reuse an existing zone. This is
3530e10080e5a7d95c7d13abdc02c1d8bd12ec18Andreas Gustafsson * only possible if all of these are true:
3530e10080e5a7d95c7d13abdc02c1d8bd12ec18Andreas Gustafsson * - The zone's view exists
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * - A zone with the right name exists in the view
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews * - The zone is compatible with the config
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * options (e.g., an existing master zone cannot
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * be reused if the options specify a slave zone)
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff result = dns_viewlist_find(&ns_g_server->viewlist,
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff result = dns_view_findzone(pview, origin, &zone);
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
3530e10080e5a7d95c7d13abdc02c1d8bd12ec18Andreas Gustafsson * If we cannot reuse an existing zone, we will have to
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * create a new one.
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff CHECK(dns_zonemgr_managezone(ns_g_server->zonemgr,
c17c59662f0969a5e52e8b7529cbde1a7c746095Andreas Gustafsson * Configure the zone.
a7c76f1924d5fc914c579fd3b0276ffbddd2f65aMark Andrews CHECK(dns_zone_configure(cctx, cview, czone, lctx->aclconf, zone));
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * Add the zone to its view in the new view list.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure a single server quota.
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff isc_result_t (*getquota)(dns_c_ctx_t *, isc_int32_t *),
46993e1d9d18410a5852b7d990338b70b158855cMichael Graffconfigure_server_querysource(dns_c_ctx_t *cctx, ns_server_t *server, int af,
35f06ab0e6d5ad26176b7584de7b4d405272ba68Brian Wellington * Make compiler happy.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = dns_c_ctx_getquerysourcev6(cctx, &sa);
35f06ab0e6d5ad26176b7584de7b4d405272ba68Brian Wellington * If we don't support this address family, we're done!
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * The query source is fully wild. No special dispatcher
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * work needs to be done.
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * If the interface manager has a dispatcher for this address,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews server_dispatchp = &server->querysrc_dispatchv4;
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews server_dispatchaddr = &server->querysrc_addressv4;
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews server_dispatchp = &server->querysrc_dispatchv6;
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews server_dispatchaddr = &server->querysrc_addressv6;
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews if (ns_interfacemgr_findudpdispatcher(server->interfacemgr, &sa,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * The interface manager doesn't have a matching dispatcher.
cfc22e53a89ccac4eb04b4f41a93f73e629e80edEvan Hunt * We've already got a custom dispatcher. If it is
cfc22e53a89ccac4eb04b4f41a93f73e629e80edEvan Hunt * compatible with the new configuration, use it.
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * The existing custom dispatcher is not compatible.
cfc22e53a89ccac4eb04b4f41a93f73e629e80edEvan Hunt * We don't need it anymore.
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt * Create a custom dispatcher.
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 result = dns_dispatch_create(ns_g_mctx, socket,
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * Regardless of whether dns_dispatch_create() succeeded or
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * failed, we don't need to keep the reference to the socket.
2b2fc9b4df2db5686126c9eb56973b0af0c109e5Automatic Updater dns_dispatch_attach(*server_dispatchp, dispatchp);
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * We're sharing a UDP dispatcher with the interface manager
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * now. Any prior custom dispatcher can be discarded.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * This function is called as soon as the 'options' statement has been
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉options_callback(dns_c_ctx_t *cctx, void *uap) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Change directory.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = isc_dir_chdir(cctx->options->directory);
089f456eb39d614cb6904107d4a9580ed4f3f296Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "to '%s' failed: %s",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ns_interfacemgr_scan(server->interfacemgr);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ns_interfacemgr_getaclenv(server->interfacemgr));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * This event callback is invoked to do periodic network
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * interface scanning.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉interface_timer_tick(isc_task_t *task, isc_event_t *event) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ns_server_t *server = (ns_server_t *) event->arg;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 RWLOCK(&server->conflock, isc_rwlocktype_write);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 RWUNLOCK(&server->conflock, isc_rwlocktype_write);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉load_configuration(const char *filename, ns_server_t *server,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 RWLOCK(&server->conflock, isc_rwlocktype_write);
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt dns_zonemgr_lockconf(server->zonemgr, isc_rwlocktype_write);
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews ISC_LOG_INFO, "loading configuration from '%s'",
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * Parse the configuration file creating a parse tree. Any
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * 'zone' statements are handled immediately by calling
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * configure_zone() through 'callbacks'.
9cf04a12ec5ea0ee64338feef76e885980a524dfMark Andrews CHECK(dns_c_parse_namedconf(filename, ns_g_mctx, &configctx,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews * Configure various server options.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 configure_server_quota(configctx, dns_c_ctx_gettransfersout,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 configure_server_quota(configctx, dns_c_ctx_gettcpclients,
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 configure_server_quota(configctx, dns_c_ctx_getrecursiveclients,
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt (void) dns_c_ctx_getprovideixfr(configctx, &server->provide_ixfr);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure the zone manager.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_gettransfersin(configctx, &transfersin);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_zonemgr_settransfersin(server->zonemgr, transfersin);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_gettransfersperns(configctx, &transfersperns);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_zonemgr_settransfersperns(server->zonemgr, transfersperns);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_getrequestixfr(configctx, &requestixfr);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 dns_zonemgr_setrequestixfr(server->zonemgr, requestixfr);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure the interface manager according to the "listen-on"
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_getlistenlist(configctx, &clistenon);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = ns_listenlist_fromconfig(clistenon,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 /* Not specified, use default. */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(ns_listenlist_default(ns_g_mctx, ns_g_port,
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 ns_interfacemgr_setlistenon(server->interfacemgr, listenon);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Rescan the interface list to pick up changes in the
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * listen-on option. It's important that we do this before we try
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * to configure the query source, since the dispatcher we use might
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * be shared with an interface.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Arrange for further interface scanning to occur periodically
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * as specified by the "interface-interval" option.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 interface_interval = 3600; /* Default is 1 hour. */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 (void) dns_c_ctx_getinterfaceinterval(configctx, &interface_interval);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_interval_set(&interval, interface_interval, 0);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_timer_reset(server->interface_timer, isc_timertype_ticker,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECK(configure_server_querysource(configctx, server,
96b3cb85d3b06d99323a6ea7ae04f4eb3d74e8bcMark Andrews CHECK(configure_server_querysource(configctx, server,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Configure and freeze the views.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 * Views that have zones were already created at parsing
34350037a886e7a16728335821da2bbff95683a9Evan Hunt * time, but views with no zones must be created here.
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 for (cview = ISC_LIST_HEAD(configctx->views->views);
34350037a886e7a16728335821da2bbff95683a9Evan Hunt CHECK(configure_view(view, configctx, cview, ns_g_mctx,
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * If we haven't created any views, create and configure
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 * a default view for class IN. (We're a caching-only server.)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 CHECKM(dns_view_create(ns_g_mctx, dns_rdataclass_in,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "creating default view");
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 ISC_LIST_APPEND(lctx.viewlist, view, link);
3530e10080e5a7d95c7d13abdc02c1d8bd12ec18Andreas Gustafsson view = NULL; /* Ownership transferred to list. */
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff * Create (or recreate) the version view.
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 * Swap our new view list with the production one.
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff * Load the TKEY information from the configuration.
3d181bc9f12154a56bfbb536198a6c481cbcd525David Lawrence CHECKM(dns_tkeyctx_fromconfig(configctx, ns_g_mctx, &t),
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt "configuring TKEY");
8affb49a70de247206cb04aae87730f2b4c90dd0Mark Andrews * Configure the logging system.
8affb49a70de247206cb04aae87730f2b4c90dd0Mark Andrews "ignoring named.conf logging statement "
8affb49a70de247206cb04aae87730f2b4c90dd0Mark Andrews "due to -g option");
c6066a8e67f40c7c12925c5634485f55713c06d6Michael Graff CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
c6066a8e67f40c7c12925c5634485f55713c06d6Michael Graff "creating new logging configuration");
c6066a8e67f40c7c12925c5634485f55713c06d6Michael Graff (void) dns_c_ctx_getlogging(configctx, &clog);
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff "configuring logging");
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt "setting up default logging defaults");
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt CHECKM(result, "intalling logging configuration");
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt if (dns_c_ctx_getpidfilename(configctx, &pidfilename) ==
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt * This cleans up either the old production view list
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt * or our temporary list depending on whether they
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt * were swapped above or not.
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt dns_zonemgr_unlockconf(server->zonemgr, isc_rwlocktype_write);
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt RWUNLOCK(&server->conflock, isc_rwlocktype_write);
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Huntload_zones(ns_server_t *server, isc_boolean_t stop) {
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt dns_zonemgr_lockconf(server->zonemgr, isc_rwlocktype_read);
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * Load zone data from disk.
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * Force zone maintenance. Do this after loading
54489ba1672458382e8dfb5490fcfc7230f8ea85Evan Hunt * so that we know when we need to force AXFR of
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff * slave zones whose master files are missing.
ce10da99834b806d5a92a6e5b4c8ff3990a4ae0fBrian Wellington dns_zonemgr_unlockconf(server->zonemgr, isc_rwlocktype_read);
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graffrun_server(isc_task_t *task, isc_event_t *event) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ns_server_t *server = (ns_server_t *) event->arg;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECKFATAL(ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "creating client manager");
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECKFATAL(ns_interfacemgr_create(ns_g_mctx, ns_g_taskmgr,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "creating interface manager");
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECKFATAL(isc_timer_create(ns_g_timermgr, isc_timertype_inactive,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "creating interface timer");
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff CHECKFATAL(load_configuration(ns_g_conffile, server, ISC_TRUE),
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff "loading configuration");
e992af4209b737f511b6f2fad3ddb7bdfc17b9aeTatuya JINMEI 神明達哉 "loading zones");
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graff isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
1ec39fc7a8b6ad92de3363d4c50b75e24fcd6accMichael Graffshutdown_server(isc_task_t *task, isc_event_t *event) {
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff ns_server_t *server = (ns_server_t *) event->arg;
6f1422b81ed2c5142092e2ced8e3faf0e61f3ba0Michael Graff RWLOCK(&server->conflock, isc_rwlocktype_write);
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff dns_dispatch_detach(&server->querysrc_dispatchv4);
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff dns_dispatch_detach(&server->querysrc_dispatchv6);
46993e1d9d18410a5852b7d990338b70b158855cMichael Graff ns_interfacemgr_shutdown(server->interfacemgr);
20c266cbc999c724e03e6edd437fb4181b92f095Michael Graff ns_interfacemgr_detach(&server->interfacemgr);
e992af4209b737f511b6f2fad3ddb7bdfc17b9aeTatuya JINMEI 神明達哉 RWUNLOCK(&server->conflock, isc_rwlocktype_write);
35f06ab0e6d5ad26176b7584de7b4d405272ba68Brian Wellingtonns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ns_server_t *server = isc_mem_get(mctx, sizeof(*server));
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 fatal("allocating server object", ISC_R_NOMEMORY);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 CHECKFATAL(isc_rwlock_init(&server->conflock, 1, 1),
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "initializing server configuration lock");
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 /* Initialize configuration data with default values. */
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = isc_quota_init(&server->xfroutquota, 10);
6da50be4364a17cdcd14095c0110aaa6a0566178Bob Halley result = isc_quota_init(&server->recursionquota, 100);
35f06ab0e6d5ad26176b7584de7b4d405272ba68Brian Wellington /* Initialize server data structures. */
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 CHECKFATAL(dns_rootns_create(mctx, dns_rdataclass_in, NULL,
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 "setting up root hints");
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 CHECKFATAL(isc_mutex_init(&server->reload_event_lock),
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 "initializing reload event lock");
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 CHECKFATAL(server->reload_event == NULL ?
61facaae4eb15535e1b0cebf007500551874f133Mark Andrews "allocating reload event");
2f76108082f11d4979048f1c22602391c5733c88Tatuya JINMEI 神明達哉 CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, &server->tkeyctx),
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "creating TKEY context");
135b1206c96d03353ac59fde7be0053dacc6568eAndreas Gustafsson * Setup the server task, which is responsible for coordinating
135b1206c96d03353ac59fde7be0053dacc6568eAndreas Gustafsson * startup and shutdown of the server.
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff CHECKFATAL(isc_task_create(ns_g_taskmgr, ns_g_mctx, 0, &server->task),
135b1206c96d03353ac59fde7be0053dacc6568eAndreas Gustafsson "creating server task");
135b1206c96d03353ac59fde7be0053dacc6568eAndreas Gustafsson isc_task_setname(server->task, "server", server);
135b1206c96d03353ac59fde7be0053dacc6568eAndreas Gustafsson CHECKFATAL(isc_task_onshutdown(server->task, shutdown_server, server),
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff "isc_task_onshutdown");
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graff CHECKFATAL(isc_app_onrun(ns_g_mctx, server->task, run_server, server),
e21d199dca95aff5d50f133d6b064309e209af00Brian Wellington "isc_app_onrun");
8ed67113ec802546179294a682581faa75e890c9Andreas Gustafsson * Create a timer for periodic interface scanning.
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews CHECKFATAL(dns_zonemgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
e21d199dca95aff5d50f133d6b064309e209af00Brian Wellington "dns_zonemgr_create");
e21d199dca95aff5d50f133d6b064309e209af00Brian Wellington REQUIRE(server->querysrc_dispatchv4 == NULL);
e21d199dca95aff5d50f133d6b064309e209af00Brian Wellington REQUIRE(server->querysrc_dispatchv6 == NULL);
ab0e5066083abcbec62513a3cc041d1f1eb9098aMichael Graff isc_mem_put(server->mctx, server, sizeof(*server));
d8c2b1787119de43dd6b7e3927ff193ed5df682fMark Andrews isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 ISC_LOG_CRITICAL, "exiting (due to fatal error)");
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉ns_server_reload(isc_task_t *task, isc_event_t *event) {
e2fe1fda755f24f593406dc26fed87e8ea1bb502Tatuya JINMEI 神明達哉 ns_server_t *server = (ns_server_t *)event->arg;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 result = load_configuration(ns_g_conffile, server, ISC_FALSE);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 "reloading configuration failed: %s",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
f19e6ef1eb7d5abf547fc1af24e561bdc5d75b22Mark Andrews "reloading zones failed: %s",
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews isc_task_send(server->task, &server->reload_event);
a295fbb55cfed38bcf2853c60410cce52ab6cebbMark Andrewsns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
a295fbb55cfed38bcf2853c60410cce52ab6cebbMark Andrews result = ns_listenelt_fromconfig(ce, cctx, actx, mctx, &delt);
d8c2b1787119de43dd6b7e3927ff193ed5df682fMark Andrews * Create a listen list from the corresponding configuration
d8c2b1787119de43dd6b7e3927ff193ed5df682fMark Andrews * data structure.
8d1943e8ffa991d54c5406342e44d7134762e7eaMichael Graffns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
8affb49a70de247206cb04aae87730f2b4c90dd0Mark Andrews result = ns_listenelt_create(mctx, celt->port, NULL, &delt);