mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-08-17 21:25:50 +02:00
Merge branch 'master' into zonemd
This commit is contained in:
+22
-8
@@ -64,6 +64,7 @@
|
||||
#include "sldns/sbuffer.h"
|
||||
#include "sldns/wire2str.h"
|
||||
#include "sldns/str2wire.h"
|
||||
#include "daemon/remote.h"
|
||||
#include <signal.h>
|
||||
struct worker;
|
||||
struct daemon_remote;
|
||||
@@ -1045,7 +1046,7 @@ outside_network_create(struct comm_base* base, size_t bufsize,
|
||||
void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param),
|
||||
int ATTR_UNUSED(do_udp), void* ATTR_UNUSED(sslctx),
|
||||
int ATTR_UNUSED(delayclose), int ATTR_UNUSED(tls_use_sni),
|
||||
struct dt_env* ATTR_UNUSED(dtenv))
|
||||
struct dt_env* ATTR_UNUSED(dtenv), int ATTR_UNUSED(udp_connect))
|
||||
{
|
||||
struct replay_runtime* runtime = (struct replay_runtime*)base;
|
||||
struct outside_network* outnet = calloc(1,
|
||||
@@ -1214,7 +1215,7 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
|
||||
sldns_buffer_flip(pend->buffer);
|
||||
if(1) {
|
||||
struct edns_data edns;
|
||||
struct edns_tag_addr* client_tag_addr;
|
||||
struct edns_string_addr* client_string_addr;
|
||||
if(!inplace_cb_query_call(env, qinfo, flags, addr, addrlen,
|
||||
zone, zonelen, qstate, qstate->region)) {
|
||||
free(pend);
|
||||
@@ -1228,13 +1229,14 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
|
||||
edns.bits = 0;
|
||||
if(dnssec)
|
||||
edns.bits = EDNS_DO;
|
||||
if((client_tag_addr = edns_tag_addr_lookup(
|
||||
&env->edns_tags->client_tags,
|
||||
edns.padding_block_size = 0;
|
||||
if((client_string_addr = edns_string_addr_lookup(
|
||||
&env->edns_strings->client_strings,
|
||||
addr, addrlen))) {
|
||||
uint16_t client_tag = htons(client_tag_addr->tag_data);
|
||||
edns_opt_list_append(&qstate->edns_opts_back_out,
|
||||
env->edns_tags->client_tag_opcode, 2,
|
||||
(uint8_t*)&client_tag, qstate->region);
|
||||
env->edns_strings->client_string_opcode,
|
||||
client_string_addr->string_len,
|
||||
client_string_addr->string, qstate->region);
|
||||
}
|
||||
edns.opt_list = qstate->edns_opts_back_out;
|
||||
attach_edns_record(pend->buffer, &edns);
|
||||
@@ -1511,6 +1513,18 @@ int serviced_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reuse_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||
{
|
||||
log_assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reuse_id_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||
{
|
||||
log_assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* timers in testbound for autotrust. statistics tested in tdir. */
|
||||
struct comm_timer* comm_timer_create(struct comm_base* base,
|
||||
void (*cb)(void*), void* cb_arg)
|
||||
@@ -1753,7 +1767,7 @@ struct comm_point* outnet_comm_point_for_http(struct outside_network* outnet,
|
||||
}
|
||||
|
||||
int comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
|
||||
struct sockaddr* addr, socklen_t addrlen)
|
||||
struct sockaddr* addr, socklen_t addrlen, int ATTR_UNUSED(is_connected))
|
||||
{
|
||||
struct fake_commpoint* fc = (struct fake_commpoint*)c;
|
||||
struct replay_runtime* runtime = fc->runtime;
|
||||
|
||||
+14
-2
@@ -42,16 +42,22 @@
|
||||
#ifdef HAVE_TIME_H
|
||||
# include <time.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include "testcode/testpkts.h"
|
||||
#include "testcode/replay.h"
|
||||
#include "testcode/fake_event.h"
|
||||
#include "daemon/remote.h"
|
||||
#include "libunbound/worker.h"
|
||||
#include "util/config_file.h"
|
||||
#include "sldns/keyraw.h"
|
||||
#include <ctype.h>
|
||||
#ifdef UB_ON_WINDOWS
|
||||
#include "winrc/win_svc.h"
|
||||
#endif
|
||||
|
||||
/** signal that this is a testbound compile */
|
||||
#define unbound_testbound 1
|
||||
/** renamed main routine */
|
||||
int daemon_main(int argc, char* argv[]);
|
||||
/**
|
||||
* include the main program from the unbound daemon.
|
||||
* rename main to daemon_main to call it
|
||||
@@ -333,7 +339,7 @@ setup_playback(const char* filename, int* pass_argc, char* pass_argv[])
|
||||
}
|
||||
|
||||
/** remove config file at exit */
|
||||
void remove_configfile(void)
|
||||
static void remove_configfile(void)
|
||||
{
|
||||
struct config_strlist* p;
|
||||
for(p=cfgfiles; p; p=p->next)
|
||||
@@ -551,22 +557,28 @@ void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg))
|
||||
log_assert(0);
|
||||
}
|
||||
|
||||
#ifdef UB_ON_WINDOWS
|
||||
void wsvc_command_option(const char* ATTR_UNUSED(wopt),
|
||||
const char* ATTR_UNUSED(cfgfile), int ATTR_UNUSED(v),
|
||||
int ATTR_UNUSED(c))
|
||||
{
|
||||
log_assert(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UB_ON_WINDOWS
|
||||
void wsvc_setup_worker(struct worker* ATTR_UNUSED(worker))
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UB_ON_WINDOWS
|
||||
void wsvc_desetup_worker(struct worker* ATTR_UNUSED(worker))
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UB_ON_WINDOWS
|
||||
void worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
|
||||
|
||||
@@ -839,6 +839,52 @@ static void respip_test(void)
|
||||
respip_conf_actions_test();
|
||||
}
|
||||
|
||||
#include "services/outside_network.h"
|
||||
/** add number of new IDs to the reuse tree, randomly chosen */
|
||||
static void tcpid_addmore(struct reuse_tcp* reuse,
|
||||
struct outside_network* outnet, unsigned int addnum)
|
||||
{
|
||||
unsigned int i;
|
||||
struct waiting_tcp* w;
|
||||
for(i=0; i<addnum; i++) {
|
||||
uint16_t id = reuse_tcp_select_id(reuse, outnet);
|
||||
unit_assert(!reuse_tcp_by_id_find(reuse, id));
|
||||
w = calloc(1, sizeof(*w));
|
||||
unit_assert(w);
|
||||
w->id = id;
|
||||
w->outnet = outnet;
|
||||
w->next_waiting = (void*)reuse->pending;
|
||||
reuse_tree_by_id_insert(reuse, w);
|
||||
}
|
||||
}
|
||||
|
||||
/** fill up the reuse ID tree and test assertions */
|
||||
static void tcpid_fillup(struct reuse_tcp* reuse,
|
||||
struct outside_network* outnet)
|
||||
{
|
||||
int t, numtest=3;
|
||||
for(t=0; t<numtest; t++) {
|
||||
rbtree_init(&reuse->tree_by_id, reuse_id_cmp);
|
||||
tcpid_addmore(reuse, outnet, 65535);
|
||||
reuse_del_readwait(&reuse->tree_by_id);
|
||||
}
|
||||
}
|
||||
|
||||
/** test TCP ID selection */
|
||||
static void tcpid_test(void)
|
||||
{
|
||||
struct pending_tcp pend;
|
||||
struct outside_network outnet;
|
||||
unit_show_func("services/outside_network.c", "reuse_tcp_select_id");
|
||||
memset(&pend, 0, sizeof(pend));
|
||||
pend.reuse.pending = &pend;
|
||||
memset(&outnet, 0, sizeof(outnet));
|
||||
outnet.rnd = ub_initstate(NULL);
|
||||
rbtree_init(&pend.reuse.tree_by_id, reuse_id_cmp);
|
||||
tcpid_fillup(&pend.reuse, &outnet);
|
||||
ub_randfree(outnet.rnd);
|
||||
}
|
||||
|
||||
void unit_show_func(const char* file, const char* func)
|
||||
{
|
||||
printf("test %s:%s\n", file, func);
|
||||
@@ -908,6 +954,7 @@ main(int argc, char* argv[])
|
||||
ldns_test();
|
||||
zonemd_test();
|
||||
msgparse_test();
|
||||
tcpid_test();
|
||||
#ifdef CLIENT_SUBNET
|
||||
ecs_test();
|
||||
#endif /* CLIENT_SUBNET */
|
||||
|
||||
Reference in New Issue
Block a user