Skip to content

Commit

Permalink
remove lost and backoff values.
Browse files Browse the repository at this point in the history
git-svn-id: https://unbound.nlnetlabs.nl/svn/trunk@2309 be551aaa-1e26-0410-a405-d3ace91eadb9
  • Loading branch information
wouter committed Oct 26, 2010
1 parent ee39f03 commit ef38180
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 63 deletions.
19 changes: 7 additions & 12 deletions daemon/cachedump.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
{
char buf[257];
struct delegpt_addr* a;
int lame, dlame, rlame, rtt, edns_vs, to, lost;
int entry_ttl, clean_rtt, backoff;
int lame, dlame, rlame, rtt, edns_vs, to;
int entry_ttl, clean_rtt;
uint8_t edns_lame_known;
for(a = dp->target_list; a; a = a->next_target) {
addr_to_str(&a->addr, a->addrlen, buf, sizeof(buf));
Expand All @@ -815,15 +815,14 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
}
/* lookup in infra cache */
entry_ttl = infra_get_host_rto(worker->env.infra_cache,
&a->addr, a->addrlen, &clean_rtt, &rtt, &backoff,
&a->addr, a->addrlen, &clean_rtt, &rtt,
*worker->env.now);
if(entry_ttl == -1) {
if(!ssl_printf(ssl, "not in infra cache.\n"))
return;
continue; /* skip stuff not in infra cache */
} else if(entry_ttl == -2) {
if(!ssl_printf(ssl, "not in infra cache "
"(backoff %d).\n", backoff))
if(!ssl_printf(ssl, "not in infra cache.\n"))
return;
continue; /* skip stuff not in infra cache */
}
Expand All @@ -832,25 +831,21 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
* lameness won't be reported then */
if(!infra_get_lame_rtt(worker->env.infra_cache,
&a->addr, a->addrlen, dp->name, dp->namelen,
LDNS_RR_TYPE_A, &lame, &dlame, &rlame, &rtt, &lost,
LDNS_RR_TYPE_A, &lame, &dlame, &rlame, &rtt,
*worker->env.now)) {
if(!ssl_printf(ssl, "not in infra cache.\n"))
return;
continue; /* skip stuff not in infra cache */
}
if(!ssl_printf(ssl, "%s%s%s%srtt %d msec, %d lost, ttl %d",
if(!ssl_printf(ssl, "%s%s%s%srtt %d msec, ttl %d",
lame?"LAME ":"", dlame?"NoDNSSEC ":"",
a->lame?"AddrWasParentSide ":"",
rlame?"NoAuthButRecursive ":"", rtt, lost, entry_ttl))
rlame?"NoAuthButRecursive ":"", rtt, entry_ttl))
return;
if(rtt != clean_rtt && clean_rtt != 376 /* unknown */) {
if(!ssl_printf(ssl, ", ping %d", clean_rtt))
return;
}
if(backoff != INFRA_BACKOFF_INITIAL) {
if(!ssl_printf(ssl, ", backoff %d", backoff))
return;
}
if(infra_host(worker->env.infra_cache, &a->addr, a->addrlen,
*worker->env.now, &edns_vs, &edns_lame_known, &to)) {
if(edns_vs == -1) {
Expand Down
10 changes: 2 additions & 8 deletions daemon/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,21 +1567,15 @@ dump_infra_host(struct lruhash_entry* e, void* arg)
a->ipstr = ip_str;
/* skip expired stuff (only backed off) */
if(d->ttl < a->now) {
if(d->backoff != INFRA_BACKOFF_INITIAL) {
if(!ssl_printf(a->ssl, "%s expired, backoff is %d\n",
ip_str, (int)d->backoff))
return;
}
if(d->lameness)
lruhash_traverse(d->lameness, 0, &dump_infra_lame, arg);
return;
}
if(!ssl_printf(a->ssl, "%s ttl %d ping %d var %d rtt %d rto %d "
"backoff %d ednsknown %d edns %d\n",
"ednsknown %d edns %d\n",
ip_str, (int)(d->ttl - a->now),
d->rtt.srtt, d->rtt.rttvar, rtt_notimeout(&d->rtt), d->rtt.rto,
(int)d->backoff, (int)d->edns_lame_known, (int)d->edns_version
))
(int)d->edns_lame_known, (int)d->edns_version))
return;
if(d->lameness)
lruhash_traverse(d->lameness, 0, &dump_infra_lame, arg);
Expand Down
6 changes: 3 additions & 3 deletions iterator/iter_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
uint8_t* name, size_t namelen, uint16_t qtype, uint32_t now,
struct delegpt_addr* a)
{
int rtt, lame, reclame, dnsseclame, lost;
int rtt, lame, reclame, dnsseclame;
if(a->bogus)
return -1; /* address of server is bogus */
if(donotq_lookup(iter_env->donotq, &a->addr, a->addrlen)) {
Expand All @@ -197,9 +197,9 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
/* check lameness - need zone , class info */
if(infra_get_lame_rtt(env->infra_cache, &a->addr, a->addrlen,
name, namelen, qtype, &lame, &dnsseclame, &reclame,
&rtt, &lost, now)) {
&rtt, now)) {
log_addr(VERB_ALGO, "servselect", &a->addr, a->addrlen);
verbose(VERB_ALGO, " rtt=%d lost=%d%s%s%s%s", rtt, lost,
verbose(VERB_ALGO, " rtt=%d%s%s%s%s", rtt,
lame?" LAME":"",
dnsseclame?" DNSSEC_LAME":"",
reclame?" REC_LAME":"",
Expand Down
32 changes: 3 additions & 29 deletions services/cache/infra.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ infra_lookup_host(struct infra_cache* infra,
return data;
}

/** init the host elements (not lame elems, not backoff) */
/** init the host elements (not lame elems) */
static void
host_entry_init(struct infra_cache* infra, struct lruhash_entry* e,
uint32_t timenow)
Expand All @@ -213,7 +213,6 @@ host_entry_init(struct infra_cache* infra, struct lruhash_entry* e,
rtt_init(&data->rtt);
data->edns_version = 0;
data->edns_lame_known = 0;
data->num_timeouts = 0;
}

/**
Expand Down Expand Up @@ -246,7 +245,6 @@ new_host_entry(struct infra_cache* infra, struct sockaddr_storage* addr,
key->addrlen = addrlen;
memcpy(&key->addr, addr, addrlen);
data->lameness = NULL;
data->backoff = INFRA_BACKOFF_INITIAL;
host_entry_init(infra, &key->entry, tm);
return &key->entry;
}
Expand Down Expand Up @@ -497,30 +495,9 @@ infra_rtt_update(struct infra_cache* infra,
/* have an entry, update the rtt */
data = (struct infra_host_data*)e->data;
if(roundtrip == -1) {
int o = rtt_timeout(&data->rtt);
rtt_lost(&data->rtt, orig_rtt);
if(rtt_timeout(&data->rtt) >= USEFUL_SERVER_TOP_TIMEOUT
&& o < USEFUL_SERVER_TOP_TIMEOUT) {
/* backoff the blacklisted timeout */
log_addr(VERB_ALGO, "backoff for", addr, addrlen);
data->backoff *= 2;
if(data->backoff >= 24*3600)
data->backoff = 24*3600;
verbose(VERB_ALGO, "backoff to %d", data->backoff);
/* increase the infra item TTL */
data->ttl = timenow + data->backoff;
}

if(data->num_timeouts<255)
data->num_timeouts++;
} else {
rtt_update(&data->rtt, roundtrip);
/* un-backoff the element */
if(data->backoff > (uint32_t)infra->host_ttl*2)
data->backoff = (uint32_t)infra->host_ttl*2;
else data->backoff = INFRA_BACKOFF_INITIAL;

data->num_timeouts = 0;
}
if(data->rtt.rto > 0)
rto = data->rtt.rto;
Expand All @@ -533,15 +510,14 @@ infra_rtt_update(struct infra_cache* infra,

int infra_get_host_rto(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
int* rtt, int* rto, int* backoff, uint32_t timenow)
int* rtt, int* rto, uint32_t timenow)
{
struct lruhash_entry* e = infra_lookup_host_nottl(infra, addr,
addrlen, 0);
struct infra_host_data* data;
int ttl = -2;
if(!e) return -1;
data = (struct infra_host_data*)e->data;
*backoff = (int)data->backoff;
if(data->ttl >= timenow) {
ttl = (int)(data->ttl - timenow);
*rtt = rtt_notimeout(&data->rtt);
Expand Down Expand Up @@ -585,8 +561,7 @@ int
infra_get_lame_rtt(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* name, size_t namelen, uint16_t qtype,
int* lame, int* dnsseclame, int* reclame, int* rtt, int* lost,
uint32_t timenow)
int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow)
{
struct infra_host_data* host;
struct lruhash_entry* e = infra_lookup_host_nottl(infra, addr,
Expand All @@ -596,7 +571,6 @@ infra_get_lame_rtt(struct infra_cache* infra,
return 0;
host = (struct infra_host_data*)e->data;
*rtt = rtt_unclamped(&host->rtt);
*lost = (int)host->num_timeouts;
/* check lameness first, if so, ttl on host does not matter anymore */
if(infra_lookup_lame(host, name, namelen, timenow,
&dlm, &rlm, &alm, &olm)) {
Expand Down
14 changes: 3 additions & 11 deletions services/cache/infra.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ struct infra_host_key {
struct infra_host_data {
/** TTL value for this entry. absolute time. */
uint32_t ttl;
/** backoff time if blacklisted unresponsive. in seconds. */
uint32_t backoff;
/** round trip times for timeout calculation */
struct rtt_info rtt;
/** Names of the zones that are lame. NULL=no lame zones. */
Expand All @@ -76,8 +74,6 @@ struct infra_host_data {
* EDNS lame is when EDNS queries or replies are dropped,
* and cause a timeout */
uint8_t edns_lame_known;
/** Number of consequtive timeouts; reset when reply arrives OK. */
uint8_t num_timeouts;
};

/**
Expand Down Expand Up @@ -281,16 +277,13 @@ int infra_edns_update(struct infra_cache* infra,
* @param reclame: if function returns true, this is if it is recursion lame.
* @param rtt: if function returns true, this returns avg rtt of the server.
* The rtt value is unclamped and reflects recent timeouts.
* @param lost: number of queries lost in a row. Reset to 0 when an answer
* gets back. Gives a connectivity number.
* @param timenow: what time it is now.
* @return if found in cache, or false if not (or TTL bad).
*/
int infra_get_lame_rtt(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* name, size_t namelen, uint16_t qtype,
int* lame, int* dnsseclame, int* reclame, int* rtt, int* lost,
uint32_t timenow);
int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow);

/**
* Get additional (debug) info on timing.
Expand All @@ -299,14 +292,13 @@ int infra_get_lame_rtt(struct infra_cache* infra,
* @param addrlen: length of addr.
* @param rtt: the clean rtt time (of working replies).
* @param rto: the rtt with timeouts applied. (rtt as returned by other funcs).
* @param backoff: the backoff time for blacked entries.
* @param timenow: what time it is now.
* @return TTL the infra host element is valid for. If -1: not found in cache.
* If -2: found in cache, but TTL was not valid, only backoff is filled.
* If -2: found in cache, but TTL was not valid.
*/
int infra_get_host_rto(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
int* rtt, int* rto, int* backoff, uint32_t timenow);
int* rtt, int* rto, uint32_t timenow);

/**
* Get memory used by the infra cache.
Expand Down

0 comments on commit ef38180

Please sign in to comment.