verbose(VERB_ALGO, "total of %d outgoing ports available", numport);
#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");
+ if (cfg_has_quic(daemon->cfg)) {
+ 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
daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1);
daemon->dnscenv = NULL;
#endif
#ifdef HAVE_NGTCP2
- doq_table_delete(daemon->doq_table);
- daemon->doq_table = NULL;
+ if (daemon->doq_table) {
+ doq_table_delete(daemon->doq_table);
+ daemon->doq_table = NULL;
+ }
#endif
daemon->cfg = NULL;
}
cp = comm_point_create_udp(base, ports->fd,
front->udp_buff, ports->pp2_enabled, cb,
cb_arg, ports->socket);
- } else if(ports->ftype == listen_type_doq) {
+ } else if(ports->ftype == listen_type_doq && doq_table) {
#ifndef HAVE_NGTCP2
log_warn("Unbound is not compiled with "
"ngtcp2. This is required to use DNS "
struct doq_table*
doq_table_create(struct config_file* cfg, struct ub_randstate* rnd)
{
- struct doq_table* table = calloc(1, sizeof(*table));
+ struct doq_table* table;
+
+ if (!cfg->quic_port)
+ return NULL;
+ table = calloc(1, sizeof(*table));
if(!table)
return NULL;
#ifdef USE_NGTCP2_CRYPTO_OSSL
/* Initialize the ossl crypto, it is harmless to call twice,
* and this is before use of doq connections. */
if(ngtcp2_crypto_ossl_init() != 0) {
- log_err("ngtcp2_crypto_oss_init failed");
+ log_err("ngtcp2_crypto_ossl_init failed");
free(table);
return NULL;
}
{
struct doq_table* table = (struct doq_table*)arg;
struct doq_conn* conn;
- if(!node)
+ if(!node || !table)
return;
conn = (struct doq_conn*)node->key;
if(conn->timer.timer_in_list) {
{
struct doq_timer key;
struct rbnode_type* node;
+ log_assert(table != NULL);
memset(&key, 0, sizeof(key));
key.time.tv_sec = tv->tv_sec;
key.time.tv_usec = tv->tv_usec;
key.node.key = &key;
key.cid = (void*)data;
key.cidlen = datalen;
+ log_assert(table != NULL);
node = rbtree_search(table->conid_tree, &key);
if(node)
return (struct doq_conid*)node->key;
struct config_file* cfg, size_t mem)
{
size_t cur;
+ if (!table)
+ return 0;
lock_basic_lock(&table->size_lock);
cur = table->current_size;
lock_basic_unlock(&table->size_lock);
/* Initialize the ossl crypto, it is harmless to call twice,
* and this is before use of doq connections. */
if(ngtcp2_crypto_ossl_init() != 0)
- fatal_exit("ngtcp2_crypto_oss_init failed");
+ fatal_exit("ngtcp2_crypto_ossl_init failed");
#elif defined(HAVE_NGTCP2_CRYPTO_QUICTLS_INIT)
if(ngtcp2_crypto_quictls_init() != 0)
fatal_exit("ngtcp2_crypto_quictls_init failed");
server_quic_port: VAR_QUIC_PORT STRING_ARG
{
OUTYY(("P(server_quic_port:%s)\n", $2));
+ if(atoi($2) == 0 && strcmp($2,"0")!=0)
+ yyerror("port number expected");
+ else {
+ cfg_parser->cfg->quic_port = atoi($2);
#ifndef HAVE_NGTCP2
- log_warn("%s:%d: Unbound is not compiled with "
- "ngtcp2. This is required to use DNS "
- "over QUIC.", cfg_parser->filename, cfg_parser->line);
+ if (cfg_parser->cfg->quic_port != 0)
+ log_warn("%s:%d: Unbound is not compiled with "
+ "ngtcp2. This is required to use DNS "
+ "over QUIC.", cfg_parser->filename, cfg_parser->line);
#endif
- if(atoi($2) == 0)
- yyerror("port number expected");
- else cfg_parser->cfg->quic_port = atoi($2);
+ }
free($2);
};
server_quic_size: VAR_QUIC_SIZE STRING_ARG
{
size_t doq_buffer_size = 4096; /* bytes buffer size, for one packet. */
struct doq_server_socket* doq_socket;
+ log_assert(doq_table != NULL);
doq_socket = calloc(1, sizeof(*doq_socket));
if(!doq_socket) {
return NULL;
{
struct doq_conn* conn;
struct doq_conn_key key;
+ log_assert(table != NULL);
doq_conn_key_from_repinfo(&key, repinfo);
lock_rw_rdlock(&table->lock);
conn = doq_conn_find(table, &key.paddr.addr,
struct config_file* cfg)
{
#ifdef HAVE_NGTCP2
+ log_assert(table != NULL);
struct comm_point* c = (struct comm_point*)calloc(1,
sizeof(struct comm_point));
short evbits;