Lines Matching defs:server

97 #include <named/server.h>
328 end_reserved_dispatches(ns_server_t *server, isc_boolean_t all);
520 * The per-view configuration values and the server-global defaults are read
1785 * is a root server. Root servers never need to consult
1818 (void)ns_config_get(cfgmaps, "server", &peers);
2179 char server[DNS_NAME_FORMATSIZE + 1];
2191 result = ns_config_get(maps, "empty-server", &obj);
2198 isc_buffer_init(&buffer, server, sizeof(server) - 1);
2200 server[isc_buffer_usedlength(&buffer)] = 0;
2201 empty_dbtype[2] = server;
2862 * Configure a single server quota.
2912 scan_interfaces(ns_server_t *server, isc_boolean_t verbose) {
2913 isc_boolean_t match_mapped = server->aclenv.match_mapped;
2915 ns_interfacemgr_scan(server->interfacemgr, verbose);
2920 dns_aclenv_copy(&server->aclenv,
2921 ns_interfacemgr_getaclenv(server->interfacemgr));
2923 server->aclenv.match_mapped = match_mapped;
2975 adjust_interfaces(ns_server_t *server, isc_mem_t *mctx) {
2986 for (view = ISC_LIST_HEAD(server->viewlist);
3012 for (result = dns_zone_first(server->zonemgr, &zone);
3028 for (view = ISC_LIST_HEAD(server->viewlist);
3046 ns_interfacemgr_adjust(server->interfacemgr, list, ISC_TRUE);
3071 ns_server_t *server = (ns_server_t *) event->ev_arg;
3072 INSIST(task == server->task);
3079 result = isc_task_beginexclusive(server->task);
3081 scan_interfaces(server, ISC_FALSE);
3082 isc_task_endexclusive(server->task);
3087 ns_server_t *server = (ns_server_t *) event->ev_arg;
3092 view = ISC_LIST_HEAD(server->viewlist);
3120 setstring(ns_server_t *server, char **field, const char *value) {
3124 copy = isc_mem_strdup(server->mctx, value);
3132 isc_mem_free(server->mctx, *field);
3144 setoptstring(ns_server_t *server, char **field, const cfg_obj_t *obj) {
3146 return (setstring(server, field, NULL));
3148 return (setstring(server, field, cfg_obj_asstring(obj)));
3275 load_configuration(const char *filename, ns_server_t *server,
3379 result = isc_task_beginexclusive(server->task);
3393 * server.
3432 * Configure various server options.
3434 configure_server_quota(maps, "transfers-out", &server->xfroutquota);
3435 configure_server_quota(maps, "tcp-clients", &server->tcpquota);
3437 &server->recursionquota);
3438 if (server->recursionquota.max > 1000)
3439 isc_quota_soft(&server->recursionquota,
3440 server->recursionquota.max - 100);
3442 isc_quota_soft(&server->recursionquota, 0);
3445 ns_g_mctx, &server->blackholeacl));
3446 if (server->blackholeacl != NULL)
3448 server->blackholeacl);
3453 server->aclenv.match_mapped = cfg_obj_asboolean(obj);
3456 "configuring statistics server(s)");
3536 dns_zonemgr_settransfersin(server->zonemgr, cfg_obj_asuint32(obj));
3541 dns_zonemgr_settransfersperns(server->zonemgr, cfg_obj_asuint32(obj));
3546 dns_zonemgr_setserialqueryrate(server->zonemgr, cfg_obj_asuint32(obj));
3595 ns_interfacemgr_setlistenon4(server->interfacemgr,
3624 ns_interfacemgr_setlistenon6(server->interfacemgr,
3636 scan_interfaces(server, ISC_TRUE);
3647 CHECK(isc_timer_reset(server->interface_timer,
3650 } else if (server->interface_interval != interface_interval) {
3652 CHECK(isc_timer_reset(server->interface_timer,
3656 server->interface_interval = interface_interval;
3666 CHECK(isc_timer_reset(server->heartbeat_timer,
3669 } else if (server->heartbeat_interval != heartbeat_interval) {
3671 CHECK(isc_timer_reset(server->heartbeat_timer,
3675 server->heartbeat_interval = heartbeat_interval;
3678 CHECK(isc_timer_reset(server->pps_timer, isc_timertype_ticker, NULL,
3792 tmpviewlist = server->viewlist;
3793 server->viewlist = viewlist;
3804 if (server->tkeyctx != NULL)
3805 dns_tkeyctx_destroy(&server->tkeyctx);
3806 server->tkeyctx = t;
3952 server->log_queries = cfg_obj_asboolean(obj);
3972 server->log_queries = ISC_TRUE;
4008 CHECKM(setstring(server, &server->statsfile, cfg_obj_asstring(obj)),
4014 CHECKM(setstring(server, &server->dumpfile, cfg_obj_asstring(obj)),
4020 CHECKM(setstring(server, &server->recfile, cfg_obj_asstring(obj)),
4026 CHECKM(setoptstring(server, &server->version, obj), "strdup");
4027 server->version_set = ISC_TRUE;
4029 server->version_set = ISC_FALSE;
4035 CHECKM(setoptstring(server, &server->hostname, obj), "strdup");
4036 server->hostname_set = ISC_TRUE;
4038 server->hostname_set = ISC_FALSE;
4042 result = ns_config_get(maps, "server-id", &obj);
4043 server->server_usehostname = ISC_FALSE;
4046 server->server_usehostname = cfg_obj_asboolean(obj);
4047 result = setstring(server, &server->server_id, NULL);
4051 CHECKM(setoptstring(server, &server->server_id, obj), "strdup");
4053 result = setstring(server, &server->server_id, NULL);
4060 server->flushonshutdown = cfg_obj_asboolean(obj);
4062 server->flushonshutdown = ISC_FALSE;
4110 adjust_interfaces(server, ns_g_mctx);
4114 isc_task_endexclusive(server->task);
4124 load_zones(ns_server_t *server, isc_boolean_t stop) {
4128 result = isc_task_beginexclusive(server->task);
4134 for (view = ISC_LIST_HEAD(server->viewlist);
4146 CHECK(dns_zonemgr_forcemaint(server->zonemgr));
4148 isc_task_endexclusive(server->task);
4153 load_new_zones(ns_server_t *server, isc_boolean_t stop) {
4157 result = isc_task_beginexclusive(server->task);
4163 for (view = ISC_LIST_HEAD(server->viewlist);
4174 dns_zonemgr_resumexfrs(server->zonemgr);
4176 isc_task_endexclusive(server->task);
4183 ns_server_t *server = (ns_server_t *)event->ev_arg;
4185 INSIST(task == server->task);
4193 dns_dispatchmgr_setstats(ns_g_dispatchmgr, server->resolverstats);
4197 &server->interfacemgr),
4201 NULL, NULL, server->task,
4203 server, &server->interface_timer),
4207 NULL, NULL, server->task,
4209 server, &server->heartbeat_timer),
4213 NULL, NULL, server->task, pps_timer_tick,
4214 server, &server->pps_timer),
4221 CHECKFATAL(load_configuration(lwresd_g_conffile, server,
4225 CHECKFATAL(load_configuration(ns_g_conffile, server, ISC_TRUE),
4230 CHECKFATAL(load_zones(server, ISC_FALSE), "loading zones");
4238 ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush) {
4240 REQUIRE(NS_SERVER_VALID(server));
4242 server->flushonshutdown = flush;
4249 ns_server_t *server = (ns_server_t *)event->ev_arg;
4250 isc_boolean_t flush = server->flushonshutdown;
4253 INSIST(task == server->task);
4255 result = isc_task_beginexclusive(server->task);
4262 ns_statschannels_shutdown(server);
4263 ns_controls_shutdown(server->controls);
4264 end_reserved_dispatches(server, ISC_TRUE);
4269 for (view = ISC_LIST_HEAD(server->viewlist);
4273 ISC_LIST_UNLINK(server->viewlist, view, link);
4280 isc_timer_detach(&server->interface_timer);
4281 isc_timer_detach(&server->heartbeat_timer);
4282 isc_timer_detach(&server->pps_timer);
4284 ns_interfacemgr_shutdown(server->interfacemgr);
4285 ns_interfacemgr_detach(&server->interfacemgr);
4289 dns_zonemgr_shutdown(server->zonemgr);
4291 if (server->blackholeacl != NULL)
4292 dns_acl_detach(&server->blackholeacl);
4294 dns_db_detach(&server->in_roothints);
4296 isc_task_endexclusive(server->task);
4298 isc_task_detach(&server->task);
4306 ns_server_t *server = isc_mem_get(mctx, sizeof(*server));
4308 if (server == NULL)
4309 fatal("allocating server object", ISC_R_NOMEMORY);
4311 server->mctx = mctx;
4312 server->task = NULL;
4316 result = isc_quota_init(&server->xfroutquota, 10);
4318 result = isc_quota_init(&server->tcpquota, 10);
4320 result = isc_quota_init(&server->recursionquota, 100);
4323 result = dns_aclenv_init(mctx, &server->aclenv);
4326 /* Initialize server data structures. */
4327 server->zonemgr = NULL;
4328 server->interfacemgr = NULL;
4329 ISC_LIST_INIT(server->viewlist);
4330 server->in_roothints = NULL;
4331 server->blackholeacl = NULL;
4334 &server->in_roothints),
4337 CHECKFATAL(isc_mutex_init(&server->reload_event_lock),
4339 server->reload_event =
4340 isc_event_allocate(ns_g_mctx, server,
4343 server,
4345 CHECKFATAL(server->reload_event == NULL ?
4352 server->tkeyctx = NULL;
4354 &server->tkeyctx),
4358 * Setup the server task, which is responsible for coordinating
4359 * startup and shutdown of the server.
4361 CHECKFATAL(isc_task_create(ns_g_taskmgr, 0, &server->task),
4362 "creating server task");
4363 isc_task_setname(server->task, "server", server);
4364 CHECKFATAL(isc_task_onshutdown(server->task, shutdown_server, server),
4366 CHECKFATAL(isc_app_onrun(ns_g_mctx, server->task, run_server, server),
4369 server->interface_timer = NULL;
4370 server->heartbeat_timer = NULL;
4371 server->pps_timer = NULL;
4373 server->interface_interval = 0;
4374 server->heartbeat_interval = 0;
4377 ns_g_socketmgr, &server->zonemgr),
4379 CHECKFATAL(dns_zonemgr_setsize(server->zonemgr, 1000),
4382 server->statsfile = isc_mem_strdup(server->mctx, "named.stats");
4383 CHECKFATAL(server->statsfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
4385 server->nsstats = NULL;
4386 server->rcvquerystats = NULL;
4387 server->opcodestats = NULL;
4388 server->zonestats = NULL;
4389 server->resolverstats = NULL;
4390 server->sockstats = NULL;
4391 CHECKFATAL(isc_stats_create(server->mctx, &server->sockstats,
4394 isc_socketmgr_setstats(ns_g_socketmgr, server->sockstats);
4396 server->dumpfile = isc_mem_strdup(server->mctx, "named_dump.db");
4397 CHECKFATAL(server->dumpfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
4400 server->recfile = isc_mem_strdup(server->mctx, "named.recursing");
4401 CHECKFATAL(server->recfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS,
4404 server->hostname_set = ISC_FALSE;
4405 server->hostname = NULL;
4406 server->version_set = ISC_FALSE;
4407 server->version = NULL;
4408 server->server_usehostname = ISC_FALSE;
4409 server->server_id = NULL;
4411 CHECKFATAL(isc_stats_create(ns_g_mctx, &server->nsstats,
4413 "dns_stats_create (server)");
4416 &server->rcvquerystats),
4419 CHECKFATAL(dns_opcodestats_create(ns_g_mctx, &server->opcodestats),
4422 CHECKFATAL(isc_stats_create(ns_g_mctx, &server->zonestats,
4426 CHECKFATAL(isc_stats_create(ns_g_mctx, &server->resolverstats,
4430 server->flushonshutdown = ISC_FALSE;
4431 server->log_queries = ISC_FALSE;
4433 server->controls = NULL;
4434 CHECKFATAL(ns_controls_create(server, &server->controls),
4436 server->dispatchgen = 0;
4437 ISC_LIST_INIT(server->dispatches);
4439 ISC_LIST_INIT(server->statschannels);
4441 server->magic = NS_SERVER_MAGIC;
4442 *serverp = server;
4447 ns_server_t *server = *serverp;
4448 REQUIRE(NS_SERVER_VALID(server));
4450 ns_controls_destroy(&server->controls);
4452 isc_stats_detach(&server->nsstats);
4453 dns_stats_detach(&server->rcvquerystats);
4454 dns_stats_detach(&server->opcodestats);
4455 isc_stats_detach(&server->zonestats);
4456 isc_stats_detach(&server->resolverstats);
4457 isc_stats_detach(&server->sockstats);
4459 isc_mem_free(server->mctx, server->statsfile);
4460 isc_mem_free(server->mctx, server->dumpfile);
4461 isc_mem_free(server->mctx, server->recfile);
4463 if (server->version != NULL)
4464 isc_mem_free(server->mctx, server->version);
4465 if (server->hostname != NULL)
4466 isc_mem_free(server->mctx, server->hostname);
4467 if (server->server_id != NULL)
4468 isc_mem_free(server->mctx, server->server_id);
4470 if (server->zonemgr != NULL)
4471 dns_zonemgr_detach(&server->zonemgr);
4473 if (server->tkeyctx != NULL)
4474 dns_tkeyctx_destroy(&server->tkeyctx);
4478 isc_event_free(&server->reload_event);
4480 INSIST(ISC_LIST_EMPTY(server->viewlist));
4482 dns_aclenv_destroy(&server->aclenv);
4484 isc_quota_destroy(&server->recursionquota);
4485 isc_quota_destroy(&server->tcpquota);
4486 isc_quota_destroy(&server->xfroutquota);
4488 server->magic = 0;
4489 isc_mem_put(server->mctx, server, sizeof(*server));
4504 start_reserved_dispatches(ns_server_t *server) {
4506 REQUIRE(NS_SERVER_VALID(server));
4508 server->dispatchgen++;
4512 end_reserved_dispatches(ns_server_t *server, isc_boolean_t all) {
4515 REQUIRE(NS_SERVER_VALID(server));
4517 for (dispatch = ISC_LIST_HEAD(server->dispatches);
4521 if (!all && server->dispatchgen == dispatch-> dispatchgen)
4523 ISC_LIST_UNLINK(server->dispatches, dispatch, link);
4525 isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
4530 ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr) {
4537 REQUIRE(NS_SERVER_VALID(server));
4543 for (dispatch = ISC_LIST_HEAD(server->dispatches);
4550 dispatch->dispatchgen = server->dispatchgen;
4554 dispatch = isc_mem_get(server->mctx, sizeof(*dispatch));
4561 dispatch->dispatchgen = server->dispatchgen;
4590 ISC_LIST_INITANDPREPEND(server->dispatches, dispatch, link);
4596 isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
4606 loadconfig(ns_server_t *server) {
4608 start_reserved_dispatches(server);
4611 server, ISC_FALSE);
4613 end_reserved_dispatches(server, ISC_FALSE);
4627 reload(ns_server_t *server) {
4629 CHECK(loadconfig(server));
4631 result = load_zones(server, ISC_FALSE);
4647 reconfig(ns_server_t *server) {
4649 CHECK(loadconfig(server));
4651 result = load_new_zones(server, ISC_FALSE);
4670 ns_server_t *server = (ns_server_t *)event->ev_arg;
4672 INSIST(task = server->task);
4678 (void)reload(server);
4680 LOCK(&server->reload_event_lock);
4681 INSIST(server->reload_event == NULL);
4682 server->reload_event = event;
4683 UNLOCK(&server->reload_event_lock);
4687 ns_server_reloadwanted(ns_server_t *server) {
4688 LOCK(&server->reload_event_lock);
4689 if (server->reload_event != NULL)
4690 isc_task_send(server->task, &server->reload_event);
4691 UNLOCK(&server->reload_event_lock);
4712 zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep) {
4763 result = dns_viewlist_findzone(&server->viewlist,
4768 result = dns_viewlist_find(&server->viewlist, viewtxt,
4791 ns_server_retransfercommand(ns_server_t *server, char *args) {
4796 result = zone_from_args(server, args, &zone);
4814 ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
4820 result = zone_from_args(server, args, &zone);
4824 result = reload(server);
4826 msg = "server reload successful";
4864 ns_server_reconfigcommand(ns_server_t *server, char *args) {
4867 reconfig(server);
4875 ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text) {
4880 result = zone_from_args(server, args, &zone);
4898 ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
4905 result = zone_from_args(server, args, &zone);
4927 ns_server_togglequerylog(ns_server_t *server) {
4928 server->log_queries = server->log_queries ? ISC_FALSE : ISC_TRUE;
4933 server->log_queries ? "on" : "off");
5022 ns_server_dumpstats(ns_server_t *server) {
5026 CHECKMF(isc_stdio_open(server->statsfile, "a", &fp),
5027 "could not open statistics dump file", server->statsfile);
5029 result = ns_stats_dump(server, fp);
5236 ns_server_dumpdb(ns_server_t *server, char *args) {
5248 dctx = isc_mem_get(server->mctx, sizeof(*dctx));
5252 dctx->mctx = server->mctx;
5265 isc_task_attach(server->task, &dctx->task);
5267 CHECKMF(isc_stdio_open(server->dumpfile, "w", &dctx->fp),
5268 "could not open dump file", server->dumpfile);
5291 for (view = ISC_LIST_HEAD(server->viewlist);
5314 ns_server_dumprecursing(ns_server_t *server) {
5318 CHECKMF(isc_stdio_open(server->recfile, "w", &fp),
5319 "could not open dump file", server->recfile);
5321 ns_interfacemgr_dumprecursing(fp, server->interfacemgr);
5340 ns_server_setdebuglevel(ns_server_t *server, char *args) {
5346 UNUSED(server);
5372 ns_server_validation(ns_server_t *server, char *args) {
5401 result = isc_task_beginexclusive(server->task);
5403 for (view = ISC_LIST_HEAD(server->viewlist);
5420 isc_task_endexclusive(server->task);
5425 ns_server_flushcache(ns_server_t *server, char *args) {
5440 result = isc_task_beginexclusive(server->task);
5444 for (view = ISC_LIST_HEAD(server->viewlist);
5481 isc_task_endexclusive(server->task);
5486 ns_server_flushname(ns_server_t *server, char *args) {
5517 result = isc_task_beginexclusive(server->task);
5521 for (view = ISC_LIST_HEAD(server->viewlist);
5559 isc_task_endexclusive(server->task);
5564 ns_server_status(ns_server_t *server, isc_buffer_t *text) {
5577 zonecount = dns_zonemgr_getcount(server->zonemgr, DNS_ZONESTATE_ANY);
5578 xferrunning = dns_zonemgr_getcount(server->zonemgr,
5580 xferdeferred = dns_zonemgr_getcount(server->zonemgr,
5582 soaqueries = dns_zonemgr_getcount(server->zonemgr,
5600 "server is up and running",
5606 soaqueries, server->log_queries ? "ON" : "OFF",
5607 server->recursionquota.used, server->recursionquota.soft,
5608 server->recursionquota.max,
5609 server->tcpquota.used, server->tcpquota.max);
5680 ns_server_tsigdelete(ns_server_t *server, char *command, isc_buffer_t *text) {
5694 result = isc_task_beginexclusive(server->task);
5696 for (view = ISC_LIST_HEAD(server->viewlist);
5706 isc_task_endexclusive(server->task);
5711 isc_task_endexclusive(server->task);
5799 ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text) {
5805 result = isc_task_beginexclusive(server->task);
5807 for (view = ISC_LIST_HEAD(server->viewlist);
5815 isc_task_endexclusive(server->task);
5823 isc_task_endexclusive(server->task);
5827 isc_task_endexclusive(server->task);
5845 ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args,
5859 result = zone_from_args(server, args, &zone);
5863 result = isc_task_beginexclusive(server->task);
5866 for (view = ISC_LIST_HEAD(server->viewlist);
5874 isc_task_endexclusive(server->task);
5888 result = isc_task_beginexclusive(server->task);
5929 isc_task_endexclusive(server->task);