- Fix timeouts to keep track of query type, A, AAAA and other, if

another has caused timeout blacklist, different type can still probe.


git-svn-id: file:///svn/unbound/trunk@2613 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2012-02-10 12:17:25 +00:00
parent 358fd2ad07
commit 09b9ea04a3
9 changed files with 350 additions and 18 deletions
+29 -4
View File
@@ -147,6 +147,7 @@ delete_fake_pending(struct fake_pending* pend)
{
if(!pend)
return;
free(pend->zone);
ldns_buffer_free(pend->buffer);
ldns_pkt_free(pend->pkt);
free(pend);
@@ -554,7 +555,7 @@ do_infra_rtt(struct replay_runtime* runtime)
if(!dp) fatal_exit("cannot parse %s", now->variable);
rto = infra_rtt_update(runtime->infra, &now->addr,
now->addrlen, ldns_rdf_data(dp), ldns_rdf_size(dp),
atoi(now->string), -1, runtime->now_secs);
LDNS_RR_TYPE_A, atoi(now->string), -1, runtime->now_secs);
log_addr(0, "INFRA_RTT for", &now->addr, now->addrlen);
log_info("INFRA_RTT(%s roundtrip %d): rto of %d", now->variable,
atoi(now->string), rto);
@@ -562,6 +563,24 @@ do_infra_rtt(struct replay_runtime* runtime)
ldns_rdf_deep_free(dp);
}
/** perform exponential backoff on the timout */
static void
expon_timeout_backoff(struct replay_runtime* runtime)
{
struct fake_pending* p = runtime->pending_list;
int rtt, vs;
uint8_t edns_lame_known;
int last_rtt, rto;
if(!p) return; /* no pending packet to backoff */
if(!infra_host(runtime->infra, &p->addr, p->addrlen, p->zone,
p->zonelen, runtime->now_secs, &vs, &edns_lame_known, &rtt))
return;
last_rtt = rtt;
rto = infra_rtt_update(runtime->infra, &p->addr, p->addrlen, p->zone,
p->zonelen, p->qtype, -1, last_rtt, runtime->now_secs);
log_info("infra_rtt_update returned rto %d", rto);
}
/**
* Advance to the next moment.
*/
@@ -608,6 +627,7 @@ do_moment_and_advance(struct replay_runtime* runtime)
case repevt_timeout:
mom = runtime->now;
advance_moment(runtime);
expon_timeout_backoff(runtime);
fake_pending_callback(runtime, mom, NETEVENT_TIMEOUT);
break;
case repevt_back_reply:
@@ -929,6 +949,7 @@ pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
pend->timeout = timeout/1000;
pend->transport = transport_udp;
pend->pkt = NULL;
pend->zone = NULL;
pend->serviced = 0;
pend->runtime = runtime;
status = ldns_buffer2pkt_wire(&pend->pkt, packet);
@@ -982,6 +1003,7 @@ pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
pend->timeout = timeout;
pend->transport = transport_tcp;
pend->pkt = NULL;
pend->zone = NULL;
pend->runtime = runtime;
pend->serviced = 0;
status = ldns_buffer2pkt_wire(&pend->pkt, packet);
@@ -1017,9 +1039,8 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
uint16_t flags, int dnssec, int ATTR_UNUSED(want_dnssec),
int ATTR_UNUSED(tcp_upstream), int ATTR_UNUSED(ssl_upstream),
struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
size_t ATTR_UNUSED(zonelen), comm_point_callback_t* callback,
void* callback_arg, ldns_buffer* ATTR_UNUSED(buff),
int (*arg_compare)(void*,void*))
size_t zonelen, comm_point_callback_t* callback, void* callback_arg,
ldns_buffer* ATTR_UNUSED(buff), int (*arg_compare)(void*,void*))
{
struct replay_runtime* runtime = (struct replay_runtime*)outnet->base;
struct fake_pending* pend = (struct fake_pending*)calloc(1,
@@ -1062,6 +1083,10 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
}
memcpy(&pend->addr, addr, addrlen);
pend->addrlen = addrlen;
pend->zone = memdup(zone, zonelen);
pend->zonelen = zonelen;
pend->qtype = qtype;
log_assert(pend->zone);
pend->callback = callback;
pend->cb_arg = callback_arg;
pend->timeout = UDP_AUTH_QUERY_TIMEOUT;
+6
View File
@@ -323,6 +323,12 @@ struct fake_pending {
struct sockaddr_storage addr;
/** len of addr */
socklen_t addrlen;
/** zone name, uncompressed wire format (as used when sent) */
uint8_t* zone;
/** length of zone name */
size_t zonelen;
/** qtype */
int qtype;
/** The callback function to call when answer arrives (or timeout) */
comm_point_callback_t* callback;
/** callback user argument */
+1 -1
View File
@@ -445,7 +445,7 @@ infra_test(void)
&vs, &edns_lame, &to) );
unit_assert( vs == 0 && to == init && edns_lame == 0 );
unit_assert( infra_rtt_update(slab, &one, onelen, zone, zonelen, -1, init, now) );
unit_assert( infra_rtt_update(slab, &one, onelen, zone, zonelen, LDNS_RR_TYPE_A, -1, init, now) );
unit_assert( infra_host(slab, &one, onelen, zone, zonelen,
now, &vs, &edns_lame, &to) );
unit_assert( vs == 0 && to == init*2 && edns_lame == 0 );