server.c revision f9fa6b9a3bf6efdbb2483b0ac986ccbb6334fc94
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
68116c5a5fd36fef812fc207de3b7714db2994d5Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
68116c5a5fd36fef812fc207de3b7714db2994d5Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
68116c5a5fd36fef812fc207de3b7714db2994d5Evan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
66e50468dde42a9757ac489e738d8b2db8fd7f80Evan Hunt/* $Id: server.c,v 1.259 2000/11/28 19:58:14 mws Exp $ */
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * Check an operation for failure. Assumes that the function
68116c5a5fd36fef812fc207de3b7714db2994d5Evan Hunt * using it has a 'result' variable and a 'cleanup' label.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt } while (0) \
6643b0dd91249ace16218ef667967c87b291992cMark Andrews } while (0) \
68116c5a5fd36fef812fc207de3b7714db2994d5Evan Hunttypedef struct {
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Huntns_server_reload(isc_task_t *task, isc_event_t *event);
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Huntns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsconfigure_forward(dns_c_ctx_t *cctx, dns_c_zone_t *czone, dns_c_view_t *cview,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Configure a single view ACL at '*aclp'. Get its configuration by
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * calling 'getvcacl' (for per-view configuration) and maybe 'getscacl'
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * (for a global default).
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * No value available. *aclp == NULL.
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews result = ns_acl_fromconfig(cacl, cctx, actx, mctx, aclp);
6643b0dd91249ace16218ef667967c87b291992cMark Andrewsconfigure_view_dnsseckey(dns_c_view_t *cview, dns_c_tkey_t *ckey,
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * The key data in keystruct is not
6643b0dd91249ace16218ef667967c87b291992cMark Andrews * dynamically allocated.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt isc_buffer_init(&keydatabuf, keydata, sizeof(keydata));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews CHECK(isc_base64_decodestring(mctx, ckey->pubkey->key,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_add(&namebuf, strlen(ckey->domain));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews CHECK(dst_key_fromdns(keyname, viewclass, &rrdatabuf,
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt "configuring trusted key for '%s': "
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Configure DNSSEC keys for a view. Currently used only for
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * the security roots.
66e50468dde42a9757ac489e738d8b2db8fd7f80Evan Hunt * The per-view configuration values and their server-global
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * defaults are are read from 'cview' and 'cctx' using
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * the function 'cgetv' and 'cgets', respectively.
66e50468dde42a9757ac489e738d8b2db8fd7f80Evan Hunt * The variable to be configured is '*target'.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * Get a dispatch appropriate for the resolver of a given view.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Huntget_view_querysource_dispatch(dns_c_ctx_t *cctx, dns_c_view_t *cview,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Make compiler happy.
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews result = dns_c_view_getquerysource(cview, &sa);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews result = dns_c_view_getquerysourcev6(cview, &sa);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews result = dns_c_ctx_getquerysourcev6(cctx, &sa);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * If we don't support this address family, we're done!
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Try to find a dispatcher that we can share.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt result = dns_dispatch_getudp(ns_g_dispatchmgr, ns_g_socketmgr,
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt "could not get query source dispatcher");
6643b0dd91249ace16218ef667967c87b291992cMark Andrews * Configure 'view' according to 'cview', taking defaults from 'cctx'
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * where values are missing in cview.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * When configuring the default view, cview will be NULL and the
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Hunt * global defaults in cctx used exclusively.
56c9fcf07580457442b80ac32bdb7c07aa0df870Evan Huntconfigure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_view_t *pview = NULL; /* Production view */
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Set the view's port number for outgoing queries.
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Attach load manager to view.
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_view_setloadmgr(view, ns_g_server->loadmgr);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * Configure the view's cache. Try to reuse an existing
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews * cache if possible, otherwise create a new cache.
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * Note that the ADB is not preserved in either case.
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * XXX Determining when it is safe to reuse a cache is
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * tricky. When the view's configuration changes, the cached
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * data may become invalid because it reflects our old
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * view of the world. As more view attributes become
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * configurable, we will have to add code here to check
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * whether they have changed in ways that could
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews * invalidate the cache.
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews result = dns_viewlist_find(&ns_g_server->viewlist,
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews "reusing existing cache");
9b956d342e93ab60d5d9367785b26546f7e49391Mark Andrews CHECK(dns_cache_create(cmctx, ns_g_taskmgr, ns_g_timermgr,
max_cache_size = 0;
max_cache_size = 0;
&dispatch4));
&dispatch6));
0, ns_g_dispatchmgr,
goto cleanup;
return (result);
static isc_result_t
return (result);
static isc_result_t
char *versiontext;
isc_region_t r;
return (result);
static isc_result_t
static const char *authors[] = {
NULL,
return (result);
static isc_result_t
return (result);
static isc_result_t
if (ns_g_port != 0) {
goto cleanup;
goto cleanup;
return (result);
static isc_result_t
const char *viewname;
return (result);
return (ISC_R_SUCCESS);
return (result);
return (result);
return (ISC_R_SUCCESS);
* is called after parsing each "zone" statement in named.conf.
static isc_result_t
void *uap)
char *corigin;
goto cleanup;
corigin);
goto cleanup;
corigin);
goto cleanup;
goto cleanup;
goto cleanup;
&pview);
goto cleanup;
goto cleanup;
return (result);
static isc_result_t
return (result);
return (ISC_R_SUCCESS);
int len;
static isc_result_t
union { char *nc;
return (result);
static isc_result_t
return (result);
for (i = 0; i < DNS_ZONE_COUNTSIZE; i++)
value); \
static isc_result_t
char *pidfilename;
char *statsfilename;
filename);
&callbacks);
if (ns_g_port != 0) {
cctx,
&listenon);
} else if (!ns_g_lwresdonly) {
listenon);
cctx,
&listenon);
} else if (!ns_g_lwresdonly) {
listenon);
if (interface_interval == 0) {
if (heartbeat_interval == 0) {
&aclconfctx));
goto cleanup;
if (first_time)
* files specified in named.conf get created by the
if (ns_g_logstderr) {
else if (ns_g_lwresdonly)
return (result);
static isc_result_t
return (result);
if (ns_g_lwresdonly)
ISC_TRUE),
if (flush)
sizeof(isc_event_t));
if (ns_g_lwresdonly)
char *res;
return (res);
static isc_result_t
switch (ptr[0]) {
goto fail1;
goto fail1;
zone);
goto fail2;
return (result);
return (result);
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (result);
return (result);
return (ISC_R_SUCCESS);
char *viewname;
int numbercounters;
return (result);
(long)now);
for (i = 0; i < numbercounters; i++)
for (i = 0; i < numbercounters; i++)
return (ISC_R_SUCCESS);