From 75bce22b30e6ec2d2499603cc4898703a980dd70 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 21 May 2010 11:00:35 +0000 Subject: [PATCH] - EDNS timeout code will not fire if EDNS status already known. - EDNS failure not stored if EDNS status known to work. git-svn-id: file:///svn/unbound/trunk@2115 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 4 ++++ services/cache/infra.c | 7 +++++-- services/cache/infra.h | 1 + services/outside_network.c | 11 ++++------- testcode/unitmain.c | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 012ece3ba..3df67f323 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +21 May 2010: Wouter + - EDNS timeout code will not fire if EDNS status already known. + - EDNS failure not stored if EDNS status known to work. + 19 May 2010: Wouter - Fix resolution for domains like safesvc.com.cn. If the iterator can not recurse further and it finds the delegation in a state diff --git a/services/cache/infra.c b/services/cache/infra.c index 6066f98bb..219a67a6b 100644 --- a/services/cache/infra.c +++ b/services/cache/infra.c @@ -514,8 +514,11 @@ infra_edns_update(struct infra_cache* infra, } /* have an entry, update the rtt, and the ttl */ data = (struct infra_host_data*)e->data; - data->edns_version = edns_version; - data->edns_lame_known = 1; + /* do not update if noEDNS and stored is yesEDNS */ + if(!(edns_version == -1 && data->edns_version != -1)) { + data->edns_version = edns_version; + data->edns_lame_known = 1; + } if(needtoinsert) slabhash_insert(infra->hosts, e->hash, e, e->data, NULL); diff --git a/services/cache/infra.h b/services/cache/infra.h index e6fc3cda2..80321b0e1 100644 --- a/services/cache/infra.h +++ b/services/cache/infra.h @@ -251,6 +251,7 @@ void infra_update_tcp_works(struct infra_cache* infra, * @param addr: host address. * @param addrlen: length of addr. * @param edns_version: the version that it publishes. + * If it is known to support EDNS then no-EDNS is not stored over it. * @param timenow: what time it is now. * @return: 0 on error. */ diff --git a/services/outside_network.c b/services/outside_network.c index aeb44971a..91614024d 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -1244,8 +1244,7 @@ serviced_udp_send(struct serviced_query* sq, ldns_buffer* buff) &edns_lame_known, &rtt)) return 0; if(sq->status == serviced_initial) { - if((vs != -1 || edns_lame_known == 0) && - rtt > 5000 && rtt < 10001) { + if(edns_lame_known == 0 && rtt > 5000 && rtt < 10001) { /* perform EDNS lame probe - check if server is * EDNS lame (EDNS queries to it are dropped) */ verbose(VERB_ALGO, "serviced query: send probe to see " @@ -1494,11 +1493,9 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, if(error == NETEVENT_TIMEOUT) { int rto = 0; if(sq->status == serviced_query_PROBE_EDNS) { - /* non-EDNS probe failed; not an EDNS lame server */ - if(!infra_edns_update(outnet->infra, &sq->addr, - sq->addrlen, 0, (uint32_t)now.tv_sec)) { - log_err("Out of memory caching edns works"); - } + /* non-EDNS probe failed; we do not know its status, + * keep trying with EDNS, timeout may not be caused + * by EDNS. */ sq->status = serviced_query_UDP_EDNS; } sq->retry++; diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 9105afb88..d4750df65 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -407,7 +407,7 @@ infra_test() unit_assert( infra_edns_update(slab, &one, onelen, -1, now) ); unit_assert( infra_host(slab, &one, onelen, now, &vs, &edns_lame, &to) ); - unit_assert( vs == -1 && to == init*2 && edns_lame == 1); + unit_assert( vs == 0 && to == init*2 && edns_lame == 0); now += cfg->host_ttl + 10; unit_assert( infra_host(slab, &one, onelen, -- 2.47.2