Skip to content

Commit 162f8ee

Browse files
committed
Merge commit '3352b1090ea1098883f6bf64236fa877e18e458b' (release-1.19.0) into inl_1.19.0
2 parents 4a15da6 + 3352b10 commit 162f8ee

File tree

283 files changed

+13289
-17625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+13289
-17625
lines changed

.github/workflows/analysis_ports.yml

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ jobs:
175175
cd ..
176176
export prepath=`pwd`
177177
echo prepath=${prepath}
178+
echo "choco install winflexbison3"
179+
choco install winflexbison3
180+
echo 'LEX="win_flex"'
181+
export LEX="win_flex"
182+
echo 'YACC="win_bison -y"'
183+
export YACC="win_bison -y"
178184
#echo "curl cpanm"
179185
#curl -L -k -s -S -o cpanm https://cpanmin.us/
180186
#echo "perl cpanm Pod::Usage"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/config.status
1111
/dnstap/dnstap_config.h
1212
/dnscrypt/dnscrypt_config.h
13+
/clubsyms.def
1314
/doc/example.conf
1415
/doc/libunbound.3
1516
/doc/unbound-anchor.8

Makefile.in

+26-21
Large diffs are not rendered by default.

acx_nlnetlabs.m4

+19-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
33
# BSD licensed.
44
#
5-
# Version 44
5+
# Version 46
6+
# 2023-05-04 fix to remove unused whitespace.
7+
# 2023-01-26 fix -Wstrict-prototypes.
68
# 2022-09-01 fix checking if nonblocking sockets work on OpenBSD.
79
# 2021-08-17 fix sed script in ssldir split handling.
810
# 2021-08-17 fix for openssl to detect split version, with ssldir_include
@@ -187,7 +189,7 @@ dnl cache=`echo $1 | sed 'y%.=/+- %___p__%'`
187189
AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache,
188190
[
189191
echo '$2' > conftest.c
190-
echo 'void f(){}' >>conftest.c
192+
echo 'void f(void){}' >>conftest.c
191193
if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then
192194
eval "cv_prog_cc_flag_needed_$cache=no"
193195
else
@@ -233,7 +235,7 @@ dnl DEPFLAG: set to flag that generates dependencies.
233235
AC_DEFUN([ACX_DEPFLAG],
234236
[
235237
AC_MSG_CHECKING([$CC dependency flag])
236-
echo 'void f(){}' >conftest.c
238+
echo 'void f(void){}' >conftest.c
237239
if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then
238240
DEPFLAG="-MM"
239241
else
@@ -272,7 +274,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAUL
272274
#include <getopt.h>
273275
#endif
274276
275-
int test() {
277+
int test(void) {
276278
int a;
277279
char **opts = NULL;
278280
struct timeval tv;
@@ -309,7 +311,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAUL
309311
#include <getopt.h>
310312
#endif
311313
312-
int test() {
314+
int test(void) {
313315
int a;
314316
char **opts = NULL;
315317
struct timeval tv;
@@ -335,7 +337,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG,
335337
[
336338
#include <stdbool.h>
337339
#include <ctype.h>
338-
int test() {
340+
int test(void) {
339341
int a = 0;
340342
return a;
341343
}
@@ -345,7 +347,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE -D_DEFAULT_SOURCE,
345347
[
346348
#include <ctype.h>
347349
348-
int test() {
350+
int test(void) {
349351
int a;
350352
a = isascii(32);
351353
return a;
@@ -356,7 +358,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE,
356358
[
357359
#include <netinet/in.h>
358360
359-
int test() {
361+
int test(void) {
360362
struct in6_pktinfo inf;
361363
int a = (int)sizeof(inf);
362364
return a;
@@ -370,7 +372,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID,
370372
[
371373
#include <unistd.h>
372374
373-
int test() {
375+
int test(void) {
374376
int a = setresgid(0,0,0);
375377
a = setresuid(0,0,0);
376378
return a;
@@ -385,7 +387,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112,
385387
#endif
386388
#include <netdb.h>
387389
388-
int test() {
390+
int test(void) {
389391
int a = 0;
390392
char *t;
391393
time_t time = 0;
@@ -413,7 +415,7 @@ ACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__,
413415
#include <getopt.h>
414416
#endif
415417
416-
int test() {
418+
int test(void) {
417419
int a;
418420
char **opts = NULL;
419421
struct timeval tv;
@@ -475,7 +477,7 @@ fi
475477
dnl Setup ATTR_FORMAT config.h parts.
476478
dnl make sure you call ACX_CHECK_FORMAT_ATTRIBUTE also.
477479
AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE],
478-
[
480+
[
479481
#ifdef HAVE_ATTR_FORMAT
480482
# define ATTR_FORMAT(archetype, string_index, first_to_check) \
481483
__attribute__ ((format (archetype, string_index, first_to_check)))
@@ -834,7 +836,7 @@ dnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko
834836
ACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1,
835837
[
836838
#include <stdio.h>
837-
int test() {
839+
int test(void) {
838840
int a = fseeko(stdin, 0, 0);
839841
return a;
840842
}
@@ -859,7 +861,7 @@ char* (*f) () = getaddrinfo;
859861
#ifdef __cplusplus
860862
}
861863
#endif
862-
int main() {
864+
int main(void) {
863865
;
864866
return 0;
865867
}
@@ -923,7 +925,7 @@ cache=`echo $1 | sed 'y%.=/+-%___p_%'`
923925
AC_CACHE_VAL(cv_cc_deprecated_$cache,
924926
[
925927
echo '$3' >conftest.c
926-
echo 'void f(){ $2 }' >>conftest.c
928+
echo 'void f(void){ $2 }' >>conftest.c
927929
if test -z "`$CC $CPPFLAGS $CFLAGS -c conftest.c 2>&1 | grep -e deprecated -e unavailable`"; then
928930
eval "cv_cc_deprecated_$cache=no"
929931
else
@@ -1317,7 +1319,7 @@ AC_DEFUN([AHX_CONFIG_W32_FD_SET_T],
13171319
#ifdef HAVE_WINSOCK2_H
13181320
#define FD_SET_T (u_int)
13191321
#else
1320-
#define FD_SET_T
1322+
#define FD_SET_T
13211323
#endif
13221324
])
13231325

@@ -1355,7 +1357,7 @@ dnl $3: define value, 1
13551357
AC_DEFUN([AHX_CONFIG_FLAG_OMITTED],
13561358
[#if defined($1) && !defined($2)
13571359
#define $2 $3
1358-
[#]endif ])
1360+
[#]endif])
13591361

13601362
dnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags
13611363
dnl $1: the -DNAME or -DNAME=value string.

cachedb/cachedb.c

+57-11
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static int
102102
testframe_init(struct module_env* env, struct cachedb_env* cachedb_env)
103103
{
104104
struct testframe_moddata* d;
105-
(void)env;
106105
verbose(VERB_ALGO, "testframe_init");
107106
d = (struct testframe_moddata*)calloc(1,
108107
sizeof(struct testframe_moddata));
@@ -111,6 +110,15 @@ testframe_init(struct module_env* env, struct cachedb_env* cachedb_env)
111110
log_err("out of memory");
112111
return 0;
113112
}
113+
/* Register an EDNS option (65534) to bypass the worker cache lookup
114+
* for testing */
115+
if(!edns_register_option(LDNS_EDNS_UNBOUND_CACHEDB_TESTFRAME_TEST,
116+
1 /* bypass cache */,
117+
0 /* no aggregation */, env)) {
118+
log_err("testframe_init, could not register test opcode");
119+
free(d);
120+
return 0;
121+
}
114122
lock_basic_init(&d->lock);
115123
lock_protect(&d->lock, d, sizeof(*d));
116124
return 1;
@@ -218,6 +226,8 @@ static int
218226
cachedb_apply_cfg(struct cachedb_env* cachedb_env, struct config_file* cfg)
219227
{
220228
const char* backend_str = cfg->cachedb_backend;
229+
if(!backend_str || *backend_str==0)
230+
return 1;
221231
cachedb_env->backend = cachedb_find_backend(backend_str);
222232
if(!cachedb_env->backend) {
223233
log_err("cachedb: cannot find backend name '%s'", backend_str);
@@ -228,7 +238,7 @@ cachedb_apply_cfg(struct cachedb_env* cachedb_env, struct config_file* cfg)
228238
return 1;
229239
}
230240

231-
int
241+
int
232242
cachedb_init(struct module_env* env, int id)
233243
{
234244
struct cachedb_env* cachedb_env = (struct cachedb_env*)calloc(1,
@@ -255,31 +265,28 @@ cachedb_init(struct module_env* env, int id)
255265
return 0;
256266
}
257267
cachedb_env->enabled = 1;
258-
if(env->cfg->serve_expired_reply_ttl)
268+
if(env->cfg->serve_expired && env->cfg->serve_expired_reply_ttl)
259269
log_warn(
260270
"cachedb: serve-expired-reply-ttl is set but not working for data "
261-
"originating from the external cache; 0 TLL is used for those.");
262-
if(env->cfg->serve_expired_client_timeout)
271+
"originating from the external cache; 0 TTL is used for those.");
272+
if(env->cfg->serve_expired && env->cfg->serve_expired_client_timeout)
263273
log_warn(
264274
"cachedb: serve-expired-client-timeout is set but not working for "
265275
"data originating from the external cache; expired data are used "
266276
"in the reply without first trying to refresh the data.");
267277
return 1;
268278
}
269279

270-
void
280+
void
271281
cachedb_deinit(struct module_env* env, int id)
272282
{
273283
struct cachedb_env* cachedb_env;
274284
if(!env || !env->modinfo[id])
275285
return;
276286
cachedb_env = (struct cachedb_env*)env->modinfo[id];
277-
/* free contents */
278-
/* TODO */
279287
if(cachedb_env->enabled) {
280288
(*cachedb_env->backend->deinit)(env, cachedb_env);
281289
}
282-
283290
free(cachedb_env);
284291
env->modinfo[id] = NULL;
285292
}
@@ -406,6 +413,14 @@ prep_data(struct module_qstate* qstate, struct sldns_buffer* buf)
406413
if(qstate->return_msg->rep->ttl == 0 &&
407414
!qstate->env->cfg->serve_expired)
408415
return 0;
416+
417+
/* The EDE is added to the out-list so it is encoded in the cached message */
418+
if (qstate->env->cfg->ede && qstate->return_msg->rep->reason_bogus != LDNS_EDE_NONE) {
419+
edns_opt_list_append_ede(&edns.opt_list_out, qstate->env->scratch,
420+
qstate->return_msg->rep->reason_bogus,
421+
qstate->return_msg->rep->reason_bogus_str);
422+
}
423+
409424
if(verbosity >= VERB_ALGO)
410425
log_dns_msg("cachedb encoding", &qstate->return_msg->qinfo,
411426
qstate->return_msg->rep);
@@ -502,6 +517,7 @@ parse_data(struct module_qstate* qstate, struct sldns_buffer* buf)
502517
{
503518
struct msg_parse* prs;
504519
struct edns_data edns;
520+
struct edns_option* ede;
505521
uint64_t timestamp, expiry;
506522
time_t adjust;
507523
size_t lim = sldns_buffer_limit(buf);
@@ -539,6 +555,24 @@ parse_data(struct module_qstate* qstate, struct sldns_buffer* buf)
539555
if(!qstate->return_msg)
540556
return 0;
541557

558+
/* We find the EDE in the in-list after parsing */
559+
if(qstate->env->cfg->ede &&
560+
(ede = edns_opt_list_find(edns.opt_list_in, LDNS_EDNS_EDE))) {
561+
if(ede->opt_len >= 2) {
562+
qstate->return_msg->rep->reason_bogus =
563+
sldns_read_uint16(ede->opt_data);
564+
}
565+
/* allocate space and store the error string and it's size */
566+
if(ede->opt_len > 2) {
567+
size_t ede_len = ede->opt_len - 2;
568+
qstate->return_msg->rep->reason_bogus_str = regional_alloc(
569+
qstate->region, sizeof(char) * (ede_len+1));
570+
memcpy(qstate->return_msg->rep->reason_bogus_str,
571+
ede->opt_data+2, ede_len);
572+
qstate->return_msg->rep->reason_bogus_str[ede_len] = 0;
573+
}
574+
}
575+
542576
qstate->return_rcode = LDNS_RCODE_NOERROR;
543577

544578
/* see how much of the TTL expired, and remove it */
@@ -630,11 +664,15 @@ cachedb_extcache_store(struct module_qstate* qstate, struct cachedb_env* ie)
630664
* See if unbound's internal cache can answer the query
631665
*/
632666
static int
633-
cachedb_intcache_lookup(struct module_qstate* qstate)
667+
cachedb_intcache_lookup(struct module_qstate* qstate, struct cachedb_env* cde)
634668
{
635669
uint8_t* dpname=NULL;
636670
size_t dpnamelen=0;
637671
struct dns_msg* msg;
672+
/* for testframe bypass this lookup */
673+
if(cde->backend == &testframe_backend) {
674+
return 0;
675+
}
638676
if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,
639677
&dpname, &dpnamelen))
640678
return 0; /* no cache for these queries */
@@ -693,6 +731,7 @@ cachedb_handle_query(struct module_qstate* qstate,
693731
struct cachedb_qstate* ATTR_UNUSED(iq),
694732
struct cachedb_env* ie, int id)
695733
{
734+
qstate->is_cachedb_answer = 0;
696735
/* check if we are enabled, and skip if so */
697736
if(!ie->enabled) {
698737
/* pass request to next module */
@@ -709,7 +748,7 @@ cachedb_handle_query(struct module_qstate* qstate,
709748

710749
/* lookup inside unbound's internal cache.
711750
* This does not look for expired entries. */
712-
if(cachedb_intcache_lookup(qstate)) {
751+
if(cachedb_intcache_lookup(qstate, ie)) {
713752
if(verbosity >= VERB_ALGO) {
714753
if(qstate->return_msg->rep)
715754
log_dns_msg("cachedb internal cache lookup",
@@ -746,6 +785,7 @@ cachedb_handle_query(struct module_qstate* qstate,
746785
qstate->ext_state[id] = module_wait_module;
747786
return;
748787
}
788+
qstate->is_cachedb_answer = 1;
749789
/* we are done with the query */
750790
qstate->ext_state[id] = module_finished;
751791
return;
@@ -768,12 +808,18 @@ static void
768808
cachedb_handle_response(struct module_qstate* qstate,
769809
struct cachedb_qstate* ATTR_UNUSED(iq), struct cachedb_env* ie, int id)
770810
{
811+
qstate->is_cachedb_answer = 0;
771812
/* check if we are not enabled or instructed to not cache, and skip */
772813
if(!ie->enabled || qstate->no_cache_store) {
773814
/* we are done with the query */
774815
qstate->ext_state[id] = module_finished;
775816
return;
776817
}
818+
if(qstate->env->cfg->cachedb_no_store) {
819+
/* do not store the item in the external cache */
820+
qstate->ext_state[id] = module_finished;
821+
return;
822+
}
777823

778824
/* store the item into the backend cache */
779825
cachedb_extcache_store(qstate, ie);

0 commit comments

Comments
 (0)