]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
do-udp: no fixed.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 29 Oct 2009 12:11:38 +0000 (12:11 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 29 Oct 2009 12:11:38 +0000 (12:11 +0000)
git-svn-id: file:///svn/unbound/trunk@1882 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/worker.c
doc/Changelog
libunbound/libworker.c
services/outside_network.c
services/outside_network.h
testcode/fake_event.c

index 7d87595f8a5f8e681900167a044a07c170e81bde..26241817081a451aea7463cade02400efa74a371 100644 (file)
@@ -1050,7 +1050,8 @@ worker_init(struct worker* worker, struct config_file *cfg,
                cfg->do_tcp?cfg->outgoing_num_tcp:0, 
                worker->daemon->env->infra_cache, worker->rndstate,
                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) {
                log_err("could not create outgoing sockets");
                worker_delete(worker);
index 43de8fb2b1853e2aa53b41be86e5f8967df28db6..91f009f3931a13ed561e8ace1d699cd3a2812d20 100644 (file)
@@ -1,6 +1,7 @@
 29 October 2009: Wouter
        - iana portlist updated.
        - edns-buffer-size option, default 4096.
+       - fixed do-udp: no.
 
 28 October 2009: Wouter
        - removed abort on prealloc failure, error still printed but softfail.
index 3491b79cc8b3d25f53fbd4fd6134ded6ff03cfe7..f23b1af67a5c396c2a352cc7f7da306eb311d26d 100644 (file)
@@ -169,7 +169,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
                cfg->do_tcp?cfg->outgoing_num_tcp:0,
                w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id,
                ports, numports, cfg->unwanted_threshold,
-               &libworker_alloc_cleanup, w);
+               &libworker_alloc_cleanup, w, cfg->do_udp);
        if(!w->is_bg || w->is_bg_thread) {
                lock_basic_unlock(&ctx->cfglock);
        }
index 634f5fa5b84b45531dbcb7178687ce08f1a07f19..3af16a641f556b5a3c267596e9771463e1bbfadb 100644 (file)
@@ -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,
        struct ub_randstate* rnd, int use_caps_for_id, int* availports, 
        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*)
                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_param = unwanted_param;
        outnet->use_caps_for_id = use_caps_for_id;
+       outnet->do_udp = do_udp;
        if(numavailports == 0) {
                log_err("no outgoing ports available");
                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 
 serviced_udp_callback(struct comm_point* c, void* arg, int error,
         struct comm_reply* rep)
@@ -1582,12 +1601,22 @@ outnet_serviced_query(struct outside_network* outnet,
                        return NULL;
                }
                /* perform first network action */
-               if(!serviced_udp_send(sq, buff)) {
-                       (void)rbtree_delete(outnet->serviced, sq);
-                       free(sq->qbuf);
-                       free(sq);
-                       free(cb);
-                       return NULL;
+               if(outnet->do_udp) {
+                       if(!serviced_udp_send(sq, buff)) {
+                               (void)rbtree_delete(outnet->serviced, sq);
+                               free(sq->qbuf);
+                               free(sq);
+                               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 */
index 584f13a9bb09f5cef75705c59f16ff6f62764bed..342682524d219b56614bc7d6cb43883884f1df9b 100644 (file)
@@ -92,6 +92,8 @@ struct outside_network {
        /** linked list of available commpoints, unused file descriptors,
         * for use as outgoing UDP ports. cp.fd=-1 in them. */
        struct port_comm* unused_fds;
+       /** if udp is done */
+       int do_udp;
 
        /** array of outgoing IP4 interfaces */
        struct port_if* ip4_ifs;
@@ -347,6 +349,7 @@ struct serviced_query {
  * @param unwanted_threshold: when to take defensive action.
  * @param unwanted_action: the action to take.
  * @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.
  */
 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, 
        struct ub_randstate* rnd, int use_caps_for_id, int* availports, 
        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.
index e13126e0a2335e8a2ff0c63e4456f333675ba6b2..79b98f89f3f35fe0f1c4378f0807313b76425071 100644 (file)
@@ -851,7 +851,8 @@ outside_network_create(struct comm_base* base, size_t bufsize,
        struct ub_randstate* ATTR_UNUSED(rnd), 
        int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports),
        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, 
                sizeof(struct outside_network));