server.c revision 80cc19dc262cead5a8af41838ebfae5a6e587605
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Copyright (C) 1999-2003 Internet Software Consortium.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Permission to use, copy, modify, and distribute this software for any
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * purpose with or without fee is hereby granted, provided that the above
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * copyright notice and this permission notice appear in all copies.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * PERFORMANCE OF THIS SOFTWARE.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington/* $Id: server.c,v 1.421 2004/04/10 05:03:27 marka Exp $ */
d2524f38d22998efb4196410643280b14f8b6febBob Halley * Check an operation for failure. Assumes that the function
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * using it has a 'result' variable and a 'cleanup' label.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (result != ISC_R_SUCCESS) goto cleanup; \
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington } while (0) \
1fd4766e5b732c04c06ef44c0338b3b6bdbf2457Brian Wellington } while (0) \
183d6e8b51170e57e7268120d475927fffcf08a5Brian Wellington } while (0) \
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellingtonfatal(const char *msg, isc_result_t result);
b6666e61dc9b91f4ac6af3aa1172bfd8a5f2d6ffBrian Wellingtonns_server_reload(isc_task_t *task, isc_event_t *event);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonns_listenelt_fromconfig(cfg_obj_t *listener, cfg_obj_t *config,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington isc_mem_t *mctx, ns_listenlist_t **target);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonconfigure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington cfg_obj_t *forwarders, cfg_obj_t *forwardtype);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellingtonconfigure_alternates(cfg_obj_t *config, dns_view_t *view,
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellingtonconfigure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellingtonend_reserved_dispatches(ns_server_t *server, isc_boolean_t all);
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington * Configure a single view ACL at '*aclp'. Get its configuration by
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington * calling 'getvcacl' (for per-view configuration) and maybe 'getscacl'
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * (for a global default).
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellingtonconfigure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config,
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington const char *aclname, ns_aclconfctx_t *actx,
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington maps[i++] = cfg_tuple_get(vconfig, "options");
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington (void)cfg_map_get(config, "options", &options);
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington result = ns_config_get(maps, aclname, &aclobj);
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington * No value available. *aclp == NULL.
d0345e08f26267c1d11e02af57a6555868068415Brian Wellington result = ns_acl_fromconfig(aclobj, config, actx, mctx, aclp);
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellingtonconfigure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington flags = cfg_obj_asuint32(cfg_tuple_get(key, "flags"));
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington proto = cfg_obj_asuint32(cfg_tuple_get(key, "protocol"));
d692d9991a731d60b63e6389da1ebf2b2839cfabBrian Wellington alg = cfg_obj_asuint32(cfg_tuple_get(key, "algorithm"));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington keynamestr = cfg_obj_asstring(cfg_tuple_get(key, "name"));
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington cfg_obj_t *classobj = cfg_tuple_get(vconfig, "class");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(ns_config_getclass(classobj, dns_rdataclass_in,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence keystruct.common.rdtype = dns_rdatatype_dnskey;
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington * The key data in keystruct is not dynamically allocated.
58aaab3687aac838542ee4ef65a9c094a5d34ab0Michael Graff isc_buffer_init(&keydatabuf, keydata, sizeof(keydata));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington keystr = cfg_obj_asstring(cfg_tuple_get(key, "key"));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington CHECK(isc_base64_decodestring(keystr, &keydatabuf));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_init(&namebuf, keynamestr, strlen(keynamestr));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington isc_buffer_add(&namebuf, strlen(keynamestr));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington CHECK(dst_key_fromdns(keyname, viewclass, &rrdatabuf,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(dns_keytable_add(keytable, &dstkey));
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington "ignoring trusted key for '%s': no crypto support",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington "configuring trusted key for '%s': %s",
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington * Configure DNSSEC keys for a view. Currently used only for
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington * the security roots.
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington * The per-view configuration values and the server-global defaults are read
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellington * from 'vconfig' and 'config'. The variable to be configured is '*target'.
d84ce5d5c69a7e144fb90fd4b3c349e88e4dcdddBrian Wellingtonconfigure_view_dnsseckeys(cfg_obj_t *vconfig, cfg_obj_t *config,
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington voptions = cfg_tuple_get(vconfig, "options");
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void)cfg_map_get(voptions, "trusted-keys", &keys);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void)cfg_map_get(config, "trusted-keys", &keys);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington *target = keytable; /* Transfer ownership. */
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington * Get a dispatch appropriate for the resolver of a given view.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellingtonget_view_querysource_dispatch(cfg_obj_t **maps,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Make compiler happy.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "query-source", &obj);
83e4218f6c6497eeaec7fb422b5f662cd98b2ba6David Lawrence result = ns_config_get(maps, "query-source-v6", &obj);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * If we don't support this address family, we're done!
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington * Try to find a dispatcher that we can share.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = dns_dispatch_getudp(ns_g_dispatchmgr, ns_g_socketmgr,
2c12fc4d63f1d5f9d55fc0ecb198d582da6fd7d3Brian Wellington isc_sockaddr_format(&sa, buf, sizeof(buf));
c3a4d8072ccd3b33aa3fc84cdeadd1a6fac87e08Michael Graff isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
0dc4e6a6aef01175b8cdd71cb757f09ba1e69c49Brian Wellington "could not get query source dispatcher (%s)",
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellingtonconfigure_order(dns_order_t *order, cfg_obj_t *ent) {
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington unsigned int mode = 0;
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington result = ns_config_getclass(cfg_tuple_get(ent, "class"),
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_gettype(cfg_tuple_get(ent, "type"),
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = dns_name_fromtext(dns_fixedname_name(&fixed), &b,
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington return (dns_order_add(order, dns_fixedname_name(&fixed),
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellingtonconfigure_peer(cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
7e8dd00fce7057d1da8158b65395a09ced43a892Brian Wellington sa = cfg_obj_assockaddr(cfg_map_getname(cpeer));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(dns_peer_setbogus(peer, cfg_obj_asboolean(obj)));
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington (void)cfg_map_get(cpeer, "provide-ixfr", &obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington CHECK(dns_peer_setprovideixfr(peer, cfg_obj_asboolean(obj)));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(cpeer, "request-ixfr", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(dns_peer_setrequestixfr(peer, cfg_obj_asboolean(obj)));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(dns_peer_setsupportedns(peer, cfg_obj_asboolean(obj)));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(cpeer, "transfers", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(dns_peer_settransfers(peer, cfg_obj_asuint32(obj)));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(cpeer, "transfer-format", &obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington else if (strcasecmp(str, "one-answer") == 0)
05b6b2e6802d503a9e131415b4720f35ab9f08d1Brian Wellington result = dns_peer_setkeybycharp(peer, cfg_obj_asstring(obj));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(cpeer, "transfer-source", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(cpeer, "transfer-source-v6", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtondisable_algorithms(cfg_obj_t *disabled, dns_resolver_t *resolver) {
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington str = cfg_obj_asstring(cfg_tuple_get(disabled, "name"));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence CHECK(dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence algorithms = cfg_tuple_get(disabled, "algorithms");
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington r.base = cfg_obj_asstring(cfg_listelt_value(element));
0f0162e6297ddf5e4abe848d27f3bcdb373189daBrian Wellington "invalid algorithm");
7077846f3bf941f626a8623bd29a56a5ce7a1e11Brian Wellington CHECK(dns_resolver_disable_algorithm(resolver, name, alg));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Configure 'view' according to 'vconfig', taking defaults from 'config'
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * where values are missing in 'vconfig'.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * When configuring the default view, 'vconfig' will be NULL and the
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * global defaults in 'config' used exclusively.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellingtonconfigure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_view_t *pview = NULL; /* Production view */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence unsigned int check = 0;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void)cfg_map_get(config, "options", &options);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington voptions = cfg_tuple_get(vconfig, "options");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Set the view's port number for outgoing queries.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECKM(ns_config_getport(config, &port), "port");
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence * Configure the zones.
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence (void)cfg_map_get(voptions, "zone", &zonelist);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington (void)cfg_map_get(config, "zone", &zonelist);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington cfg_obj_t *zconfig = cfg_listelt_value(element);
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence CHECK(configure_zone(config, zconfig, vconfig, mctx, view,
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence * Configure the view's cache. Try to reuse an existing
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * cache if possible, otherwise create a new cache.
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington * Note that the ADB is not preserved in either case.
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence * XXX Determining when it is safe to reuse a cache is
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence * tricky. When the view's configuration changes, the cached
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * data may become invalid because it reflects our old
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * view of the world. As more view attributes become
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * configurable, we will have to add code here to check
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * whether they have changed in ways that could
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * invalidate the cache.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = dns_viewlist_find(&ns_g_server->viewlist,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
83e4218f6c6497eeaec7fb422b5f662cd98b2ba6David Lawrence isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
83e4218f6c6497eeaec7fb422b5f662cd98b2ba6David Lawrence "reusing existing cache");
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence CHECK(dns_cache_create(cmctx, ns_g_taskmgr, ns_g_timermgr,
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington * cache-file cannot be inherited if views are present, but this
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington * should be caught by the configuration checking stage.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "cache-file", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington if (result == ISC_R_SUCCESS && strcmp(view->name, "_bind") != 0) {
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington CHECK(dns_cache_setfilename(cache, cfg_obj_asstring(obj)));
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "cleaning-interval", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_cache_setcleaninginterval(cache, cfg_obj_asuint32(obj) * 60);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "max-cache-size", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington "'max-cache-size "
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington "%" ISC_PRINT_QUADFORMAT "d' is too large",
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_cache_setcachesize(cache, max_cache_size);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Check-names.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "check-names", &obj);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington if (strcasecmp(cfg_obj_asstring(type), "response") == 0) {
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington str = cfg_obj_asstring(cfg_tuple_get(value, "mode"));
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington } else if (strcasecmp(str, "ignore") == 0) {
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington * XXXRTH Hardwired number of tasks.
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington CHECK(get_view_querysource_dispatch(maps, AF_INET, &dispatch4));
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington CHECK(get_view_querysource_dispatch(maps, AF_INET6, &dispatch6));
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington if (dispatch4 == NULL && dispatch6 == NULL) {
5caab9f99d19ab9ebb0a0ba64c09c8de80e89e29Brian Wellington "unable to obtain neither an IPv4 nor"
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington " an IPv6 dispatch");
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington CHECK(dns_view_createresolver(view, ns_g_taskmgr, 31,
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * Set the ADB cache size to 1/8th of the max-cache-size.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington dns_adb_setadbsize(view->adb, max_adb_size);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * Set resolver's lame-ttl.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence result = ns_config_get(maps, "lame-ttl", &obj);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington dns_resolver_setlamettl(view->resolver, lame_ttl);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * Set the resolver's EDNS UDP size.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington result = ns_config_get(maps, "edns-udp-size", &obj);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington dns_resolver_setudpsize(view->resolver, udpsize);
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington * Set supported DNSSEC algorithms.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington dns_resolver_reset_algorithms(view->resolver);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void)ns_config_get(maps, "disable-algorithms", &disabled);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington CHECK(disable_algorithms(cfg_listelt_value(element),
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * A global or view "forwarders" option, if present,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * creates an entry for "." in the forwarding table.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void)ns_config_get(maps, "forward", &forwardtype);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void)ns_config_get(maps, "forwarders", &forwarders);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence CHECK(configure_forward(config, view, dns_rootname,
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * Dual Stack Servers.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void)ns_config_get(maps, "dual-stack-servers", &alternates);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence CHECK(configure_alternates(config, view, alternates));
dc3fc5830a90b170c0a2fbf2e8fe057aad209678Brian Wellington * We have default hints for class IN if we need them.
dc3fc5830a90b170c0a2fbf2e8fe057aad209678Brian Wellington if (view->rdclass == dns_rdataclass_in && view->hints == NULL)
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington dns_view_sethints(view, ns_g_server->in_roothints);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * If we still have no hints, this is a non-IN view with no
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * "hints zone" configured. Issue a warning, except if this
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * is a root server. Root servers never need to consult
81ab85fd39c3f6c781ecac725d830364a311479dBrian Wellington * their hints, so it's no point requiring users to configure
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence (void)dns_view_findzone(view, dns_rootname, &rootzone);
d598338952797df77417e69fcb8782b73651f9a9Brian Wellington isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington "no root hints for view '%s'",
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Configure the view's TSIG keys.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington CHECK(ns_tsigkeyring_fromconfig(config, vconfig, view->mctx, &ring));
83e4218f6c6497eeaec7fb422b5f662cd98b2ba6David Lawrence * Configure the view's peer list.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void)ns_config_get(cfgmaps, "server", &peers);
5766ea1011051b4a9f7560041a03d9a562722df3Brian Wellington cfg_obj_t *cpeer = cfg_listelt_value(element);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington view->peers = newpeers; /* Transfer ownership. */
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington * Configure the views rrset-order.
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington (void)ns_config_get(maps, "rrset-order", &rrsetorder);
c7f13217d11f26739a79f0dab391ec372b49b96bBrian Wellington cfg_obj_t *ent = cfg_listelt_value(element);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Copy the aclenv object.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington dns_aclenv_copy(&view->aclenv, &ns_g_server->aclenv);
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington * Configure the "match-clients" and "match-destinations" ACL.
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington CHECK(configure_view_acl(vconfig, config, "match-clients", actx,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(configure_view_acl(vconfig, config, "match-destinations", actx,
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington * Configure the "match-recursive-only" option.
fb01226bcd598c36b5edc566489c890c39f03ed3Brian Wellington (void) ns_config_get(maps, "match-recursive-only", &obj);
15660bccc162db0a7df281f5d743757c527580d5Brian Wellington * Configure other configurable data.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "recursion", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "auth-nxdomain", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington view->auth_nxdomain = cfg_obj_asboolean(obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "minimal-responses", &obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington view->minimalresponses = cfg_obj_asboolean(obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington result = ns_config_get(maps, "transfer-format", &obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington else if (strcasecmp(str, "one-answer") == 0)
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson * Set sources where additional data and CNAME/DNAME
ffdcf33647eb0345dfe84be2c0e7b28264377436Brian Wellington * targets for authoritative answers may be found.
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington result = ns_config_get(maps, "additional-from-auth", &obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington view->additionalfromauth = cfg_obj_asboolean(obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington if (view->recursion && ! view->additionalfromauth) {
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington cfg_obj_log(obj, ns_g_lctx, ISC_LOG_WARNING,
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington "'additional-from-auth no' is only supported "
8dd915daf3f75ac9d04395e61157fdea825f3ebaBrian Wellington "with 'recursion no'");
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff result = ns_config_get(maps, "additional-from-cache", &obj);
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington view->additionalfromcache = cfg_obj_asboolean(obj);
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington if (view->recursion && ! view->additionalfromcache) {
e552b980379e3a7ffce1411a939c62e27f953133Brian Wellington cfg_obj_log(obj, ns_g_lctx, ISC_LOG_WARNING,
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington "'additional-from-cache no' is only supported "
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington "with 'recursion no'");
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington CHECK(configure_view_acl(vconfig, config, "allow-query",
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington CHECK(configure_view_acl(vconfig, config, "allow-recursion",
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington * Warning if both "recursion no;" and allow-recursion are active
949d406b57fe80fabc6a60d36a0dcee927c780b3Brian Wellington * except for "allow-recursion { none; };".
af602636644fdfaabc331bd926b0aabb9432e152Brian Wellington if (!view->recursion && view->recursionacl != NULL &&
8dd915daf3f75ac9d04395e61157fdea825f3ebaBrian Wellington view->recursionacl->elements[0].type != dns_aclelementtype_any ||
8dd915daf3f75ac9d04395e61157fdea825f3ebaBrian Wellington view->recursionacl->elements[0].negative != ISC_TRUE)) {
const char *dlv;
isc_buffer_t b;
isc_buffer_t b;
char *str;
name));
return (result);
static isc_result_t
return (result);
static isc_result_t
return (ISC_R_RANGE);
val);
return (ISC_R_RANGE);
NULL, 0));
return (result);
static isc_result_t
return (ISC_R_RANGE);
goto cleanup;
INSIST(0);
goto cleanup;
return (result);
static isc_result_t
const char *viewname;
&viewclass);
return (ISC_R_EXISTS);
return (result);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
const char *zname;
const char *ztypestr;
goto cleanup;
return (ISC_R_FAILURE);
zname);
goto cleanup;
goto cleanup;
&only);
zname);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
&pview);
goto cleanup;
goto cleanup;
forwardtype));
return (result);
static isc_result_t
char *directory;
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
goto clean;
goto clean;
return (ISC_R_SUCCESS);
return (result);
goto fail;
goto fail;
goto fail;
goto fail;
fail:
goto clean;
static isc_result_t
char *copy;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
char *resource;
static isc_result_t
return (result);
static isc_result_t
if (first_time) {
&ns_g_defaults) ==
filename);
&config);
* option where the above parsing failed, parse resolv.conf.
if (ns_g_lwresdonly &&
&config);
if (ns_g_port != 0)
&listenon);
} else if (!ns_g_lwresdonly) {
listenon);
&listenon);
} else if (!ns_g_lwresdonly) {
listenon);
if (interface_interval == 0) {
if (heartbeat_interval == 0) {
&aclconfctx),
if (first_time) {
#ifdef PATH_RANDOMDEV
&ns_g_entropy);
if (first_time)
* files specified in named.conf get created by the
if (ns_g_logstderr) {
if (first_time) {
&categories);
char *str;
else if (ns_g_lwresdonly)
return (result);
static isc_result_t
return (result);
static isc_result_t
return (result);
if (ns_g_lwresdonly)
ISC_TRUE),
if (flush)
sizeof(isc_event_t));
goto cleanup;
attrs = 0;
case AF_INET:
case AF_INET6:
goto cleanup;
attrmask = 0;
goto cleanup;
static isc_result_t
return (result);
static isc_result_t
return (result);
cleanup: ;
char *res;
return (res);
static isc_result_t
const char *zonetxt;
char *classtxt;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
goto fail1;
goto fail1;
goto fail1;
return (result);
return (result);
return (ISC_R_UNEXPECTEDEND);
return (result);
return (result);
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_CONTINUE:
case DNS_R_UPTODATE:
return (result);
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
if (ns_g_port != 0) {
return (result);
return (ISC_R_RANGE);
return (result);
return (result);
return (ISC_R_SUCCESS);
int ncounters;
for (i = 0; i < ncounters; i++)
char *viewname;
for (i = 0; i < ncounters; i++) {
zonestats[i],
zonename);
return (result);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOMEMORY);
return (result);
goto cleanup;
goto done;
goto cleanup;
goto nextzone;
goto cleanup;
goto nextview;
done:
char *ptr;
const char *sep;
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
return (result);
return (result);
char *ptr;
char *levelstr;
char *endp;
long newlevel;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
return (ISC_R_UNEXPECTEDEND);
goto out;
if (flushed)
out:
return (result);
isc_buffer_t b;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (result);
if (flushed)
return (result);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
char *journal;
return (result);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOTFOUND);
if (freeze) {
if (frozen)
if (frozen) {
sizeof(classstr));
return (result);