mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-23 16:20:26 -05:00
- infra cache entries that are expired are wiped clean. Previously
it was possible to not expire host data (if accessed often). git-svn-id: file:///svn/unbound/trunk@2106 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
5c4fbf10b1
commit
8f4957a0e0
2 changed files with 24 additions and 15 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
29 April 2010: Wouter
|
29 April 2010: Wouter
|
||||||
- Fix for dnssec lameness detection to use the key cache.
|
- Fix for dnssec lameness detection to use the key cache.
|
||||||
|
- infra cache entries that are expired are wiped clean. Previously
|
||||||
|
it was possible to not expire host data (if accessed often).
|
||||||
|
|
||||||
28 April 2010: Wouter
|
28 April 2010: Wouter
|
||||||
- ldns tarball updated and GOST support is detected and then enabled.
|
- ldns tarball updated and GOST support is detected and then enabled.
|
||||||
|
|
|
||||||
33
services/cache/infra.c
vendored
33
services/cache/infra.c
vendored
|
|
@ -187,6 +187,19 @@ infra_lookup_host(struct infra_cache* infra,
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** init the host elements (not lame elems) */
|
||||||
|
static void
|
||||||
|
host_entry_init(struct infra_cache* infra, struct lruhash_entry* e,
|
||||||
|
uint32_t timenow)
|
||||||
|
{
|
||||||
|
struct infra_host_data* data = (struct infra_host_data*)e->data;
|
||||||
|
data->ttl = timenow + infra->host_ttl;
|
||||||
|
rtt_init(&data->rtt);
|
||||||
|
data->edns_version = 0;
|
||||||
|
data->edns_lame_known = 0;
|
||||||
|
data->num_timeouts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and init a new entry for a host
|
* Create and init a new entry for a host
|
||||||
* @param infra: infra structure with config parameters.
|
* @param infra: infra structure with config parameters.
|
||||||
|
|
@ -216,12 +229,8 @@ new_host_entry(struct infra_cache* infra, struct sockaddr_storage* addr,
|
||||||
key->entry.data = (void*)data;
|
key->entry.data = (void*)data;
|
||||||
key->addrlen = addrlen;
|
key->addrlen = addrlen;
|
||||||
memcpy(&key->addr, addr, addrlen);
|
memcpy(&key->addr, addr, addrlen);
|
||||||
data->ttl = tm + infra->host_ttl;
|
|
||||||
data->lameness = NULL;
|
data->lameness = NULL;
|
||||||
data->edns_version = 0;
|
host_entry_init(infra, &key->entry, tm);
|
||||||
data->edns_lame_known = 0;
|
|
||||||
data->num_timeouts = 0;
|
|
||||||
rtt_init(&data->rtt);
|
|
||||||
return &key->entry;
|
return &key->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,12 +249,8 @@ infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
|
||||||
if(e) {
|
if(e) {
|
||||||
/* if its still there we have a writelock, init */
|
/* if its still there we have a writelock, init */
|
||||||
/* re-initialise */
|
/* re-initialise */
|
||||||
data = (struct infra_host_data*)e->data;
|
|
||||||
data->ttl = timenow + infra->host_ttl;
|
|
||||||
rtt_init(&data->rtt);
|
|
||||||
/* do not touch lameness, it may be valid still */
|
/* do not touch lameness, it may be valid still */
|
||||||
data->edns_version = 0;
|
host_entry_init(infra, e, timenow);
|
||||||
data->edns_lame_known = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!e) {
|
if(!e) {
|
||||||
|
|
@ -469,10 +474,11 @@ infra_rtt_update(struct infra_cache* infra,
|
||||||
if(!(e = new_host_entry(infra, addr, addrlen, timenow)))
|
if(!(e = new_host_entry(infra, addr, addrlen, timenow)))
|
||||||
return 0;
|
return 0;
|
||||||
needtoinsert = 1;
|
needtoinsert = 1;
|
||||||
|
} else if(((struct infra_host_data*)e->data)->ttl < timenow) {
|
||||||
|
host_entry_init(infra, e, timenow);
|
||||||
}
|
}
|
||||||
/* have an entry, update the rtt, and the ttl */
|
/* have an entry, update the rtt */
|
||||||
data = (struct infra_host_data*)e->data;
|
data = (struct infra_host_data*)e->data;
|
||||||
data->ttl = timenow + infra->host_ttl;
|
|
||||||
if(roundtrip == -1) {
|
if(roundtrip == -1) {
|
||||||
rtt_lost(&data->rtt, orig_rtt);
|
rtt_lost(&data->rtt, orig_rtt);
|
||||||
if(data->num_timeouts<255)
|
if(data->num_timeouts<255)
|
||||||
|
|
@ -503,10 +509,11 @@ infra_edns_update(struct infra_cache* infra,
|
||||||
if(!(e = new_host_entry(infra, addr, addrlen, timenow)))
|
if(!(e = new_host_entry(infra, addr, addrlen, timenow)))
|
||||||
return 0;
|
return 0;
|
||||||
needtoinsert = 1;
|
needtoinsert = 1;
|
||||||
|
} else if(((struct infra_host_data*)e->data)->ttl < timenow) {
|
||||||
|
host_entry_init(infra, e, timenow);
|
||||||
}
|
}
|
||||||
/* have an entry, update the rtt, and the ttl */
|
/* have an entry, update the rtt, and the ttl */
|
||||||
data = (struct infra_host_data*)e->data;
|
data = (struct infra_host_data*)e->data;
|
||||||
data->ttl = timenow + infra->host_ttl;
|
|
||||||
data->edns_version = edns_version;
|
data->edns_version = edns_version;
|
||||||
data->edns_lame_known = 1;
|
data->edns_lame_known = 1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue