mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
do-udp: no fixed.
git-svn-id: file:///svn/unbound/trunk@1882 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
5b66f07e38
commit
1d8013c67a
6 changed files with 46 additions and 11 deletions
|
|
@ -1050,7 +1050,8 @@ worker_init(struct worker* worker, struct config_file *cfg,
|
||||||
cfg->do_tcp?cfg->outgoing_num_tcp:0,
|
cfg->do_tcp?cfg->outgoing_num_tcp:0,
|
||||||
worker->daemon->env->infra_cache, worker->rndstate,
|
worker->daemon->env->infra_cache, worker->rndstate,
|
||||||
cfg->use_caps_bits_for_id, worker->ports, worker->numports,
|
cfg->use_caps_bits_for_id, worker->ports, worker->numports,
|
||||||
cfg->unwanted_threshold, &worker_alloc_cleanup, worker);
|
cfg->unwanted_threshold, &worker_alloc_cleanup, worker,
|
||||||
|
cfg->do_udp);
|
||||||
if(!worker->back) {
|
if(!worker->back) {
|
||||||
log_err("could not create outgoing sockets");
|
log_err("could not create outgoing sockets");
|
||||||
worker_delete(worker);
|
worker_delete(worker);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
29 October 2009: Wouter
|
29 October 2009: Wouter
|
||||||
- iana portlist updated.
|
- iana portlist updated.
|
||||||
- edns-buffer-size option, default 4096.
|
- edns-buffer-size option, default 4096.
|
||||||
|
- fixed do-udp: no.
|
||||||
|
|
||||||
28 October 2009: Wouter
|
28 October 2009: Wouter
|
||||||
- removed abort on prealloc failure, error still printed but softfail.
|
- removed abort on prealloc failure, error still printed but softfail.
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
|
||||||
cfg->do_tcp?cfg->outgoing_num_tcp:0,
|
cfg->do_tcp?cfg->outgoing_num_tcp:0,
|
||||||
w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id,
|
w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id,
|
||||||
ports, numports, cfg->unwanted_threshold,
|
ports, numports, cfg->unwanted_threshold,
|
||||||
&libworker_alloc_cleanup, w);
|
&libworker_alloc_cleanup, w, cfg->do_udp);
|
||||||
if(!w->is_bg || w->is_bg_thread) {
|
if(!w->is_bg || w->is_bg_thread) {
|
||||||
lock_basic_unlock(&ctx->cfglock);
|
lock_basic_unlock(&ctx->cfglock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,7 @@ outside_network_create(struct comm_base *base, size_t bufsize,
|
||||||
int do_ip6, size_t num_tcp, struct infra_cache* infra,
|
int do_ip6, size_t num_tcp, struct infra_cache* infra,
|
||||||
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
|
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
|
||||||
int numavailports, size_t unwanted_threshold,
|
int numavailports, size_t unwanted_threshold,
|
||||||
void (*unwanted_action)(void*), void* unwanted_param)
|
void (*unwanted_action)(void*), void* unwanted_param, int do_udp)
|
||||||
{
|
{
|
||||||
struct outside_network* outnet = (struct outside_network*)
|
struct outside_network* outnet = (struct outside_network*)
|
||||||
calloc(1, sizeof(struct outside_network));
|
calloc(1, sizeof(struct outside_network));
|
||||||
|
|
@ -490,6 +490,7 @@ outside_network_create(struct comm_base *base, size_t bufsize,
|
||||||
outnet->unwanted_action = unwanted_action;
|
outnet->unwanted_action = unwanted_action;
|
||||||
outnet->unwanted_param = unwanted_param;
|
outnet->unwanted_param = unwanted_param;
|
||||||
outnet->use_caps_for_id = use_caps_for_id;
|
outnet->use_caps_for_id = use_caps_for_id;
|
||||||
|
outnet->do_udp = do_udp;
|
||||||
if(numavailports == 0) {
|
if(numavailports == 0) {
|
||||||
log_err("no outgoing ports available");
|
log_err("no outgoing ports available");
|
||||||
outside_network_delete(outnet);
|
outside_network_delete(outnet);
|
||||||
|
|
@ -1439,6 +1440,24 @@ serviced_tcp_initiate(struct outside_network* outnet,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
serviced_tcp_send(struct serviced_query* sq, ldns_buffer* buff)
|
||||||
|
{
|
||||||
|
int vs, rtt;
|
||||||
|
uint8_t edns_lame_known;
|
||||||
|
if(!infra_host(sq->outnet->infra, &sq->addr, sq->addrlen,
|
||||||
|
*sq->outnet->now_secs, &vs, &edns_lame_known, &rtt))
|
||||||
|
return 0;
|
||||||
|
if(vs != -1)
|
||||||
|
sq->status = serviced_query_TCP_EDNS;
|
||||||
|
else sq->status = serviced_query_TCP;
|
||||||
|
serviced_encode(sq, buff, sq->status == serviced_query_TCP_EDNS);
|
||||||
|
sq->pending = pending_tcp_query(sq->outnet, buff, &sq->addr,
|
||||||
|
sq->addrlen, TCP_AUTH_QUERY_TIMEOUT, serviced_tcp_callback,
|
||||||
|
sq);
|
||||||
|
return sq->pending != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
serviced_udp_callback(struct comm_point* c, void* arg, int error,
|
serviced_udp_callback(struct comm_point* c, void* arg, int error,
|
||||||
struct comm_reply* rep)
|
struct comm_reply* rep)
|
||||||
|
|
@ -1582,12 +1601,22 @@ outnet_serviced_query(struct outside_network* outnet,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* perform first network action */
|
/* perform first network action */
|
||||||
if(!serviced_udp_send(sq, buff)) {
|
if(outnet->do_udp) {
|
||||||
(void)rbtree_delete(outnet->serviced, sq);
|
if(!serviced_udp_send(sq, buff)) {
|
||||||
free(sq->qbuf);
|
(void)rbtree_delete(outnet->serviced, sq);
|
||||||
free(sq);
|
free(sq->qbuf);
|
||||||
free(cb);
|
free(sq);
|
||||||
return NULL;
|
free(cb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!serviced_tcp_send(sq, buff)) {
|
||||||
|
(void)rbtree_delete(outnet->serviced, sq);
|
||||||
|
free(sq->qbuf);
|
||||||
|
free(sq);
|
||||||
|
free(cb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* add callback to list of callbacks */
|
/* add callback to list of callbacks */
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,8 @@ struct outside_network {
|
||||||
/** linked list of available commpoints, unused file descriptors,
|
/** linked list of available commpoints, unused file descriptors,
|
||||||
* for use as outgoing UDP ports. cp.fd=-1 in them. */
|
* for use as outgoing UDP ports. cp.fd=-1 in them. */
|
||||||
struct port_comm* unused_fds;
|
struct port_comm* unused_fds;
|
||||||
|
/** if udp is done */
|
||||||
|
int do_udp;
|
||||||
|
|
||||||
/** array of outgoing IP4 interfaces */
|
/** array of outgoing IP4 interfaces */
|
||||||
struct port_if* ip4_ifs;
|
struct port_if* ip4_ifs;
|
||||||
|
|
@ -347,6 +349,7 @@ struct serviced_query {
|
||||||
* @param unwanted_threshold: when to take defensive action.
|
* @param unwanted_threshold: when to take defensive action.
|
||||||
* @param unwanted_action: the action to take.
|
* @param unwanted_action: the action to take.
|
||||||
* @param unwanted_param: user parameter to action.
|
* @param unwanted_param: user parameter to action.
|
||||||
|
* @param do_udp: if udp is done.
|
||||||
* @return: the new structure (with no pending answers) or NULL on error.
|
* @return: the new structure (with no pending answers) or NULL on error.
|
||||||
*/
|
*/
|
||||||
struct outside_network* outside_network_create(struct comm_base* base,
|
struct outside_network* outside_network_create(struct comm_base* base,
|
||||||
|
|
@ -354,7 +357,7 @@ struct outside_network* outside_network_create(struct comm_base* base,
|
||||||
int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache* infra,
|
int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache* infra,
|
||||||
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
|
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
|
||||||
int numavailports, size_t unwanted_threshold,
|
int numavailports, size_t unwanted_threshold,
|
||||||
void (*unwanted_action)(void*), void* unwanted_param);
|
void (*unwanted_action)(void*), void* unwanted_param, int do_udp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete outside_network structure.
|
* Delete outside_network structure.
|
||||||
|
|
|
||||||
|
|
@ -851,7 +851,8 @@ outside_network_create(struct comm_base* base, size_t bufsize,
|
||||||
struct ub_randstate* ATTR_UNUSED(rnd),
|
struct ub_randstate* ATTR_UNUSED(rnd),
|
||||||
int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports),
|
int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports),
|
||||||
int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold),
|
int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold),
|
||||||
void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param))
|
void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param),
|
||||||
|
int ATTR_UNUSED(do_udp))
|
||||||
{
|
{
|
||||||
struct outside_network* outnet = calloc(1,
|
struct outside_network* outnet = calloc(1,
|
||||||
sizeof(struct outside_network));
|
sizeof(struct outside_network));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue