diff options
author | des <des@FreeBSD.org> | 2013-04-05 09:51:31 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2013-04-05 09:51:31 +0000 |
commit | 977c6e8c4173172b0a2399d8f55f18a3b815a947 (patch) | |
tree | a17550a8c82df6e46c2bb87a9d9faf38d76f9933 /contrib/unbound/services | |
parent | b0cbd784b12baa8ea27f7196e9a297847e8284c1 (diff) | |
parent | 35be22788f689639c1a53f650cd8a1fad60a1466 (diff) | |
download | FreeBSD-src-977c6e8c4173172b0a2399d8f55f18a3b815a947.zip FreeBSD-src-977c6e8c4173172b0a2399d8f55f18a3b815a947.tar.gz |
Upgrade to 1.4.20.
Diffstat (limited to 'contrib/unbound/services')
-rw-r--r-- | contrib/unbound/services/cache/infra.c | 5 | ||||
-rw-r--r-- | contrib/unbound/services/listen_dnsport.c | 31 | ||||
-rw-r--r-- | contrib/unbound/services/localzone.c | 4 | ||||
-rw-r--r-- | contrib/unbound/services/mesh.c | 22 | ||||
-rw-r--r-- | contrib/unbound/services/outside_network.c | 37 | ||||
-rw-r--r-- | contrib/unbound/services/outside_network.h | 9 |
6 files changed, 68 insertions, 40 deletions
diff --git a/contrib/unbound/services/cache/infra.c b/contrib/unbound/services/cache/infra.c index dbbd503..c674aca 100644 --- a/contrib/unbound/services/cache/infra.c +++ b/contrib/unbound/services/cache/infra.c @@ -403,6 +403,11 @@ infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr, data->timeout_other++; } } else { + /* if we got a reply, but the old timeout was above server + * selection height, delete the timeout so the server is + * fully available again */ + if(rtt_unclamped(&data->rtt) >= USEFUL_SERVER_TOP_TIMEOUT) + rtt_init(&data->rtt); rtt_update(&data->rtt, roundtrip); data->probedelay = 0; if(qtype == LDNS_RR_TYPE_A) diff --git a/contrib/unbound/services/listen_dnsport.c b/contrib/unbound/services/listen_dnsport.c index 59ca199..647cbe0 100644 --- a/contrib/unbound/services/listen_dnsport.c +++ b/contrib/unbound/services/listen_dnsport.c @@ -323,6 +323,11 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, log_err("setsockopt(..., IP_MTU_DISCOVER, " "IP_PMTUDISC_DONT...) failed: %s", strerror(errno)); +# ifndef USE_WINSOCK + close(s); +# else + closesocket(s); +# endif return -1; } # elif defined(IP_DONTFRAG) @@ -331,6 +336,11 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, &off, (socklen_t)sizeof(off)) < 0) { log_err("setsockopt(..., IP_DONTFRAG, ...) failed: %s", strerror(errno)); +# ifndef USE_WINSOCK + close(s); +# else + closesocket(s); +# endif return -1; } # endif /* IPv4 MTU */ @@ -408,9 +418,11 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto) #ifndef USE_WINSOCK log_err("setsockopt(.. SO_REUSEADDR ..) failed: %s", strerror(errno)); + close(s); #else log_err("setsockopt(.. SO_REUSEADDR ..) failed: %s", wsa_strerror(WSAGetLastError())); + closesocket(s); #endif return -1; } @@ -422,9 +434,11 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto) #ifndef USE_WINSOCK log_err("setsockopt(..., IPV6_V6ONLY, ...) failed: %s", strerror(errno)); + close(s); #else log_err("setsockopt(..., IPV6_V6ONLY, ...) failed: %s", wsa_strerror(WSAGetLastError())); + closesocket(s); #endif return -1; } @@ -443,23 +457,32 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto) (struct sockaddr_storage*)addr->ai_addr, addr->ai_addrlen); } + close(s); #else log_err("can't bind socket: %s", wsa_strerror(WSAGetLastError())); log_addr(0, "failed address", (struct sockaddr_storage*)addr->ai_addr, addr->ai_addrlen); + closesocket(s); #endif return -1; } if(!fd_set_nonblock(s)) { +#ifndef USE_WINSOCK + close(s); +#else + closesocket(s); +#endif return -1; } if(listen(s, TCP_BACKLOG) == -1) { #ifndef USE_WINSOCK log_err("can't listen: %s", strerror(errno)); + close(s); #else log_err("can't listen: %s", wsa_strerror(WSAGetLastError())); + closesocket(s); #endif return -1; } @@ -653,8 +676,14 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp, return 0; } /* getting source addr packet info is highly non-portable */ - if(!set_recvpktinfo(s, hints->ai_family)) + if(!set_recvpktinfo(s, hints->ai_family)) { +#ifndef USE_WINSOCK + close(s); +#else + closesocket(s); +#endif return 0; + } if(!port_insert(list, s, listen_type_udpancil)) { #ifndef USE_WINSOCK close(s); diff --git a/contrib/unbound/services/localzone.c b/contrib/unbound/services/localzone.c index 98d6943..9fdab51 100644 --- a/contrib/unbound/services/localzone.c +++ b/contrib/unbound/services/localzone.c @@ -449,8 +449,8 @@ lz_enter_rr_into_zone(struct local_zone* z, ldns_buffer* buf, struct local_data* node; struct local_rrset* rrset; struct packed_rrset_data* pd; - uint16_t rrtype, rrclass; - uint32_t ttl; + uint16_t rrtype = 0, rrclass = 0; + uint32_t ttl = 0; if(!get_rr_content(rrstr, &nm, &rrtype, &rrclass, &ttl, buf)) { log_err("bad local-data: %s", rrstr); return 0; diff --git a/contrib/unbound/services/mesh.c b/contrib/unbound/services/mesh.c index f6fd288..5c66caf 100644 --- a/contrib/unbound/services/mesh.c +++ b/contrib/unbound/services/mesh.c @@ -676,6 +676,7 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo, /* find it, if not, create it */ struct mesh_area* mesh = qstate->env->mesh; struct mesh_state* sub = mesh_area_find(mesh, qinfo, qflags, prime); + int was_detached; if(mesh_detect_cycle_found(qstate, sub)) { verbose(VERB_ALGO, "attach failed, cycle detected"); return 0; @@ -706,9 +707,12 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo, *newq = &sub->s; } else *newq = NULL; + was_detached = (sub->super_set.count == 0); if(!mesh_state_attachment(qstate->mesh_info, sub)) return 0; - if(!sub->reply_list && !sub->cb_list && sub->super_set.count == 1) { + /* if it was a duplicate attachment, the count was not zero before */ + if(!sub->reply_list && !sub->cb_list && was_detached && + sub->super_set.count == 1) { /* it used to be detached, before this one got added */ log_assert(mesh->num_detached_states > 0); mesh->num_detached_states--; @@ -735,16 +739,20 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub) superref->s = super; subref->node.key = subref; subref->s = sub; -#ifdef UNBOUND_DEBUG - n = -#endif - rbtree_insert(&sub->super_set, &superref->node); - log_assert(n != NULL); + if(!rbtree_insert(&sub->super_set, &superref->node)) { + /* this should not happen, iterator and validator do not + * attach subqueries that are identical. */ + /* already attached, we are done, nothing todo. + * since superref and subref already allocated in region, + * we cannot free them */ + return 1; + } #ifdef UNBOUND_DEBUG n = #endif rbtree_insert(&super->sub_set, &subref->node); - log_assert(n != NULL); + log_assert(n != NULL); /* we checked above if statement, the reverse + administration should not fail now, unless they are out of sync */ return 1; } diff --git a/contrib/unbound/services/outside_network.c b/contrib/unbound/services/outside_network.c index 24d65db..e1cd0fd 100644 --- a/contrib/unbound/services/outside_network.c +++ b/contrib/unbound/services/outside_network.c @@ -58,7 +58,9 @@ #include "util/net_help.h" #include "util/random.h" #include "util/fptr_wlist.h" +#ifdef HAVE_OPENSSL_SSL_H #include <openssl/ssl.h> +#endif #ifdef HAVE_NETDB_H #include <netdb.h> @@ -297,9 +299,11 @@ decomission_pending_tcp(struct outside_network* outnet, struct pending_tcp* pend) { if(pend->c->ssl) { +#ifdef HAVE_SSL SSL_shutdown(pend->c->ssl); SSL_free(pend->c->ssl); pend->c->ssl = NULL; +#endif } comm_point_close(pend->c); pend->next_free = outnet->tcp_free; @@ -1439,7 +1443,7 @@ static void serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, struct comm_reply* rep) { - struct service_callback* p = sq->cblist, *n; + struct service_callback* p; int dobackup = (sq->cblist && sq->cblist->next); /* >1 cb*/ uint8_t *backup_p = NULL; size_t backlen = 0; @@ -1498,8 +1502,9 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, } sq->outnet->svcd_overhead = backlen; } - while(p) { - n = p->next; + /* test the actual sq->cblist, because the next elem could be deleted*/ + while((p=sq->cblist) != NULL) { + sq->cblist = p->next; /* remove this element */ if(dobackup && c) { ldns_buffer_clear(c->buffer); ldns_buffer_write(c->buffer, backup_p, backlen); @@ -1507,7 +1512,7 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, } fptr_ok(fptr_whitelist_serviced_query(p->cb)); (void)(*p->cb)(c, p->cb_arg, error, rep); - p = n; + free(p); } if(backup_p) { free(backup_p); @@ -1781,37 +1786,21 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, return 0; } -/** find callback in list */ -static struct service_callback* -callback_list_find(struct serviced_query* sq, void* cb_arg, - int (*arg_compare)(void*,void*)) -{ - struct service_callback* p; - for(p = sq->cblist; p; p = p->next) { - if(arg_compare(p->cb_arg, cb_arg)) - return p; - } - return NULL; -} - struct serviced_query* outnet_serviced_query(struct outside_network* outnet, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, int want_dnssec, int tcp_upstream, int ssl_upstream, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone, size_t zonelen, comm_point_callback_t* callback, - void* callback_arg, ldns_buffer* buff, int (*arg_compare)(void*,void*)) + void* callback_arg, ldns_buffer* buff) { struct serviced_query* sq; struct service_callback* cb; serviced_gen_query(buff, qname, qnamelen, qtype, qclass, flags); sq = lookup_serviced(outnet, buff, dnssec, addr, addrlen); - if(sq) { - /* see if it is a duplicate notification request for cb_arg */ - if(callback_list_find(sq, callback_arg, arg_compare)) { - return sq; - } - } + /* duplicate entries are included in the callback list, because + * there is a counterpart registration by our caller that needs to + * be doubly-removed (with callbacks perhaps). */ if(!(cb = (struct service_callback*)malloc(sizeof(*cb)))) return NULL; if(!sq) { diff --git a/contrib/unbound/services/outside_network.h b/contrib/unbound/services/outside_network.h index ab18d24..9ec81f4 100644 --- a/contrib/unbound/services/outside_network.h +++ b/contrib/unbound/services/outside_network.h @@ -279,9 +279,9 @@ struct service_callback { }; /** fallback size for fragmentation for EDNS in IPv4 */ -#define EDNS_FRAG_SIZE_IP4 1480 +#define EDNS_FRAG_SIZE_IP4 1472 /** fallback size for EDNS in IPv6, fits one fragment with ip6-tunnel-ids */ -#define EDNS_FRAG_SIZE_IP6 1260 +#define EDNS_FRAG_SIZE_IP6 1232 /** * Query service record. @@ -468,8 +468,6 @@ void pending_delete(struct outside_network* outnet, struct pending* p); authoritative. * @param zonelen: length of zone. * @param buff: scratch buffer to create query contents in. Empty on exit. - * @param arg_compare: function to compare callback args, return true if - * identical. It is given the callback_arg and args that are listed. * @return 0 on error, or pointer to serviced query that is used to answer * this serviced query may be shared with other callbacks as well. */ @@ -478,8 +476,7 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet, uint16_t flags, int dnssec, int want_dnssec, int tcp_upstream, int ssl_upstream, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone, size_t zonelen, comm_point_callback_t* callback, - void* callback_arg, ldns_buffer* buff, - int (*arg_compare)(void*,void*)); + void* callback_arg, ldns_buffer* buff); /** * Remove service query callback. |