2007-02-22 11:22:54 -05:00
|
|
|
/*
|
|
|
|
|
* daemon/daemon.c - collection of workers that handles requests.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This software is open source.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
*
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* Neither the name of the NLNET LABS nor the names of its contributors may
|
|
|
|
|
* be used to endorse or promote products derived from this software without
|
|
|
|
|
* specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
2014-02-07 08:28:39 -05:00
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
|
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2007-02-22 11:22:54 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file
|
|
|
|
|
*
|
|
|
|
|
* The daemon consists of global settings and a number of workers.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2010-03-12 10:17:48 -05:00
|
|
|
#ifdef HAVE_OPENSSL_ERR_H
|
|
|
|
|
#include <openssl/err.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENSSL_RAND_H
|
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENSSL_CONF_H
|
|
|
|
|
#include <openssl/conf.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENSSL_ENGINE_H
|
|
|
|
|
#include <openssl/engine.h>
|
|
|
|
|
#endif
|
2012-06-20 11:23:03 -04:00
|
|
|
|
2013-11-02 00:38:57 -04:00
|
|
|
#ifdef HAVE_TIME_H
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
2012-06-20 11:23:03 -04:00
|
|
|
#ifdef HAVE_NSS
|
2013-01-30 08:15:03 -05:00
|
|
|
/* nss3 */
|
|
|
|
|
#include "nss.h"
|
2012-06-20 11:23:03 -04:00
|
|
|
#endif
|
|
|
|
|
|
2007-02-22 11:22:54 -05:00
|
|
|
#include "daemon/daemon.h"
|
|
|
|
|
#include "daemon/worker.h"
|
2008-09-10 11:23:01 -04:00
|
|
|
#include "daemon/remote.h"
|
2007-11-19 10:32:55 -05:00
|
|
|
#include "daemon/acl_list.h"
|
2007-02-22 11:22:54 -05:00
|
|
|
#include "util/log.h"
|
|
|
|
|
#include "util/config_file.h"
|
2007-03-22 12:26:14 -04:00
|
|
|
#include "util/data/msgreply.h"
|
2017-02-23 07:05:05 -05:00
|
|
|
#include "util/shm_side/shm_main.h"
|
2012-01-02 08:16:18 -05:00
|
|
|
#include "util/storage/lookup3.h"
|
2007-03-26 06:33:41 -04:00
|
|
|
#include "util/storage/slabhash.h"
|
2018-08-07 07:57:42 -04:00
|
|
|
#include "util/tcp_conn_limit.h"
|
2020-07-23 11:17:44 -04:00
|
|
|
#include "util/edns.h"
|
2007-02-22 11:22:54 -05:00
|
|
|
#include "services/listen_dnsport.h"
|
2007-05-16 08:48:48 -04:00
|
|
|
#include "services/cache/rrset.h"
|
2007-05-16 10:29:46 -04:00
|
|
|
#include "services/cache/infra.h"
|
2007-11-22 04:30:44 -05:00
|
|
|
#include "services/localzone.h"
|
2016-10-05 05:36:25 -04:00
|
|
|
#include "services/view.h"
|
2007-12-04 08:23:41 -05:00
|
|
|
#include "services/modstack.h"
|
2018-01-30 05:35:20 -05:00
|
|
|
#include "services/authzone.h"
|
2007-05-11 10:16:42 -04:00
|
|
|
#include "util/module.h"
|
2008-04-11 09:24:49 -04:00
|
|
|
#include "util/random.h"
|
2008-07-18 11:06:59 -04:00
|
|
|
#include "util/tube.h"
|
2012-08-01 09:18:19 -04:00
|
|
|
#include "util/net_help.h"
|
2015-03-26 06:21:38 -04:00
|
|
|
#include "sldns/keyraw.h"
|
2017-03-07 09:58:51 -05:00
|
|
|
#include "respip/respip.h"
|
2024-01-04 10:53:02 -05:00
|
|
|
#include "iterator/iter_fwd.h"
|
2024-01-05 07:36:41 -05:00
|
|
|
#include "iterator/iter_hints.h"
|
2007-02-26 09:49:11 -05:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
2017-01-03 08:43:29 -05:00
|
|
|
#ifdef HAVE_SYSTEMD
|
|
|
|
|
#include <systemd/sd-daemon.h>
|
|
|
|
|
#endif
|
2022-09-11 14:57:41 -04:00
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
|
#include <netdb.h>
|
|
|
|
|
#endif
|
2024-04-10 05:21:28 -04:00
|
|
|
#ifdef USE_CACHEDB
|
|
|
|
|
#include "cachedb/cachedb.h"
|
|
|
|
|
#endif
|
2017-01-03 08:43:29 -05:00
|
|
|
|
2007-02-27 05:33:04 -05:00
|
|
|
/** How many quit requests happened. */
|
|
|
|
|
static int sig_record_quit = 0;
|
|
|
|
|
/** How many reload requests happened. */
|
|
|
|
|
static int sig_record_reload = 0;
|
|
|
|
|
|
2009-08-25 09:05:31 -04:00
|
|
|
#if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
|
2009-08-24 11:30:05 -04:00
|
|
|
/** cleaner ssl memory freeup */
|
|
|
|
|
static void* comp_meth = NULL;
|
2009-08-25 09:05:31 -04:00
|
|
|
#endif
|
2009-08-25 11:37:02 -04:00
|
|
|
/** remove buffers for parsing and init */
|
2010-02-26 06:05:49 -05:00
|
|
|
int ub_c_lex_destroy(void);
|
2009-08-24 11:30:05 -04:00
|
|
|
|
2007-02-27 05:33:04 -05:00
|
|
|
/** used when no other sighandling happens, so we don't die
|
2007-06-12 10:51:49 -04:00
|
|
|
* when multiple signals in quick succession are sent to us.
|
|
|
|
|
* @param sig: signal number.
|
|
|
|
|
* @return signal handler return type (void or int).
|
|
|
|
|
*/
|
2007-02-27 05:33:04 -05:00
|
|
|
static RETSIGTYPE record_sigh(int sig)
|
|
|
|
|
{
|
2007-03-02 04:48:31 -05:00
|
|
|
#ifdef LIBEVENT_SIGNAL_PROBLEM
|
2014-07-12 13:34:37 -04:00
|
|
|
/* cannot log, verbose here because locks may be held */
|
|
|
|
|
/* quit on signal, no cleanup and statistics,
|
|
|
|
|
because installed libevent version is not threadsafe */
|
2007-03-02 04:48:31 -05:00
|
|
|
exit(0);
|
|
|
|
|
#endif
|
2007-02-27 05:33:04 -05:00
|
|
|
switch(sig)
|
|
|
|
|
{
|
|
|
|
|
case SIGTERM:
|
2008-05-23 10:13:07 -04:00
|
|
|
#ifdef SIGQUIT
|
2007-02-27 05:33:04 -05:00
|
|
|
case SIGQUIT:
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef SIGBREAK
|
|
|
|
|
case SIGBREAK:
|
|
|
|
|
#endif
|
2007-02-27 05:33:04 -05:00
|
|
|
case SIGINT:
|
|
|
|
|
sig_record_quit++;
|
|
|
|
|
break;
|
2008-05-23 10:13:07 -04:00
|
|
|
#ifdef SIGHUP
|
2007-02-27 05:33:04 -05:00
|
|
|
case SIGHUP:
|
|
|
|
|
sig_record_reload++;
|
|
|
|
|
break;
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef SIGPIPE
|
2008-04-22 06:19:24 -04:00
|
|
|
case SIGPIPE:
|
|
|
|
|
break;
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
2007-02-27 05:33:04 -05:00
|
|
|
default:
|
2014-07-12 13:34:37 -04:00
|
|
|
/* ignoring signal */
|
|
|
|
|
break;
|
2007-02-27 05:33:04 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Signal handling during the time when netevent is disabled.
|
|
|
|
|
* Stores signals to replay later.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2010-07-07 09:13:36 -04:00
|
|
|
signal_handling_record(void)
|
2007-02-27 05:33:04 -05:00
|
|
|
{
|
|
|
|
|
if( signal(SIGTERM, record_sigh) == SIG_ERR ||
|
2008-05-23 10:13:07 -04:00
|
|
|
#ifdef SIGQUIT
|
2007-02-27 05:33:04 -05:00
|
|
|
signal(SIGQUIT, record_sigh) == SIG_ERR ||
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef SIGBREAK
|
|
|
|
|
signal(SIGBREAK, record_sigh) == SIG_ERR ||
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef SIGHUP
|
2008-04-22 06:19:24 -04:00
|
|
|
signal(SIGHUP, record_sigh) == SIG_ERR ||
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef SIGPIPE
|
|
|
|
|
signal(SIGPIPE, SIG_IGN) == SIG_ERR ||
|
|
|
|
|
#endif
|
|
|
|
|
signal(SIGINT, record_sigh) == SIG_ERR
|
|
|
|
|
)
|
2007-02-27 05:33:04 -05:00
|
|
|
log_err("install sighandler: %s", strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replay old signals.
|
|
|
|
|
* @param wrk: worker that handles signals.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
signal_handling_playback(struct worker* wrk)
|
|
|
|
|
{
|
2008-05-23 10:13:07 -04:00
|
|
|
#ifdef SIGHUP
|
2018-07-23 09:05:39 -04:00
|
|
|
if(sig_record_reload)
|
2007-02-27 05:33:04 -05:00
|
|
|
worker_sighandler(SIGHUP, wrk);
|
2008-05-23 10:13:07 -04:00
|
|
|
#endif
|
2007-11-12 06:10:11 -05:00
|
|
|
if(sig_record_quit)
|
|
|
|
|
worker_sighandler(SIGTERM, wrk);
|
2007-02-27 05:33:04 -05:00
|
|
|
sig_record_quit = 0;
|
|
|
|
|
sig_record_reload = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-22 11:22:54 -05:00
|
|
|
struct daemon*
|
2010-07-07 09:13:36 -04:00
|
|
|
daemon_init(void)
|
2007-02-22 11:22:54 -05:00
|
|
|
{
|
|
|
|
|
struct daemon* daemon = (struct daemon*)calloc(1,
|
|
|
|
|
sizeof(struct daemon));
|
2008-06-16 11:02:52 -04:00
|
|
|
#ifdef USE_WINSOCK
|
|
|
|
|
int r;
|
|
|
|
|
WSADATA wsa_data;
|
|
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
if(!daemon)
|
|
|
|
|
return NULL;
|
2008-06-16 11:02:52 -04:00
|
|
|
#ifdef USE_WINSOCK
|
|
|
|
|
r = WSAStartup(MAKEWORD(2,2), &wsa_data);
|
|
|
|
|
if(r != 0) {
|
|
|
|
|
fatal_exit("could not init winsock. WSAStartup: %s",
|
|
|
|
|
wsa_strerror(r));
|
|
|
|
|
}
|
|
|
|
|
#endif /* USE_WINSOCK */
|
2007-02-27 05:33:04 -05:00
|
|
|
signal_handling_record();
|
2012-06-20 11:23:03 -04:00
|
|
|
#ifdef HAVE_SSL
|
2016-09-02 05:59:09 -04:00
|
|
|
# ifdef HAVE_ERR_LOAD_CRYPTO_STRINGS
|
2007-08-15 04:39:00 -04:00
|
|
|
ERR_load_crypto_strings();
|
2016-09-02 05:59:09 -04:00
|
|
|
# endif
|
2017-07-03 09:44:17 -04:00
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)
|
2008-09-11 10:14:12 -04:00
|
|
|
ERR_load_SSL_strings();
|
2017-07-03 09:37:37 -04:00
|
|
|
#endif
|
2012-06-20 11:23:03 -04:00
|
|
|
# ifdef USE_GOST
|
2013-12-03 04:11:16 -05:00
|
|
|
(void)sldns_key_EVP_load_gost_id();
|
2012-06-20 11:23:03 -04:00
|
|
|
# endif
|
2016-09-15 08:03:10 -04:00
|
|
|
# if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_CRYPTO)
|
2019-11-13 09:16:27 -05:00
|
|
|
# ifndef S_SPLINT_S
|
2008-09-11 10:14:12 -04:00
|
|
|
OpenSSL_add_all_algorithms();
|
2019-11-13 09:16:27 -05:00
|
|
|
# endif
|
2016-09-02 05:59:09 -04:00
|
|
|
# else
|
|
|
|
|
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS
|
|
|
|
|
| OPENSSL_INIT_ADD_ALL_DIGESTS
|
|
|
|
|
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
|
|
|
|
# endif
|
2012-06-20 11:23:03 -04:00
|
|
|
# if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
|
2009-08-24 11:30:05 -04:00
|
|
|
/* grab the COMP method ptr because openssl leaks it */
|
2009-08-25 06:02:17 -04:00
|
|
|
comp_meth = (void*)SSL_COMP_get_compression_methods();
|
2012-06-20 11:23:03 -04:00
|
|
|
# endif
|
2016-09-15 08:03:10 -04:00
|
|
|
# if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)
|
2008-09-11 10:14:12 -04:00
|
|
|
(void)SSL_library_init();
|
2016-09-02 05:59:09 -04:00
|
|
|
# else
|
2017-07-03 09:37:37 -04:00
|
|
|
(void)OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
|
2016-09-02 05:59:09 -04:00
|
|
|
# endif
|
2013-02-11 11:03:51 -05:00
|
|
|
# if defined(HAVE_SSL) && defined(OPENSSL_THREADS) && !defined(THREADS_DISABLED)
|
2012-08-01 07:31:29 -04:00
|
|
|
if(!ub_openssl_lock_init())
|
|
|
|
|
fatal_exit("could not init openssl locks");
|
|
|
|
|
# endif
|
2012-06-20 11:23:03 -04:00
|
|
|
#elif defined(HAVE_NSS)
|
|
|
|
|
if(NSS_NoDB_Init(NULL) != SECSuccess)
|
|
|
|
|
fatal_exit("could not init NSS");
|
|
|
|
|
#endif /* HAVE_SSL or HAVE_NSS */
|
2008-05-22 05:00:56 -04:00
|
|
|
#ifdef HAVE_TZSET
|
|
|
|
|
/* init timezone info while we are not chrooted yet */
|
|
|
|
|
tzset();
|
|
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
daemon->need_to_exit = 0;
|
2024-07-02 03:08:27 -04:00
|
|
|
modstack_init(&daemon->mods);
|
2007-05-11 10:16:42 -04:00
|
|
|
if(!(daemon->env = (struct module_env*)calloc(1,
|
|
|
|
|
sizeof(*daemon->env)))) {
|
2007-05-16 10:29:46 -04:00
|
|
|
free(daemon);
|
2007-05-11 10:16:42 -04:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2024-04-26 07:32:15 -04:00
|
|
|
daemon->env->modstack = &daemon->mods;
|
2016-12-06 08:42:51 -05:00
|
|
|
/* init edns_known_options */
|
|
|
|
|
if(!edns_known_options_init(daemon->env)) {
|
|
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2007-05-16 10:29:46 -04:00
|
|
|
alloc_init(&daemon->superalloc, NULL, 0);
|
2007-11-19 10:32:55 -05:00
|
|
|
daemon->acl = acl_list_create();
|
|
|
|
|
if(!daemon->acl) {
|
2016-12-06 08:42:51 -05:00
|
|
|
edns_known_options_delete(daemon->env);
|
2007-11-19 10:32:55 -05:00
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2021-08-19 10:12:19 -04:00
|
|
|
daemon->acl_interface = acl_list_create();
|
|
|
|
|
if(!daemon->acl_interface) {
|
|
|
|
|
acl_list_delete(daemon->acl);
|
|
|
|
|
edns_known_options_delete(daemon->env);
|
|
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-08-07 07:57:42 -04:00
|
|
|
daemon->tcl = tcl_list_create();
|
|
|
|
|
if(!daemon->tcl) {
|
2021-08-19 10:12:19 -04:00
|
|
|
acl_list_delete(daemon->acl_interface);
|
2018-08-07 07:57:42 -04:00
|
|
|
acl_list_delete(daemon->acl);
|
|
|
|
|
edns_known_options_delete(daemon->env);
|
|
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2021-08-25 07:37:50 -04:00
|
|
|
listen_setup_locks();
|
2008-09-16 10:08:38 -04:00
|
|
|
if(gettimeofday(&daemon->time_boot, NULL) < 0)
|
|
|
|
|
log_err("gettimeofday: %s", strerror(errno));
|
|
|
|
|
daemon->time_last_stat = daemon->time_boot;
|
2018-01-30 05:35:20 -05:00
|
|
|
if((daemon->env->auth_zones = auth_zones_create()) == 0) {
|
2021-08-19 10:12:19 -04:00
|
|
|
acl_list_delete(daemon->acl_interface);
|
2018-01-30 05:35:20 -05:00
|
|
|
acl_list_delete(daemon->acl);
|
2018-08-07 07:57:42 -04:00
|
|
|
tcl_list_delete(daemon->tcl);
|
2018-01-30 05:35:20 -05:00
|
|
|
edns_known_options_delete(daemon->env);
|
|
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2020-09-30 17:17:53 -04:00
|
|
|
if(!(daemon->env->edns_strings = edns_strings_create())) {
|
2020-07-23 11:17:44 -04:00
|
|
|
auth_zones_delete(daemon->env->auth_zones);
|
2021-08-19 10:12:19 -04:00
|
|
|
acl_list_delete(daemon->acl_interface);
|
2020-07-23 11:17:44 -04:00
|
|
|
acl_list_delete(daemon->acl);
|
|
|
|
|
tcl_list_delete(daemon->tcl);
|
|
|
|
|
edns_known_options_delete(daemon->env);
|
|
|
|
|
free(daemon->env);
|
|
|
|
|
free(daemon);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2007-02-22 11:22:54 -05:00
|
|
|
return daemon;
|
|
|
|
|
}
|
|
|
|
|
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
int setup_acl_for_ports(struct acl_list* list, struct listen_port* port_list)
|
2022-09-11 14:57:41 -04:00
|
|
|
{
|
|
|
|
|
struct acl_addr* acl_node;
|
|
|
|
|
for(; port_list; port_list=port_list->next) {
|
|
|
|
|
if(!port_list->socket) {
|
|
|
|
|
/* This is mainly for testbound where port_list is
|
|
|
|
|
* empty. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(!(acl_node = acl_interface_insert(list,
|
2024-03-15 08:39:49 -04:00
|
|
|
(struct sockaddr_storage*)port_list->socket->addr,
|
|
|
|
|
port_list->socket->addrlen,
|
2022-09-11 14:57:41 -04:00
|
|
|
acl_refuse))) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
port_list->socket->acl = acl_node;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-11 09:49:04 -05:00
|
|
|
int
|
2007-02-23 08:38:54 -05:00
|
|
|
daemon_open_shared_ports(struct daemon* daemon)
|
2007-02-22 11:22:54 -05:00
|
|
|
{
|
|
|
|
|
log_assert(daemon);
|
2008-09-10 11:23:01 -04:00
|
|
|
if(daemon->cfg->port != daemon->listening_port) {
|
2020-08-27 08:53:33 -04:00
|
|
|
char** resif = NULL;
|
|
|
|
|
int num_resif = 0;
|
2014-01-24 08:23:45 -05:00
|
|
|
size_t i;
|
2014-01-27 05:27:19 -05:00
|
|
|
struct listen_port* p0;
|
2014-06-26 04:48:51 -04:00
|
|
|
daemon->reuseport = 0;
|
2014-01-27 05:27:19 -05:00
|
|
|
/* free and close old ports */
|
2014-01-24 06:43:38 -05:00
|
|
|
if(daemon->ports != NULL) {
|
|
|
|
|
for(i=0; i<daemon->num_ports; i++)
|
|
|
|
|
listening_ports_free(daemon->ports[i]);
|
|
|
|
|
free(daemon->ports);
|
|
|
|
|
daemon->ports = NULL;
|
|
|
|
|
}
|
2021-08-19 10:12:19 -04:00
|
|
|
/* clean acl_interface */
|
|
|
|
|
acl_interface_init(daemon->acl_interface);
|
2021-02-26 07:54:10 -05:00
|
|
|
if(!resolve_interface_names(daemon->cfg->ifs,
|
|
|
|
|
daemon->cfg->num_ifs, NULL, &resif, &num_resif))
|
2020-08-27 08:53:33 -04:00
|
|
|
return 0;
|
2014-01-27 05:27:19 -05:00
|
|
|
/* see if we want to reuseport */
|
2014-06-27 10:11:57 -04:00
|
|
|
#ifdef SO_REUSEPORT
|
2014-01-27 05:27:19 -05:00
|
|
|
if(daemon->cfg->so_reuseport && daemon->cfg->num_threads > 0)
|
2014-06-26 04:48:51 -04:00
|
|
|
daemon->reuseport = 1;
|
2014-01-27 05:27:19 -05:00
|
|
|
#endif
|
|
|
|
|
/* try to use reuseport */
|
2022-09-11 14:57:41 -04:00
|
|
|
p0 = listening_ports_open(daemon->cfg, resif, num_resif,
|
|
|
|
|
&daemon->reuseport);
|
2014-01-27 05:27:19 -05:00
|
|
|
if(!p0) {
|
|
|
|
|
listening_ports_free(p0);
|
2020-08-27 08:53:33 -04:00
|
|
|
config_del_strarray(resif, num_resif);
|
2014-01-27 05:27:19 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|
2014-06-26 04:48:51 -04:00
|
|
|
if(daemon->reuseport) {
|
2014-01-27 05:27:19 -05:00
|
|
|
/* reuseport was successful, allocate for it */
|
2014-01-27 05:41:16 -05:00
|
|
|
daemon->num_ports = (size_t)daemon->cfg->num_threads;
|
2014-01-27 05:27:19 -05:00
|
|
|
} else {
|
|
|
|
|
/* do the normal, singleportslist thing,
|
|
|
|
|
* reuseport not enabled or did not work */
|
|
|
|
|
daemon->num_ports = 1;
|
|
|
|
|
}
|
2014-01-24 06:43:38 -05:00
|
|
|
if(!(daemon->ports = (struct listen_port**)calloc(
|
|
|
|
|
daemon->num_ports, sizeof(*daemon->ports)))) {
|
2014-01-27 05:27:19 -05:00
|
|
|
listening_ports_free(p0);
|
2020-08-27 08:53:33 -04:00
|
|
|
config_del_strarray(resif, num_resif);
|
2008-09-10 11:23:01 -04:00
|
|
|
return 0;
|
2014-01-24 06:43:38 -05:00
|
|
|
}
|
2014-01-27 05:27:19 -05:00
|
|
|
daemon->ports[0] = p0;
|
2022-09-11 14:57:41 -04:00
|
|
|
if(!setup_acl_for_ports(daemon->acl_interface,
|
|
|
|
|
daemon->ports[0])) {
|
|
|
|
|
listening_ports_free(p0);
|
|
|
|
|
config_del_strarray(resif, num_resif);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2014-06-26 04:48:51 -04:00
|
|
|
if(daemon->reuseport) {
|
2014-01-27 05:27:19 -05:00
|
|
|
/* continue to use reuseport */
|
|
|
|
|
for(i=1; i<daemon->num_ports; i++) {
|
|
|
|
|
if(!(daemon->ports[i]=
|
|
|
|
|
listening_ports_open(daemon->cfg,
|
2020-08-27 08:53:33 -04:00
|
|
|
resif, num_resif,
|
2014-06-26 04:48:51 -04:00
|
|
|
&daemon->reuseport))
|
|
|
|
|
|| !daemon->reuseport ) {
|
2014-01-27 05:27:19 -05:00
|
|
|
for(i=0; i<daemon->num_ports; i++)
|
|
|
|
|
listening_ports_free(daemon->ports[i]);
|
|
|
|
|
free(daemon->ports);
|
|
|
|
|
daemon->ports = NULL;
|
2022-09-11 14:57:41 -04:00
|
|
|
config_del_strarray(resif, num_resif);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if(!setup_acl_for_ports(daemon->acl_interface,
|
|
|
|
|
daemon->ports[i])) {
|
|
|
|
|
for(i=0; i<daemon->num_ports; i++)
|
|
|
|
|
listening_ports_free(daemon->ports[i]);
|
|
|
|
|
free(daemon->ports);
|
|
|
|
|
daemon->ports = NULL;
|
2020-08-27 08:53:33 -04:00
|
|
|
config_del_strarray(resif, num_resif);
|
2014-01-27 05:27:19 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|
2014-01-24 06:43:38 -05:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-27 08:53:33 -04:00
|
|
|
config_del_strarray(resif, num_resif);
|
2008-09-10 11:23:01 -04:00
|
|
|
daemon->listening_port = daemon->cfg->port;
|
|
|
|
|
}
|
|
|
|
|
if(!daemon->cfg->remote_control_enable && daemon->rc_port) {
|
|
|
|
|
listening_ports_free(daemon->rc_ports);
|
|
|
|
|
daemon->rc_ports = NULL;
|
|
|
|
|
daemon->rc_port = 0;
|
|
|
|
|
}
|
|
|
|
|
if(daemon->cfg->remote_control_enable &&
|
|
|
|
|
daemon->cfg->control_port != daemon->rc_port) {
|
|
|
|
|
listening_ports_free(daemon->rc_ports);
|
|
|
|
|
if(!(daemon->rc_ports=daemon_remote_open_ports(daemon->cfg)))
|
|
|
|
|
return 0;
|
|
|
|
|
daemon->rc_port = daemon->cfg->control_port;
|
|
|
|
|
}
|
2007-02-22 11:22:54 -05:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-11 09:49:04 -05:00
|
|
|
int
|
|
|
|
|
daemon_privileged(struct daemon* daemon)
|
|
|
|
|
{
|
|
|
|
|
daemon->env->cfg = daemon->cfg;
|
|
|
|
|
daemon->env->alloc = &daemon->superalloc;
|
|
|
|
|
daemon->env->worker = NULL;
|
2024-07-03 07:53:44 -04:00
|
|
|
if(!modstack_call_startup(&daemon->mods, daemon->cfg->module_conf,
|
2020-01-11 09:49:04 -05:00
|
|
|
daemon->env)) {
|
2024-07-01 10:10:07 -04:00
|
|
|
fatal_exit("failed to startup modules");
|
2020-01-11 09:49:04 -05:00
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 10:16:42 -04:00
|
|
|
/**
|
2007-12-04 08:23:41 -05:00
|
|
|
* Setup modules. setup module stack.
|
2007-05-11 10:16:42 -04:00
|
|
|
* @param daemon: the daemon
|
|
|
|
|
*/
|
|
|
|
|
static void daemon_setup_modules(struct daemon* daemon)
|
|
|
|
|
{
|
|
|
|
|
daemon->env->cfg = daemon->cfg;
|
|
|
|
|
daemon->env->alloc = &daemon->superalloc;
|
|
|
|
|
daemon->env->worker = NULL;
|
2024-07-03 07:53:44 -04:00
|
|
|
if(daemon->mods_inited) {
|
|
|
|
|
modstack_call_deinit(&daemon->mods, daemon->env);
|
|
|
|
|
}
|
2007-08-21 09:12:10 -04:00
|
|
|
daemon->env->need_to_validate = 0; /* set by module init below */
|
2024-07-03 07:53:44 -04:00
|
|
|
if(!modstack_call_init(&daemon->mods, daemon->cfg->module_conf,
|
2007-12-04 08:23:41 -05:00
|
|
|
daemon->env)) {
|
2024-07-03 07:53:44 -04:00
|
|
|
fatal_exit("failed to init modules");
|
2007-05-11 10:16:42 -04:00
|
|
|
}
|
2024-07-03 07:53:44 -04:00
|
|
|
daemon->mods_inited = 1;
|
2016-12-06 08:42:51 -05:00
|
|
|
log_edns_known_options(VERB_ALGO, daemon->env);
|
2007-05-11 10:16:42 -04:00
|
|
|
}
|
|
|
|
|
|
2008-04-11 09:24:49 -04:00
|
|
|
/**
|
|
|
|
|
* Obtain allowed port numbers, concatenate the list, and shuffle them
|
|
|
|
|
* (ready to be handed out to threads).
|
|
|
|
|
* @param daemon: the daemon. Uses rand and cfg.
|
|
|
|
|
* @param shufport: the portlist output.
|
|
|
|
|
* @return number of ports available.
|
|
|
|
|
*/
|
2010-07-07 09:13:36 -04:00
|
|
|
static int daemon_get_shufport(struct daemon* daemon, int* shufport)
|
2008-04-11 09:24:49 -04:00
|
|
|
{
|
|
|
|
|
int i, n, k, temp;
|
|
|
|
|
int avail = 0;
|
|
|
|
|
for(i=0; i<65536; i++) {
|
|
|
|
|
if(daemon->cfg->outgoing_avail_ports[i]) {
|
|
|
|
|
shufport[avail++] = daemon->cfg->
|
|
|
|
|
outgoing_avail_ports[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(avail == 0)
|
|
|
|
|
fatal_exit("no ports are permitted for UDP, add "
|
|
|
|
|
"with outgoing-port-permit");
|
|
|
|
|
/* Knuth shuffle */
|
|
|
|
|
n = avail;
|
|
|
|
|
while(--n > 0) {
|
2010-03-18 10:42:22 -04:00
|
|
|
k = ub_random_max(daemon->rand, n+1); /* 0<= k<= n */
|
2008-04-11 09:24:49 -04:00
|
|
|
temp = shufport[k];
|
|
|
|
|
shufport[k] = shufport[n];
|
|
|
|
|
shufport[n] = temp;
|
|
|
|
|
}
|
|
|
|
|
return avail;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-08 16:39:13 -05:00
|
|
|
/**
|
|
|
|
|
* Clear and delete per-worker alloc caches, and free memory maintained in
|
|
|
|
|
* superalloc.
|
|
|
|
|
* The rrset and message caches must be empty at the time of call.
|
|
|
|
|
* @param daemon: the daemon that maintains the alloc caches to be cleared.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
daemon_clear_allocs(struct daemon* daemon)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2024-05-31 06:09:35 -04:00
|
|
|
/* daemon->num may be different during reloads (after configuration
|
|
|
|
|
* read). Use old_num which has the correct value used to setup the
|
|
|
|
|
* worker_allocs */
|
|
|
|
|
for(i=0; i<daemon->old_num; i++) {
|
2021-11-08 16:39:13 -05:00
|
|
|
alloc_clear(daemon->worker_allocs[i]);
|
|
|
|
|
free(daemon->worker_allocs[i]);
|
|
|
|
|
}
|
|
|
|
|
free(daemon->worker_allocs);
|
|
|
|
|
daemon->worker_allocs = NULL;
|
|
|
|
|
|
|
|
|
|
alloc_clear_special(&daemon->superalloc);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
/**
|
|
|
|
|
* Allocate empty worker structures. With backptr and thread-number,
|
|
|
|
|
* from 0..numthread initialised. Used as user arguments to new threads.
|
2008-04-11 09:24:49 -04:00
|
|
|
* Creates the daemon random generator if it does not exist yet.
|
|
|
|
|
* The random generator stays existing between reloads with a unique state.
|
2007-02-26 09:49:11 -05:00
|
|
|
* @param daemon: the daemon with (new) config settings.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
daemon_create_workers(struct daemon* daemon)
|
2007-02-22 11:22:54 -05:00
|
|
|
{
|
2008-04-11 09:24:49 -04:00
|
|
|
int i, numport;
|
|
|
|
|
int* shufport;
|
2007-02-26 09:49:11 -05:00
|
|
|
log_assert(daemon && daemon->cfg);
|
2008-04-11 09:24:49 -04:00
|
|
|
if(!daemon->rand) {
|
2019-11-20 05:28:53 -05:00
|
|
|
daemon->rand = ub_initstate(NULL);
|
2008-04-11 09:24:49 -04:00
|
|
|
if(!daemon->rand)
|
|
|
|
|
fatal_exit("could not init random generator");
|
2017-06-27 11:23:17 -04:00
|
|
|
hash_set_raninit((uint32_t)ub_random(daemon->rand));
|
2008-04-11 09:24:49 -04:00
|
|
|
}
|
|
|
|
|
shufport = (int*)calloc(65536, sizeof(int));
|
|
|
|
|
if(!shufport)
|
|
|
|
|
fatal_exit("out of memory during daemon init");
|
|
|
|
|
numport = daemon_get_shufport(daemon, shufport);
|
2008-04-11 10:10:16 -04:00
|
|
|
verbose(VERB_ALGO, "total of %d outgoing ports available", numport);
|
DNSoverQUIC (#871)
* - dnsoverquic, configure --with-libngtcp2 option.
* - dnsoverquic, create comm_point for doq and receive cmsg local address.
* - dnsoverquic, less obtrusive debug.
* - dnsoverquic, log and fix local port number. Neater subroutines and ifdefs.
* - dnsoverquic, add testcode/doqclient.
* - dnsoverquic, review fixes on doqclient.
* - dnsoverquic, fix unit test testbound link.
* - dnsoverquic, parse query in doqclient.
* - dnsoverquic, link with libngtcp2_crypto_openssl and code for doqclient.
* - dnsoverquic, random routine for doqclient and fix ngaddr allocation, and
check ub_initstate return.
* - dnsoverquic, fix doqclient free of allocated ngaddr addresses.
* - dnsoverquic, enable debug output with -v for doqclient.
* - dnsoverquic, create and set TLS object and TLS context in doqclient.
* - dnsoverquic, work on quic tls context in doqclient.
* - dnsoverquic, set default dnsoverquic port to the standardized 853 port.
* - dnsoverquic, remove debug comment.
* - dnsoverquic, dns-over-quic quic-port: 853 config option.
* - dnsoverquic, log type of interface created at start of unbound.
* - dnsoverquic, log type of no tls https as https when interface is created.
* - dnsoverquic, setup client quic tls methods.
* - dnsoverquic, event work in doqclient.
* - dnsoverquic, explain in documentation that QUIC uses UDP.
* - dnsoverquic, make doqclient exit.
* - dnsoverquic, doqclient cleanup run routine.
* - dnsoverquic, doqclient code nicer.
* - dnsoverquic, doqclient read and timer.
* - dnsoverquic, doqclient write work.
* - dnsoverquic, review fixes.
* - dnsoverquic, detect openssl quic support at configure time.
* - dnsoverquic, do not allow QUIC on port 53 to stop confusion of DoQ and DNS.
* - dnsoverquic, in doqclient, when idle close is returned, drop the connection
without calling ngtcp2_conn_write_connection_close.
* - dnsoverquic, in doqclient, log callbacks.
* - dnsoverquic, in doqclient add extend_max_local_streams_bidi callback.
* - dnsoverquic, in doqclient add client query lists.
* - dnsoverquic, in doqclient, code cleaner, log text nicer.
* - dnsoverquic, in doqclient, work on write_streams.
* - dnsoverquic, in doqclient, use signed int for stream_id, work on the
ngtcp2_recv_stream_data callback.
* - dnsoverquic, in doqclient, print result and fixes for recv data.
* - dnsoverquic, in doqclient, add the event callbacks to fptr wlist.
* - dnsoverquic, in doqclient, when already expired, use zero timeout timer.
* - dnsoverquic, in doqclient, ignore unused return codes from
ngtcp2_conn_writev_stream.
* - dnsoverquic, add doqclient event functions to the unbound-dnstap-socket
test tool for linking.
* - dnsoverquic, in doqclient, fix multiple operands for the commandline.
neater dns message output.
* - dnsoverquic, in doqclient, store packet when write blocks and try later.
* - dnsoverquic, in doqclient, limit number of packets and number of bytes sent.
* - dnsoverquic, in doqclient, better size estimate for outgoing packet.
* - dnsoverquic, in doqclient, fix that already written next packet is not
counted for data length to send.
* - dnsoverquic, in doqclient, early data transmission and session resumption.
* - dnsoverquic, send version negotiation packet.
* - dnsoverquic, send retry and accept the connection.
* - dnsoverquic, storage structures.
* - dnsoverquic, doq connection setup.
* - dnsoverquic, neater code layout for new conn. Fix verbosity of log print.
* - dnsoverquic, doq conn callback functions.
* - dnsoverquic, doq_fill_rand routine in header file.
* - dnsoverquic, keep track of connection ids.
* - dnsoverquic, get_new_connection_id callback.
* - dnsoverquic, create doq_conid tree.
* - dnsoverquic, settings for server connection.
* - dnsoverquic, tls context.
* - dnsoverquic, sendmsg error handling.
* - dnsoverquic, neat code.
* - dnsoverquic, track doq connection last error.
* - dnsoverquic, neater packet address parameters.
* - dnsoverquic, fix uninitialized bytes in msg control in doq sendmsg, and
fix tree cleanup of conid tree.
* - dnsoverquic, better usage text for doqclient.
* - dnsoverquic, neat code.
* - dnsoverquic, connection receive packet handling.
* - dnsoverquic, debug output.
* - dnsoverquic, debug switched meaning of scid and dcid gives
ERR_TRANSPORT_PARAM.
* - dnsoverquic, remove debug output.
* - dnsoverquic, connection delete routine and error from connection read in
more detail with less clutter.
* - dnsoverquic, write to stream, and receive stream data, log packet.
* - dnsoverquic, alpn set up.
* - dnsoverquic, connection close.
* - dnsoverquic, doq_table and locks.
* - dnsoverquic, fix tests.
* - dnsoverquic, better locking.
* - dnsoverquic, doq_stream.
* - dnsoverquic, remove compile warning.
* - dnsoverquic, doq_stream receive data.
* - dnsoverquic, fixes for locks and keep length bytes allocated.
* - dnsoverquic, lock connection on initial insertion.
* - dnsoverquic, reply information, and reply buffer.
* - dnsoverquic, reply info from cache, local-zone and recursion lookups.
* - dnsoverquic, spelling in comment about buffer storage.
* - dnsoverquic, stream write list and doqclient fixes to exit and printout.
* - dnsoverquic, doqclient -q option for short printout.
* - dnsoverquic, unit test with local data reply.
* - dnsoverquic, write connection and write event is set.
* - dnsoverquic, neater logging for write event connection stream writes.
* - dnsoverquic, log remote connection when the streams are written for it.
* - dnsoverquic, better threaded use, threads can write to doq connections at
the same time.
* - dnsoverquic, unit test for the calculation of connection size with a query.
* - dnsoverquic, use less memory per connection.
* - dnsoverquic, remove unit test output.
* - dnsoverquic, add MSG_DONTWAIT so that there is no mistakenly blocking
socket operations.
* - dnsoverquic, doqclient logs address on connection failures.
* - dnsoverquic, compat code for clock get time routine.
* - dnsoverquic, use skip_test for doq unit test.
* - dnsoverquic, fixes for proxyprotocol, use remote_addr and set proxyprotocol
disabled on the doq connection.
* - dnsoverquic, doqclient sets log identity to its name, instead of "unbound".
* - dnsoverquic, handle blocked udp packet writes.
* - dnsoverquic, fix function documentation for verbose_print_addr from
services/listen_dnsport.c.
* - dnsoverquic, fix doq_conn lock protection. The checklock allows to set
the output file name, and doqclient uses that. Print place of lock_protect.
* - dnsoverquic, neater buffer clear when write of blocked packet fails, make
sure that memory area does not overlap for blocked packet addresses when
write of blocked packet fails, and size blocked packet buffer to the pkt buf.
* - dnsoverquic, move lock check after the test to test script in doq test.
* - dnsoverquic, the doq test uses valgrind when enabled.
* - dnsoverquic, git ignore the doqclient test.
* - dnsoverquic, limit the buffer for packets to max packet size with some more.
* - dnsoverquic, spelling fix.
* - dnsoverquic, timer work, structure and adds and deletes.
* - dnsoverquic, timer_tree uses table.lock.
* - dnsoverquic, fix timer tree remove and spelling in header file comment.
* - dnsoverquic, fix testbound for timer compare function linkage.
* - dnsoverquic, timer set add debug output.
* - dnsoverquic, doq_conn_check_timer function.
* - dnsoverquic, doq_done_setup_timer_and_write function.
* - dnsoverquic, fix that doq conn is not deleted whilst editing write and timer.
* - dnsoverquic, Fix #861 make ERROR netevent.h:1073:32: error: field 'blocked_pkt_pi' has incomplete type
* - dnsoverquic, timer element has timeout setup when socket callback complete.
* - dnsoverquic, fix unit test compile.
* - dnsoverquic, timer callback routine, handle timeout and close and delete the
connection if necessary.
* - dnsoverquic, timer pickup stops at current time.
* - dnsoverquic, timer comparable with the event base time.
* - dnsoverquic, erase marked time when timer disabled.
* - dnsoverquic, fix timer to set correctly and lock popped write connection
early, before it is modified.
* - dnsoverquic, fix to unlock connection lock when it is unlinked and deleted.
* - dnsoverquic, fix to unlock connection lock when it is deleted because it is
a duplicate connection.
* - dnsoverquic, fix that doq timer is not disabled when not set.
* - dnsoverquic, quic-size: 8m maximum number of bytes for QUIC buffers.
* - dnsoverquic, flex and bison.
* - dnsoverquic, quic-size turn away new connections when full.
* - dnsoverquic, doqclient outputs stream reset information.
* - dnsoverquic, detect stream close and reset.
* - dnsoverquic, free stream buffers when data is acked and stream is closed.
* - dnsoverquic, delete stream when closed. Unlink it. Allow stream_id 4 as first.
* - dnsoverquic, stats output for mem.quic and num.query.quic.
* - dnsoverquic, review fix.
* - dnsoverquic, fix when compiled without ngtcp2.
* - dnsoverquic, fix to detect ngtcp2_crypto_quictls for openssl crypto, after
change in libngtcp2.
* - dnsoverquic, fix for newer ngtcp2 versions. detect ngtcp2_ccerr_default,
ngtcp2/ngtcp2_crypto_quictls.h, struct ngtcp2_pkt_hd.tokenlen,
struct ngtcp2_settings.tokenlen and struct ngtcp2_version_cid.
* - dnsoverquic, fix for newer ngtcp2 version, detect number of arguments for
ngtcp2_conn_shutdown_stream.
* - dnsoverquic, fix for newer ngtcp2.
* - dnsoverquic, use the functions from util/timeval_func.h.
* - dnsoverquic, fix in doqclient only write transport parameters once.
* - dnsoverquic, debug log output removed.
* - dnsoverquic, fix in doqclient to work with renamed NGTCP2_CC_ALGO_BBR_V2
from ngtcp2.
* - dnsoverquic, fix to check in doq_server_socket_create that tls-service-key
and tls-service-pem have a value.
* - dnsoverquic, fix to error when doq_server_socket_create fails.
* - dnsoverquic, improve linebreaks in configparser additions.
* - dnsoverquic, fix port from interface pickup after main branch change.
* Fix getting user data from SSL, fix calloc warning.
* Fix fwrite return value check in doqclient
* - timeval_substruct from timeval_func.h
- lock_protect also for HAVE_NGTCP2_CCERR_DEFAULT
- fix doq logging for inet_ntop failures
* - memset for consistency
- no value returned from msghdr_get_ecn when S_SPLINT_S is defined
* - dnsoverquic, rerun autoconf.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2024-10-09 04:32:03 -04:00
|
|
|
|
|
|
|
|
#ifdef HAVE_NGTCP2
|
|
|
|
|
daemon->doq_table = doq_table_create(daemon->cfg, daemon->rand);
|
|
|
|
|
if(!daemon->doq_table)
|
|
|
|
|
fatal_exit("could not create doq_table: out of memory");
|
|
|
|
|
#endif
|
2008-04-11 09:24:49 -04:00
|
|
|
|
2011-08-26 02:50:23 -04:00
|
|
|
daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1);
|
2015-07-24 07:44:58 -04:00
|
|
|
if(daemon->reuseport && (int)daemon->num < (int)daemon->num_ports) {
|
|
|
|
|
log_warn("cannot reduce num-threads to %d because so-reuseport "
|
|
|
|
|
"so continuing with %d threads.", (int)daemon->num,
|
|
|
|
|
(int)daemon->num_ports);
|
2015-07-24 07:49:35 -04:00
|
|
|
daemon->num = (int)daemon->num_ports;
|
2015-07-24 07:44:58 -04:00
|
|
|
}
|
2007-02-22 11:22:54 -05:00
|
|
|
daemon->workers = (struct worker**)calloc((size_t)daemon->num,
|
|
|
|
|
sizeof(struct worker*));
|
2016-07-22 03:02:03 -04:00
|
|
|
if(!daemon->workers)
|
|
|
|
|
fatal_exit("out of memory during daemon init");
|
2014-08-05 03:57:52 -04:00
|
|
|
if(daemon->cfg->dnstap) {
|
|
|
|
|
#ifdef USE_DNSTAP
|
2020-02-14 08:44:02 -05:00
|
|
|
daemon->dtenv = dt_create(daemon->cfg);
|
2014-08-05 03:57:52 -04:00
|
|
|
if (!daemon->dtenv)
|
|
|
|
|
fatal_exit("dt_create failed");
|
|
|
|
|
#else
|
|
|
|
|
fatal_exit("dnstap enabled in config but not built with dnstap support");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2007-02-26 09:49:11 -05:00
|
|
|
for(i=0; i<daemon->num; i++) {
|
2008-04-11 09:24:49 -04:00
|
|
|
if(!(daemon->workers[i] = worker_create(daemon, i,
|
|
|
|
|
shufport+numport*i/daemon->num,
|
|
|
|
|
numport*(i+1)/daemon->num - numport*i/daemon->num)))
|
|
|
|
|
/* the above is not ports/numthr, due to rounding */
|
2007-03-29 09:00:36 -04:00
|
|
|
fatal_exit("could not create worker");
|
2007-02-26 09:49:11 -05:00
|
|
|
}
|
2021-11-08 16:39:13 -05:00
|
|
|
/* create per-worker alloc caches if not reusing existing ones. */
|
|
|
|
|
if(!daemon->worker_allocs) {
|
|
|
|
|
daemon->worker_allocs = (struct alloc_cache**)calloc(
|
|
|
|
|
(size_t)daemon->num, sizeof(struct alloc_cache*));
|
|
|
|
|
if(!daemon->worker_allocs)
|
|
|
|
|
fatal_exit("could not allocate worker allocs");
|
|
|
|
|
for(i=0; i<daemon->num; i++) {
|
|
|
|
|
struct alloc_cache* alloc = calloc(1,
|
|
|
|
|
sizeof(struct alloc_cache));
|
|
|
|
|
if (!alloc)
|
|
|
|
|
fatal_exit("could not allocate worker alloc");
|
|
|
|
|
alloc_init(alloc, &daemon->superalloc, i);
|
|
|
|
|
daemon->worker_allocs[i] = alloc;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-11 09:24:49 -04:00
|
|
|
free(shufport);
|
2007-02-26 09:49:11 -05:00
|
|
|
}
|
|
|
|
|
|
2010-07-07 09:13:36 -04:00
|
|
|
#ifdef THREADS_DISABLED
|
2007-02-27 04:28:53 -05:00
|
|
|
/**
|
|
|
|
|
* Close all pipes except for the numbered thread.
|
|
|
|
|
* @param daemon: daemon to close pipes in.
|
|
|
|
|
* @param thr: thread number 0..num-1 of thread to skip.
|
|
|
|
|
*/
|
2010-07-07 09:13:36 -04:00
|
|
|
static void close_other_pipes(struct daemon* daemon, int thr)
|
2007-02-27 04:28:53 -05:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0; i<daemon->num; i++)
|
|
|
|
|
if(i!=thr) {
|
2008-12-03 08:52:00 -05:00
|
|
|
if(i==0) {
|
|
|
|
|
/* only close read part, need to write stats */
|
|
|
|
|
tube_close_read(daemon->workers[i]->cmd);
|
|
|
|
|
} else {
|
|
|
|
|
/* complete close channel to others */
|
|
|
|
|
tube_delete(daemon->workers[i]->cmd);
|
|
|
|
|
daemon->workers[i]->cmd = NULL;
|
|
|
|
|
}
|
2007-02-27 04:28:53 -05:00
|
|
|
}
|
|
|
|
|
}
|
2010-07-07 09:13:36 -04:00
|
|
|
#endif /* THREADS_DISABLED */
|
2007-02-27 04:28:53 -05:00
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
/**
|
|
|
|
|
* Function to start one thread.
|
|
|
|
|
* @param arg: user argument.
|
|
|
|
|
* @return: void* user return value could be used for thread_join results.
|
|
|
|
|
*/
|
|
|
|
|
static void*
|
|
|
|
|
thread_start(void* arg)
|
|
|
|
|
{
|
|
|
|
|
struct worker* worker = (struct worker*)arg;
|
2014-01-24 06:43:38 -05:00
|
|
|
int port_num = 0;
|
2007-03-02 04:03:14 -05:00
|
|
|
log_thread_set(&worker->thread_num);
|
2007-02-26 09:49:11 -05:00
|
|
|
ub_thread_blocksigs();
|
2008-06-16 09:39:46 -04:00
|
|
|
#ifdef THREADS_DISABLED
|
2007-02-27 04:28:53 -05:00
|
|
|
/* close pipe ends used by main */
|
2008-08-11 09:58:33 -04:00
|
|
|
tube_close_write(worker->cmd);
|
2007-02-27 04:28:53 -05:00
|
|
|
close_other_pipes(worker->daemon, worker->thread_num);
|
2007-03-29 09:00:36 -04:00
|
|
|
#endif
|
2014-06-27 10:11:57 -04:00
|
|
|
#ifdef SO_REUSEPORT
|
2014-01-24 06:43:38 -05:00
|
|
|
if(worker->daemon->cfg->so_reuseport)
|
2015-07-24 03:02:14 -04:00
|
|
|
port_num = worker->thread_num % worker->daemon->num_ports;
|
2014-01-24 06:43:38 -05:00
|
|
|
else
|
|
|
|
|
port_num = 0;
|
|
|
|
|
#endif
|
|
|
|
|
if(!worker_init(worker, worker->daemon->cfg,
|
|
|
|
|
worker->daemon->ports[port_num], 0))
|
2007-03-29 09:00:36 -04:00
|
|
|
fatal_exit("Could not initialize thread");
|
2007-02-26 09:49:11 -05:00
|
|
|
|
|
|
|
|
worker_work(worker);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2007-02-22 11:22:54 -05:00
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
/**
|
|
|
|
|
* Fork and init the other threads. Main thread returns for special handling.
|
|
|
|
|
* @param daemon: the daemon with other threads to fork.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
daemon_start_others(struct daemon* daemon)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
log_assert(daemon);
|
2007-02-27 09:28:20 -05:00
|
|
|
verbose(VERB_ALGO, "start threads");
|
2007-02-26 09:49:11 -05:00
|
|
|
/* skip i=0, is this thread */
|
|
|
|
|
for(i=1; i<daemon->num; i++) {
|
|
|
|
|
ub_thread_create(&daemon->workers[i]->thr_id,
|
|
|
|
|
thread_start, daemon->workers[i]);
|
2008-06-16 09:39:46 -04:00
|
|
|
#ifdef THREADS_DISABLED
|
2007-02-27 04:28:53 -05:00
|
|
|
/* close pipe end of child */
|
2008-08-11 10:02:37 -04:00
|
|
|
tube_close_read(daemon->workers[i]->cmd);
|
2007-02-27 04:28:53 -05:00
|
|
|
#endif /* no threads */
|
2007-02-26 09:49:11 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stop the other threads.
|
|
|
|
|
* @param daemon: the daemon with other threads.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
daemon_stop_others(struct daemon* daemon)
|
|
|
|
|
{
|
2007-02-27 04:28:53 -05:00
|
|
|
int i;
|
2007-02-26 09:49:11 -05:00
|
|
|
log_assert(daemon);
|
2007-02-27 09:28:20 -05:00
|
|
|
verbose(VERB_ALGO, "stop threads");
|
2007-02-26 09:49:11 -05:00
|
|
|
/* skip i=0, is this thread */
|
|
|
|
|
/* use i=0 buffer for sending cmds; because we are #0 */
|
|
|
|
|
for(i=1; i<daemon->num; i++) {
|
2008-07-23 05:23:03 -04:00
|
|
|
worker_send_cmd(daemon->workers[i], worker_cmd_quit);
|
2007-02-26 09:49:11 -05:00
|
|
|
}
|
2007-10-16 08:26:09 -04:00
|
|
|
/* wait for them to quit */
|
2007-02-26 09:49:11 -05:00
|
|
|
for(i=1; i<daemon->num; i++) {
|
|
|
|
|
/* join it to make sure its dead */
|
2007-02-27 09:28:20 -05:00
|
|
|
verbose(VERB_ALGO, "join %d", i);
|
2007-02-27 04:28:53 -05:00
|
|
|
ub_thread_join(daemon->workers[i]->thr_id);
|
2007-02-27 09:28:20 -05:00
|
|
|
verbose(VERB_ALGO, "join success %d", i);
|
2007-02-26 09:49:11 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
daemon_fork(struct daemon* daemon)
|
|
|
|
|
{
|
2017-03-07 09:58:51 -05:00
|
|
|
int have_view_respip_cfg = 0;
|
2019-08-14 10:08:19 -04:00
|
|
|
#ifdef HAVE_SYSTEMD
|
2019-08-14 09:51:28 -04:00
|
|
|
int ret;
|
2019-08-14 10:08:19 -04:00
|
|
|
#endif
|
2017-03-07 09:58:51 -05:00
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
log_assert(daemon);
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!(daemon->env->views = views_create()))
|
2016-10-05 05:36:25 -04:00
|
|
|
fatal_exit("Could not create views: out of memory");
|
|
|
|
|
/* create individual views and their localzone/data trees */
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!views_apply_cfg(daemon->env->views, daemon->cfg))
|
2016-10-05 05:36:25 -04:00
|
|
|
fatal_exit("Could not set up views");
|
|
|
|
|
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!acl_list_apply_cfg(daemon->acl, daemon->cfg, daemon->env->views))
|
2007-11-19 10:32:55 -05:00
|
|
|
fatal_exit("Could not setup access control list");
|
2021-08-19 10:12:19 -04:00
|
|
|
if(!acl_interface_apply_cfg(daemon->acl_interface, daemon->cfg,
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
daemon->env->views))
|
2021-08-19 10:12:19 -04:00
|
|
|
fatal_exit("Could not setup interface control list");
|
2018-08-07 07:57:42 -04:00
|
|
|
if(!tcl_list_apply_cfg(daemon->tcl, daemon->cfg))
|
|
|
|
|
fatal_exit("Could not setup TCP connection limits");
|
2017-03-20 10:55:31 -04:00
|
|
|
if(daemon->cfg->dnscrypt) {
|
|
|
|
|
#ifdef USE_DNSCRYPT
|
|
|
|
|
daemon->dnscenv = dnsc_create();
|
|
|
|
|
if (!daemon->dnscenv)
|
|
|
|
|
fatal_exit("dnsc_create failed");
|
|
|
|
|
dnsc_apply_cfg(daemon->dnscenv, daemon->cfg);
|
|
|
|
|
#else
|
|
|
|
|
fatal_exit("dnscrypt enabled in config but unbound was not built with "
|
2017-03-20 11:16:19 -04:00
|
|
|
"dnscrypt support");
|
2017-03-20 10:55:31 -04:00
|
|
|
#endif
|
|
|
|
|
}
|
Cookie secret file (#1090)
* - cookie-secret-file, define struct.
* - cookie-secret-file, add config option, create, read and delete struct.
* - cookie-secret-file, check cookie secrets for cookie validation.
* - cookie-secret-file, unbound-control add_cookie_secret, drop_cookie_secret,
activate_cookie_secret and print_cookie_secrets.
* - cookie-secret-file, test and fix locks, renew writes a fresh cookie,
staging cookies get a fresh cookie and spelling in error message.
* - cookie-secret-file, remove unused variable from cookie file unit test.
* Remove unshare and faketime dependencies for cookie_file test; documentation nits.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2024-08-02 07:32:08 -04:00
|
|
|
if(daemon->cfg->cookie_secret_file &&
|
|
|
|
|
daemon->cfg->cookie_secret_file[0]) {
|
|
|
|
|
if(!(daemon->cookie_secrets = cookie_secrets_create()))
|
|
|
|
|
fatal_exit("Could not create cookie_secrets: out of memory");
|
|
|
|
|
if(!cookie_secrets_apply_cfg(daemon->cookie_secrets,
|
|
|
|
|
daemon->cfg->cookie_secret_file))
|
|
|
|
|
fatal_exit("Could not setup cookie_secrets");
|
|
|
|
|
}
|
2016-10-05 05:36:25 -04:00
|
|
|
/* create global local_zones */
|
2007-11-22 04:30:44 -05:00
|
|
|
if(!(daemon->local_zones = local_zones_create()))
|
|
|
|
|
fatal_exit("Could not create local zones: out of memory");
|
|
|
|
|
if(!local_zones_apply_cfg(daemon->local_zones, daemon->cfg))
|
|
|
|
|
fatal_exit("Could not set up local zones");
|
2024-01-04 10:53:02 -05:00
|
|
|
if(!(daemon->env->fwds = forwards_create()) ||
|
|
|
|
|
!forwards_apply_cfg(daemon->env->fwds, daemon->cfg))
|
|
|
|
|
fatal_exit("Could not set forward zones");
|
2024-01-05 07:36:41 -05:00
|
|
|
if(!(daemon->env->hints = hints_create()) ||
|
|
|
|
|
!hints_apply_cfg(daemon->env->hints, daemon->cfg))
|
|
|
|
|
fatal_exit("Could not set root or stub hints");
|
2007-05-11 10:16:42 -04:00
|
|
|
|
2017-03-07 09:58:51 -05:00
|
|
|
/* process raw response-ip configuration data */
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!(daemon->env->respip_set = respip_set_create()))
|
2017-03-07 09:58:51 -05:00
|
|
|
fatal_exit("Could not create response IP set");
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!respip_global_apply_cfg(daemon->env->respip_set, daemon->cfg))
|
2017-03-07 09:58:51 -05:00
|
|
|
fatal_exit("Could not set up response IP set");
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(!respip_views_apply_cfg(daemon->env->views, daemon->cfg,
|
2017-03-07 09:58:51 -05:00
|
|
|
&have_view_respip_cfg))
|
|
|
|
|
fatal_exit("Could not set up per-view response IP sets");
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
daemon->use_response_ip = !respip_set_is_empty(
|
|
|
|
|
daemon->env->respip_set) || have_view_respip_cfg;
|
2020-10-22 06:10:46 -04:00
|
|
|
|
|
|
|
|
/* setup modules */
|
|
|
|
|
daemon_setup_modules(daemon);
|
|
|
|
|
|
2018-01-30 05:35:20 -05:00
|
|
|
/* read auth zonefiles */
|
2019-07-16 12:43:16 -04:00
|
|
|
if(!auth_zones_apply_cfg(daemon->env->auth_zones, daemon->cfg, 1,
|
2020-10-22 06:10:46 -04:00
|
|
|
&daemon->use_rpz, daemon->env, &daemon->mods))
|
2018-01-30 05:35:20 -05:00
|
|
|
fatal_exit("auth_zones could not be setup");
|
2017-03-07 09:58:51 -05:00
|
|
|
|
2020-09-30 17:17:53 -04:00
|
|
|
/* Set-up EDNS strings */
|
|
|
|
|
if(!edns_strings_apply_cfg(daemon->env->edns_strings, daemon->cfg))
|
|
|
|
|
fatal_exit("Could not set up EDNS strings");
|
2020-07-23 11:17:44 -04:00
|
|
|
|
2024-04-10 05:21:28 -04:00
|
|
|
#ifdef USE_CACHEDB
|
|
|
|
|
daemon->env->cachedb_enabled = cachedb_is_enabled(&daemon->mods,
|
|
|
|
|
daemon->env);
|
|
|
|
|
#endif
|
2017-03-07 09:58:51 -05:00
|
|
|
/* response-ip-xxx options don't work as expected without the respip
|
|
|
|
|
* module. To avoid run-time operational surprise we reject such
|
|
|
|
|
* configuration. */
|
|
|
|
|
if(daemon->use_response_ip &&
|
|
|
|
|
modstack_find(&daemon->mods, "respip") < 0)
|
|
|
|
|
fatal_exit("response-ip options require respip module");
|
2019-07-16 12:43:16 -04:00
|
|
|
/* RPZ response ip triggers don't work as expected without the respip
|
|
|
|
|
* module. To avoid run-time operational surprise we reject such
|
|
|
|
|
* configuration. */
|
|
|
|
|
if(daemon->use_rpz &&
|
|
|
|
|
modstack_find(&daemon->mods, "respip") < 0)
|
|
|
|
|
fatal_exit("RPZ requires the respip module");
|
2017-03-07 09:58:51 -05:00
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
/* first create all the worker structures, so we can pass
|
|
|
|
|
* them to the newly created threads.
|
|
|
|
|
*/
|
|
|
|
|
daemon_create_workers(daemon);
|
2009-01-05 10:05:33 -05:00
|
|
|
|
2010-10-29 11:03:20 -04:00
|
|
|
#if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)
|
2009-01-05 10:05:33 -05:00
|
|
|
/* in libev the first inited base gets signals */
|
2014-01-24 06:43:38 -05:00
|
|
|
if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1))
|
2009-01-05 10:05:33 -05:00
|
|
|
fatal_exit("Could not initialize main thread");
|
|
|
|
|
#endif
|
2007-02-26 09:49:11 -05:00
|
|
|
|
|
|
|
|
/* Now create the threads and init the workers.
|
|
|
|
|
* By the way, this is thread #0 (the main thread).
|
|
|
|
|
*/
|
|
|
|
|
daemon_start_others(daemon);
|
|
|
|
|
|
|
|
|
|
/* Special handling for the main thread. This is the thread
|
2008-09-10 11:23:01 -04:00
|
|
|
* that handles signals and remote control.
|
2007-02-26 09:49:11 -05:00
|
|
|
*/
|
2010-10-29 11:03:20 -04:00
|
|
|
#if !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP))
|
2009-01-05 10:05:33 -05:00
|
|
|
/* libevent has the last inited base get signals (or any base) */
|
2014-01-24 06:43:38 -05:00
|
|
|
if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1))
|
2007-02-26 09:49:11 -05:00
|
|
|
fatal_exit("Could not initialize main thread");
|
2009-01-05 10:05:33 -05:00
|
|
|
#endif
|
2007-02-27 05:33:04 -05:00
|
|
|
signal_handling_playback(daemon->workers[0]);
|
2007-02-26 09:49:11 -05:00
|
|
|
|
2017-02-23 07:05:05 -05:00
|
|
|
if (!shm_main_init(daemon))
|
|
|
|
|
log_warn("SHM has failed");
|
|
|
|
|
|
2007-02-26 09:49:11 -05:00
|
|
|
/* Start resolver service on main thread. */
|
2017-01-03 08:43:29 -05:00
|
|
|
#ifdef HAVE_SYSTEMD
|
2019-08-14 09:51:28 -04:00
|
|
|
ret = sd_notify(0, "READY=1");
|
|
|
|
|
if(ret <= 0 && getenv("NOTIFY_SOCKET"))
|
|
|
|
|
fatal_exit("sd_notify failed %s: %s. Make sure that unbound has "
|
|
|
|
|
"access/permission to use the socket presented by systemd.",
|
|
|
|
|
getenv("NOTIFY_SOCKET"),
|
|
|
|
|
(ret==0?"no $NOTIFY_SOCKET": strerror(-ret)));
|
2017-01-03 08:43:29 -05:00
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
log_info("start of service (%s).", PACKAGE_STRING);
|
|
|
|
|
worker_work(daemon->workers[0]);
|
2017-01-03 08:43:29 -05:00
|
|
|
#ifdef HAVE_SYSTEMD
|
2018-09-17 08:30:22 -04:00
|
|
|
if (daemon->workers[0]->need_to_exit)
|
|
|
|
|
sd_notify(0, "STOPPING=1");
|
|
|
|
|
else
|
|
|
|
|
sd_notify(0, "RELOADING=1");
|
2017-01-03 08:43:29 -05:00
|
|
|
#endif
|
2007-11-28 04:34:06 -05:00
|
|
|
log_info("service stopped (%s).", PACKAGE_STRING);
|
2007-02-26 09:49:11 -05:00
|
|
|
|
|
|
|
|
/* we exited! a signal happened! Stop other threads */
|
|
|
|
|
daemon_stop_others(daemon);
|
|
|
|
|
|
2017-02-23 07:05:05 -05:00
|
|
|
/* Shutdown SHM */
|
|
|
|
|
shm_main_shutdown(daemon);
|
|
|
|
|
|
2021-11-08 16:39:13 -05:00
|
|
|
daemon->reuse_cache = daemon->workers[0]->reuse_cache;
|
2007-11-12 06:10:11 -05:00
|
|
|
daemon->need_to_exit = daemon->workers[0]->need_to_exit;
|
2007-02-22 11:22:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
daemon_cleanup(struct daemon* daemon)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
log_assert(daemon);
|
2007-02-27 05:33:04 -05:00
|
|
|
/* before stopping main worker, handle signals ourselves, so we
|
|
|
|
|
don't die on multiple reload signals for example. */
|
|
|
|
|
signal_handling_record();
|
2007-03-02 04:03:14 -05:00
|
|
|
log_thread_set(NULL);
|
2007-11-12 08:58:34 -05:00
|
|
|
/* clean up caches because
|
|
|
|
|
* a) RRset IDs will be recycled after a reload, causing collisions
|
2021-11-08 16:39:13 -05:00
|
|
|
* b) validation config can change, thus rrset, msg, keycache clear
|
|
|
|
|
*
|
|
|
|
|
* If we are trying to keep the cache as long as possible, we should
|
|
|
|
|
* defer the cleanup until we know whether the new configuration allows
|
|
|
|
|
* the reuse. (If we're exiting, cleanup should be done here). */
|
|
|
|
|
if(!daemon->reuse_cache || daemon->need_to_exit) {
|
|
|
|
|
slabhash_clear(&daemon->env->rrset_cache->table);
|
|
|
|
|
slabhash_clear(daemon->env->msg_cache);
|
|
|
|
|
}
|
|
|
|
|
daemon->old_num = daemon->num; /* save the current num */
|
2024-01-04 10:53:02 -05:00
|
|
|
forwards_delete(daemon->env->fwds);
|
|
|
|
|
daemon->env->fwds = NULL;
|
2024-01-05 07:36:41 -05:00
|
|
|
hints_delete(daemon->env->hints);
|
|
|
|
|
daemon->env->hints = NULL;
|
2007-11-22 04:30:44 -05:00
|
|
|
local_zones_delete(daemon->local_zones);
|
|
|
|
|
daemon->local_zones = NULL;
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
respip_set_delete(daemon->env->respip_set);
|
|
|
|
|
daemon->env->respip_set = NULL;
|
|
|
|
|
views_delete(daemon->env->views);
|
|
|
|
|
daemon->env->views = NULL;
|
2018-01-31 07:52:40 -05:00
|
|
|
if(daemon->env->auth_zones)
|
|
|
|
|
auth_zones_cleanup(daemon->env->auth_zones);
|
2024-07-01 10:10:07 -04:00
|
|
|
/* key cache is cleared by module deinit during next daemon_fork() */
|
2009-06-11 05:43:23 -04:00
|
|
|
daemon_remote_clear(daemon->rc);
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
if(daemon->fast_reload_thread)
|
|
|
|
|
fast_reload_thread_stop(daemon->fast_reload_thread);
|
|
|
|
|
if(daemon->fast_reload_printq_list)
|
|
|
|
|
fast_reload_printq_list_delete(daemon->fast_reload_printq_list);
|
2007-02-22 11:22:54 -05:00
|
|
|
for(i=0; i<daemon->num; i++)
|
|
|
|
|
worker_delete(daemon->workers[i]);
|
|
|
|
|
free(daemon->workers);
|
|
|
|
|
daemon->workers = NULL;
|
2021-11-08 16:39:13 -05:00
|
|
|
/* Unless we're trying to keep the cache, worker alloc_caches should be
|
|
|
|
|
* cleared and freed here. We do this after deleting workers to
|
|
|
|
|
* guarantee that the alloc caches are valid throughout the lifetime
|
|
|
|
|
* of workers. */
|
|
|
|
|
if(!daemon->reuse_cache || daemon->need_to_exit)
|
|
|
|
|
daemon_clear_allocs(daemon);
|
2007-02-22 11:22:54 -05:00
|
|
|
daemon->num = 0;
|
2014-08-05 03:57:52 -04:00
|
|
|
#ifdef USE_DNSTAP
|
|
|
|
|
dt_delete(daemon->dtenv);
|
2018-04-26 02:59:49 -04:00
|
|
|
daemon->dtenv = NULL;
|
2017-08-28 03:49:42 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef USE_DNSCRYPT
|
|
|
|
|
dnsc_delete(daemon->dnscenv);
|
2018-04-26 02:59:49 -04:00
|
|
|
daemon->dnscenv = NULL;
|
DNSoverQUIC (#871)
* - dnsoverquic, configure --with-libngtcp2 option.
* - dnsoverquic, create comm_point for doq and receive cmsg local address.
* - dnsoverquic, less obtrusive debug.
* - dnsoverquic, log and fix local port number. Neater subroutines and ifdefs.
* - dnsoverquic, add testcode/doqclient.
* - dnsoverquic, review fixes on doqclient.
* - dnsoverquic, fix unit test testbound link.
* - dnsoverquic, parse query in doqclient.
* - dnsoverquic, link with libngtcp2_crypto_openssl and code for doqclient.
* - dnsoverquic, random routine for doqclient and fix ngaddr allocation, and
check ub_initstate return.
* - dnsoverquic, fix doqclient free of allocated ngaddr addresses.
* - dnsoverquic, enable debug output with -v for doqclient.
* - dnsoverquic, create and set TLS object and TLS context in doqclient.
* - dnsoverquic, work on quic tls context in doqclient.
* - dnsoverquic, set default dnsoverquic port to the standardized 853 port.
* - dnsoverquic, remove debug comment.
* - dnsoverquic, dns-over-quic quic-port: 853 config option.
* - dnsoverquic, log type of interface created at start of unbound.
* - dnsoverquic, log type of no tls https as https when interface is created.
* - dnsoverquic, setup client quic tls methods.
* - dnsoverquic, event work in doqclient.
* - dnsoverquic, explain in documentation that QUIC uses UDP.
* - dnsoverquic, make doqclient exit.
* - dnsoverquic, doqclient cleanup run routine.
* - dnsoverquic, doqclient code nicer.
* - dnsoverquic, doqclient read and timer.
* - dnsoverquic, doqclient write work.
* - dnsoverquic, review fixes.
* - dnsoverquic, detect openssl quic support at configure time.
* - dnsoverquic, do not allow QUIC on port 53 to stop confusion of DoQ and DNS.
* - dnsoverquic, in doqclient, when idle close is returned, drop the connection
without calling ngtcp2_conn_write_connection_close.
* - dnsoverquic, in doqclient, log callbacks.
* - dnsoverquic, in doqclient add extend_max_local_streams_bidi callback.
* - dnsoverquic, in doqclient add client query lists.
* - dnsoverquic, in doqclient, code cleaner, log text nicer.
* - dnsoverquic, in doqclient, work on write_streams.
* - dnsoverquic, in doqclient, use signed int for stream_id, work on the
ngtcp2_recv_stream_data callback.
* - dnsoverquic, in doqclient, print result and fixes for recv data.
* - dnsoverquic, in doqclient, add the event callbacks to fptr wlist.
* - dnsoverquic, in doqclient, when already expired, use zero timeout timer.
* - dnsoverquic, in doqclient, ignore unused return codes from
ngtcp2_conn_writev_stream.
* - dnsoverquic, add doqclient event functions to the unbound-dnstap-socket
test tool for linking.
* - dnsoverquic, in doqclient, fix multiple operands for the commandline.
neater dns message output.
* - dnsoverquic, in doqclient, store packet when write blocks and try later.
* - dnsoverquic, in doqclient, limit number of packets and number of bytes sent.
* - dnsoverquic, in doqclient, better size estimate for outgoing packet.
* - dnsoverquic, in doqclient, fix that already written next packet is not
counted for data length to send.
* - dnsoverquic, in doqclient, early data transmission and session resumption.
* - dnsoverquic, send version negotiation packet.
* - dnsoverquic, send retry and accept the connection.
* - dnsoverquic, storage structures.
* - dnsoverquic, doq connection setup.
* - dnsoverquic, neater code layout for new conn. Fix verbosity of log print.
* - dnsoverquic, doq conn callback functions.
* - dnsoverquic, doq_fill_rand routine in header file.
* - dnsoverquic, keep track of connection ids.
* - dnsoverquic, get_new_connection_id callback.
* - dnsoverquic, create doq_conid tree.
* - dnsoverquic, settings for server connection.
* - dnsoverquic, tls context.
* - dnsoverquic, sendmsg error handling.
* - dnsoverquic, neat code.
* - dnsoverquic, track doq connection last error.
* - dnsoverquic, neater packet address parameters.
* - dnsoverquic, fix uninitialized bytes in msg control in doq sendmsg, and
fix tree cleanup of conid tree.
* - dnsoverquic, better usage text for doqclient.
* - dnsoverquic, neat code.
* - dnsoverquic, connection receive packet handling.
* - dnsoverquic, debug output.
* - dnsoverquic, debug switched meaning of scid and dcid gives
ERR_TRANSPORT_PARAM.
* - dnsoverquic, remove debug output.
* - dnsoverquic, connection delete routine and error from connection read in
more detail with less clutter.
* - dnsoverquic, write to stream, and receive stream data, log packet.
* - dnsoverquic, alpn set up.
* - dnsoverquic, connection close.
* - dnsoverquic, doq_table and locks.
* - dnsoverquic, fix tests.
* - dnsoverquic, better locking.
* - dnsoverquic, doq_stream.
* - dnsoverquic, remove compile warning.
* - dnsoverquic, doq_stream receive data.
* - dnsoverquic, fixes for locks and keep length bytes allocated.
* - dnsoverquic, lock connection on initial insertion.
* - dnsoverquic, reply information, and reply buffer.
* - dnsoverquic, reply info from cache, local-zone and recursion lookups.
* - dnsoverquic, spelling in comment about buffer storage.
* - dnsoverquic, stream write list and doqclient fixes to exit and printout.
* - dnsoverquic, doqclient -q option for short printout.
* - dnsoverquic, unit test with local data reply.
* - dnsoverquic, write connection and write event is set.
* - dnsoverquic, neater logging for write event connection stream writes.
* - dnsoverquic, log remote connection when the streams are written for it.
* - dnsoverquic, better threaded use, threads can write to doq connections at
the same time.
* - dnsoverquic, unit test for the calculation of connection size with a query.
* - dnsoverquic, use less memory per connection.
* - dnsoverquic, remove unit test output.
* - dnsoverquic, add MSG_DONTWAIT so that there is no mistakenly blocking
socket operations.
* - dnsoverquic, doqclient logs address on connection failures.
* - dnsoverquic, compat code for clock get time routine.
* - dnsoverquic, use skip_test for doq unit test.
* - dnsoverquic, fixes for proxyprotocol, use remote_addr and set proxyprotocol
disabled on the doq connection.
* - dnsoverquic, doqclient sets log identity to its name, instead of "unbound".
* - dnsoverquic, handle blocked udp packet writes.
* - dnsoverquic, fix function documentation for verbose_print_addr from
services/listen_dnsport.c.
* - dnsoverquic, fix doq_conn lock protection. The checklock allows to set
the output file name, and doqclient uses that. Print place of lock_protect.
* - dnsoverquic, neater buffer clear when write of blocked packet fails, make
sure that memory area does not overlap for blocked packet addresses when
write of blocked packet fails, and size blocked packet buffer to the pkt buf.
* - dnsoverquic, move lock check after the test to test script in doq test.
* - dnsoverquic, the doq test uses valgrind when enabled.
* - dnsoverquic, git ignore the doqclient test.
* - dnsoverquic, limit the buffer for packets to max packet size with some more.
* - dnsoverquic, spelling fix.
* - dnsoverquic, timer work, structure and adds and deletes.
* - dnsoverquic, timer_tree uses table.lock.
* - dnsoverquic, fix timer tree remove and spelling in header file comment.
* - dnsoverquic, fix testbound for timer compare function linkage.
* - dnsoverquic, timer set add debug output.
* - dnsoverquic, doq_conn_check_timer function.
* - dnsoverquic, doq_done_setup_timer_and_write function.
* - dnsoverquic, fix that doq conn is not deleted whilst editing write and timer.
* - dnsoverquic, Fix #861 make ERROR netevent.h:1073:32: error: field 'blocked_pkt_pi' has incomplete type
* - dnsoverquic, timer element has timeout setup when socket callback complete.
* - dnsoverquic, fix unit test compile.
* - dnsoverquic, timer callback routine, handle timeout and close and delete the
connection if necessary.
* - dnsoverquic, timer pickup stops at current time.
* - dnsoverquic, timer comparable with the event base time.
* - dnsoverquic, erase marked time when timer disabled.
* - dnsoverquic, fix timer to set correctly and lock popped write connection
early, before it is modified.
* - dnsoverquic, fix to unlock connection lock when it is unlinked and deleted.
* - dnsoverquic, fix to unlock connection lock when it is deleted because it is
a duplicate connection.
* - dnsoverquic, fix that doq timer is not disabled when not set.
* - dnsoverquic, quic-size: 8m maximum number of bytes for QUIC buffers.
* - dnsoverquic, flex and bison.
* - dnsoverquic, quic-size turn away new connections when full.
* - dnsoverquic, doqclient outputs stream reset information.
* - dnsoverquic, detect stream close and reset.
* - dnsoverquic, free stream buffers when data is acked and stream is closed.
* - dnsoverquic, delete stream when closed. Unlink it. Allow stream_id 4 as first.
* - dnsoverquic, stats output for mem.quic and num.query.quic.
* - dnsoverquic, review fix.
* - dnsoverquic, fix when compiled without ngtcp2.
* - dnsoverquic, fix to detect ngtcp2_crypto_quictls for openssl crypto, after
change in libngtcp2.
* - dnsoverquic, fix for newer ngtcp2 versions. detect ngtcp2_ccerr_default,
ngtcp2/ngtcp2_crypto_quictls.h, struct ngtcp2_pkt_hd.tokenlen,
struct ngtcp2_settings.tokenlen and struct ngtcp2_version_cid.
* - dnsoverquic, fix for newer ngtcp2 version, detect number of arguments for
ngtcp2_conn_shutdown_stream.
* - dnsoverquic, fix for newer ngtcp2.
* - dnsoverquic, use the functions from util/timeval_func.h.
* - dnsoverquic, fix in doqclient only write transport parameters once.
* - dnsoverquic, debug log output removed.
* - dnsoverquic, fix in doqclient to work with renamed NGTCP2_CC_ALGO_BBR_V2
from ngtcp2.
* - dnsoverquic, fix to check in doq_server_socket_create that tls-service-key
and tls-service-pem have a value.
* - dnsoverquic, fix to error when doq_server_socket_create fails.
* - dnsoverquic, improve linebreaks in configparser additions.
* - dnsoverquic, fix port from interface pickup after main branch change.
* Fix getting user data from SSL, fix calloc warning.
* Fix fwrite return value check in doqclient
* - timeval_substruct from timeval_func.h
- lock_protect also for HAVE_NGTCP2_CCERR_DEFAULT
- fix doq logging for inet_ntop failures
* - memset for consistency
- no value returned from msghdr_get_ecn when S_SPLINT_S is defined
* - dnsoverquic, rerun autoconf.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2024-10-09 04:32:03 -04:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_NGTCP2
|
|
|
|
|
doq_table_delete(daemon->doq_table);
|
|
|
|
|
daemon->doq_table = NULL;
|
2014-08-05 03:57:52 -04:00
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
daemon->cfg = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
daemon_delete(struct daemon* daemon)
|
|
|
|
|
{
|
2014-01-24 08:23:45 -05:00
|
|
|
size_t i;
|
2007-02-22 11:22:54 -05:00
|
|
|
if(!daemon)
|
|
|
|
|
return;
|
2024-07-03 07:53:44 -04:00
|
|
|
modstack_call_deinit(&daemon->mods, daemon->env);
|
|
|
|
|
modstack_call_destartup(&daemon->mods, daemon->env);
|
|
|
|
|
modstack_free(&daemon->mods);
|
2009-06-11 05:43:23 -04:00
|
|
|
daemon_remote_delete(daemon->rc);
|
2014-01-24 06:43:38 -05:00
|
|
|
for(i = 0; i < daemon->num_ports; i++)
|
|
|
|
|
listening_ports_free(daemon->ports[i]);
|
|
|
|
|
free(daemon->ports);
|
2008-09-10 11:23:01 -04:00
|
|
|
listening_ports_free(daemon->rc_ports);
|
2007-05-16 10:29:46 -04:00
|
|
|
if(daemon->env) {
|
|
|
|
|
slabhash_delete(daemon->env->msg_cache);
|
|
|
|
|
rrset_cache_delete(daemon->env->rrset_cache);
|
|
|
|
|
infra_delete(daemon->env->infra_cache);
|
2016-12-06 08:42:51 -05:00
|
|
|
edns_known_options_delete(daemon->env);
|
2020-09-30 17:17:53 -04:00
|
|
|
edns_strings_delete(daemon->env->edns_strings);
|
2018-01-31 07:52:40 -05:00
|
|
|
auth_zones_delete(daemon->env->auth_zones);
|
2007-05-16 10:29:46 -04:00
|
|
|
}
|
2008-04-11 09:24:49 -04:00
|
|
|
ub_randfree(daemon->rand);
|
2007-03-09 08:37:57 -05:00
|
|
|
alloc_clear(&daemon->superalloc);
|
2007-11-19 10:32:55 -05:00
|
|
|
acl_list_delete(daemon->acl);
|
2021-08-19 10:12:19 -04:00
|
|
|
acl_list_delete(daemon->acl_interface);
|
2018-08-07 07:57:42 -04:00
|
|
|
tcl_list_delete(daemon->tcl);
|
Cookie secret file (#1090)
* - cookie-secret-file, define struct.
* - cookie-secret-file, add config option, create, read and delete struct.
* - cookie-secret-file, check cookie secrets for cookie validation.
* - cookie-secret-file, unbound-control add_cookie_secret, drop_cookie_secret,
activate_cookie_secret and print_cookie_secrets.
* - cookie-secret-file, test and fix locks, renew writes a fresh cookie,
staging cookies get a fresh cookie and spelling in error message.
* - cookie-secret-file, remove unused variable from cookie file unit test.
* Remove unshare and faketime dependencies for cookie_file test; documentation nits.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2024-08-02 07:32:08 -04:00
|
|
|
cookie_secrets_delete(daemon->cookie_secrets);
|
2021-08-25 07:37:50 -04:00
|
|
|
listen_desetup_locks();
|
2009-01-06 10:47:15 -05:00
|
|
|
free(daemon->chroot);
|
2007-02-23 08:38:54 -05:00
|
|
|
free(daemon->pidfile);
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
free(daemon->cfgfile);
|
2007-05-11 10:16:42 -04:00
|
|
|
free(daemon->env);
|
2012-06-20 11:23:03 -04:00
|
|
|
#ifdef HAVE_SSL
|
2019-01-23 05:19:04 -05:00
|
|
|
listen_sslctx_delete_ticket_keys();
|
2025-01-20 09:43:44 -05:00
|
|
|
SSL_CTX_free((SSL_CTX*)daemon->listen_dot_sslctx);
|
|
|
|
|
SSL_CTX_free((SSL_CTX*)daemon->listen_doh_sslctx);
|
|
|
|
|
SSL_CTX_free((SSL_CTX*)daemon->connect_dot_sslctx);
|
2024-12-03 08:20:33 -05:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_NGTCP2
|
2025-01-20 09:43:44 -05:00
|
|
|
SSL_CTX_free((SSL_CTX*)daemon->listen_quic_sslctx);
|
2012-06-20 11:23:03 -04:00
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
free(daemon);
|
2009-08-25 11:37:02 -04:00
|
|
|
/* lex cleanup */
|
|
|
|
|
ub_c_lex_destroy();
|
2007-08-30 09:38:52 -04:00
|
|
|
/* libcrypto cleanup */
|
2012-06-20 11:23:03 -04:00
|
|
|
#ifdef HAVE_SSL
|
2022-06-20 10:27:15 -04:00
|
|
|
# if defined(USE_GOST)
|
2013-12-03 04:11:16 -05:00
|
|
|
sldns_key_EVP_unload_gost();
|
2012-06-20 11:23:03 -04:00
|
|
|
# endif
|
|
|
|
|
# if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS && HAVE_DECL_SK_SSL_COMP_POP_FREE
|
|
|
|
|
# ifndef S_SPLINT_S
|
2016-03-23 04:19:49 -04:00
|
|
|
# if OPENSSL_VERSION_NUMBER < 0x10100000
|
2011-01-07 11:20:15 -05:00
|
|
|
sk_SSL_COMP_pop_free(comp_meth, (void(*)())CRYPTO_free);
|
2016-03-23 04:19:49 -04:00
|
|
|
# endif
|
2012-06-20 11:23:03 -04:00
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
# ifdef HAVE_OPENSSL_CONFIG
|
2007-08-30 09:38:52 -04:00
|
|
|
EVP_cleanup();
|
2020-03-02 08:06:10 -05:00
|
|
|
# if (OPENSSL_VERSION_NUMBER < 0x10100000) && !defined(OPENSSL_NO_ENGINE) && defined(HAVE_ENGINE_CLEANUP)
|
2009-08-24 10:40:25 -04:00
|
|
|
ENGINE_cleanup();
|
2016-03-23 04:19:49 -04:00
|
|
|
# endif
|
2009-08-07 11:23:35 -04:00
|
|
|
CONF_modules_free();
|
2012-06-20 11:23:03 -04:00
|
|
|
# endif
|
2016-09-02 05:59:09 -04:00
|
|
|
# ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA
|
2007-08-30 09:38:52 -04:00
|
|
|
CRYPTO_cleanup_all_ex_data(); /* safe, no more threads right now */
|
2016-09-02 05:59:09 -04:00
|
|
|
# endif
|
|
|
|
|
# ifdef HAVE_ERR_FREE_STRINGS
|
2007-08-15 04:39:00 -04:00
|
|
|
ERR_free_strings();
|
2016-09-02 05:59:09 -04:00
|
|
|
# endif
|
2016-03-23 04:19:49 -04:00
|
|
|
# if OPENSSL_VERSION_NUMBER < 0x10100000
|
2008-01-28 09:34:53 -05:00
|
|
|
RAND_cleanup();
|
2016-03-23 04:19:49 -04:00
|
|
|
# endif
|
2013-02-11 11:03:51 -05:00
|
|
|
# if defined(HAVE_SSL) && defined(OPENSSL_THREADS) && !defined(THREADS_DISABLED)
|
2012-08-01 07:31:29 -04:00
|
|
|
ub_openssl_lock_delete();
|
|
|
|
|
# endif
|
2018-02-02 04:27:16 -05:00
|
|
|
#ifndef HAVE_ARC4RANDOM
|
|
|
|
|
_ARC4_LOCK_DESTROY();
|
|
|
|
|
#endif
|
2012-06-20 11:23:03 -04:00
|
|
|
#elif defined(HAVE_NSS)
|
|
|
|
|
NSS_Shutdown();
|
|
|
|
|
#endif /* HAVE_SSL or HAVE_NSS */
|
2007-03-09 08:37:57 -05:00
|
|
|
checklock_stop();
|
2008-06-16 11:02:52 -04:00
|
|
|
#ifdef USE_WINSOCK
|
|
|
|
|
if(WSACleanup() != 0) {
|
|
|
|
|
log_err("Could not WSACleanup: %s",
|
|
|
|
|
wsa_strerror(WSAGetLastError()));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2007-02-22 11:22:54 -05:00
|
|
|
}
|
2009-02-27 11:29:40 -05:00
|
|
|
|
|
|
|
|
void daemon_apply_cfg(struct daemon* daemon, struct config_file* cfg)
|
|
|
|
|
{
|
2021-11-08 16:39:13 -05:00
|
|
|
int new_num = cfg->num_threads?cfg->num_threads:1;
|
|
|
|
|
|
2009-02-27 11:29:40 -05:00
|
|
|
daemon->cfg = cfg;
|
|
|
|
|
config_apply(cfg);
|
2021-11-08 16:39:13 -05:00
|
|
|
|
|
|
|
|
/* If this is a reload and we deferred the decision on whether to
|
|
|
|
|
* reuse the alloc, RRset, and message caches, then check to see if
|
|
|
|
|
* it's safe to keep the caches:
|
|
|
|
|
* - changing the number of threads is obviously incompatible with
|
|
|
|
|
* keeping the per-thread alloc caches. It also means we have to
|
|
|
|
|
* clear RRset and message caches. (note that 'new_num' may be
|
|
|
|
|
* adjusted in daemon_create_workers, but for our purpose we can
|
|
|
|
|
* simply compare it with 'old_num'; if they are equal here,
|
|
|
|
|
* 'new_num' won't be adjusted to a different value than 'old_num').
|
|
|
|
|
* - changing RRset cache size effectively clears any remaining cache
|
|
|
|
|
* entries. We could keep their keys in alloc caches, but it would
|
|
|
|
|
* be more consistent with the sense of the change to clear allocs
|
|
|
|
|
* and free memory. To do so we also have to clear message cache.
|
|
|
|
|
* - only changing message cache size does not necessarily affect
|
|
|
|
|
* RRset or alloc cache. But almost all new subsequent queries will
|
|
|
|
|
* require recursive resolution anyway, so it doesn't help much to
|
|
|
|
|
* just keep RRset and alloc caches. For simplicity we clear/free
|
|
|
|
|
* the other two, too. */
|
|
|
|
|
if(daemon->worker_allocs &&
|
|
|
|
|
(new_num != daemon->old_num ||
|
|
|
|
|
!slabhash_is_size(daemon->env->msg_cache, cfg->msg_cache_size,
|
|
|
|
|
cfg->msg_cache_slabs) ||
|
|
|
|
|
!slabhash_is_size(&daemon->env->rrset_cache->table,
|
|
|
|
|
cfg->rrset_cache_size, cfg->rrset_cache_slabs)))
|
|
|
|
|
{
|
|
|
|
|
log_warn("cannot reuse caches due to critical config change");
|
|
|
|
|
slabhash_clear(&daemon->env->rrset_cache->table);
|
|
|
|
|
slabhash_clear(daemon->env->msg_cache);
|
|
|
|
|
daemon_clear_allocs(daemon);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 11:07:09 -04:00
|
|
|
if(!slabhash_is_size(daemon->env->msg_cache, cfg->msg_cache_size,
|
|
|
|
|
cfg->msg_cache_slabs)) {
|
2009-02-27 11:29:40 -05:00
|
|
|
slabhash_delete(daemon->env->msg_cache);
|
|
|
|
|
daemon->env->msg_cache = slabhash_create(cfg->msg_cache_slabs,
|
|
|
|
|
HASH_DEFAULT_STARTARRAY, cfg->msg_cache_size,
|
|
|
|
|
msgreply_sizefunc, query_info_compare,
|
|
|
|
|
query_entry_delete, reply_info_delete, NULL);
|
|
|
|
|
if(!daemon->env->msg_cache) {
|
|
|
|
|
fatal_exit("malloc failure updating config settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if((daemon->env->rrset_cache = rrset_cache_adjust(
|
|
|
|
|
daemon->env->rrset_cache, cfg, &daemon->superalloc)) == 0)
|
|
|
|
|
fatal_exit("malloc failure updating config settings");
|
|
|
|
|
if((daemon->env->infra_cache = infra_adjust(daemon->env->infra_cache,
|
|
|
|
|
cfg))==0)
|
|
|
|
|
fatal_exit("malloc failure updating config settings");
|
|
|
|
|
}
|