mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Cleaner code for mesh_serve_expired_lookup.
This commit is contained in:
parent
4089147351
commit
5d6358b66d
2 changed files with 16 additions and 32 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
6 February 2020: George
|
6 February 2020: George
|
||||||
- Fix num_reply_states and num_detached_states counting with
|
- Fix num_reply_states and num_detached_states counting with
|
||||||
serve_expired_callback.
|
serve_expired_callback.
|
||||||
|
- Cleaner code in mesh_serve_expired_lookup.
|
||||||
|
|
||||||
6 February 2020: Wouter
|
6 February 2020: Wouter
|
||||||
- Fix num_reply_addr counting in mesh and tcp drop due to size
|
- Fix num_reply_addr counting in mesh and tcp drop due to size
|
||||||
|
|
|
||||||
|
|
@ -354,62 +354,45 @@ mesh_serve_expired_lookup(struct module_qstate* qstate,
|
||||||
hashvalue_type h;
|
hashvalue_type h;
|
||||||
struct lruhash_entry* e;
|
struct lruhash_entry* e;
|
||||||
struct dns_msg* msg;
|
struct dns_msg* msg;
|
||||||
struct reply_info* rep, *data;
|
struct reply_info* data;
|
||||||
struct msgreply_entry* key;
|
struct msgreply_entry* key;
|
||||||
time_t timenow = *qstate->env->now;
|
time_t timenow = *qstate->env->now;
|
||||||
time_t time_control = timenow;
|
|
||||||
int must_validate = (!(qstate->query_flags&BIT_CD)
|
int must_validate = (!(qstate->query_flags&BIT_CD)
|
||||||
|| qstate->env->cfg->ignore_cd) && qstate->env->need_to_validate;
|
|| qstate->env->cfg->ignore_cd) && qstate->env->need_to_validate;
|
||||||
/* Lookup cache */
|
/* Lookup cache */
|
||||||
h = query_info_hash(lookup_qinfo, qstate->query_flags);
|
h = query_info_hash(lookup_qinfo, qstate->query_flags);
|
||||||
e = slabhash_lookup(qstate->env->msg_cache, h, lookup_qinfo, 0);
|
e = slabhash_lookup(qstate->env->msg_cache, h, lookup_qinfo, 0);
|
||||||
if(!e) return NULL;
|
if(!e) return NULL;
|
||||||
rep = (struct reply_info*)e->data;
|
|
||||||
/* Check TTL */
|
key = (struct msgreply_entry*)e->key;
|
||||||
if(rep->ttl < timenow) {
|
data = (struct reply_info*)e->data;
|
||||||
/* Check if we need to serve expired now */
|
msg = tomsg(qstate->env, &key->key, data, qstate->region, timenow,
|
||||||
if(qstate->env->cfg->serve_expired) {
|
qstate->env->cfg->serve_expired, qstate->env->scratch);
|
||||||
if(qstate->env->cfg->serve_expired_ttl &&
|
if(!msg)
|
||||||
rep->serve_expired_ttl < timenow)
|
goto bail_out;
|
||||||
goto bail_out;
|
|
||||||
time_control = timenow;
|
|
||||||
} else {
|
|
||||||
/* the rrsets may have been updated in the meantime.
|
|
||||||
* we will refetch the message format from the
|
|
||||||
* authoritative server
|
|
||||||
*/
|
|
||||||
goto bail_out;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
time_control = timenow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check CNAME chain (if any)
|
/* Check CNAME chain (if any)
|
||||||
* This is part of tomsg further down; no need to check now. */
|
* This is part of tomsg above; no need to check now. */
|
||||||
|
|
||||||
/* Check security status of the cached answer.
|
/* Check security status of the cached answer.
|
||||||
* tomsg further down has a subset of these checks, so we are leaving
|
* tomsg above has a subset of these checks, so we are leaving
|
||||||
* these as is.
|
* these as is.
|
||||||
* In case of bogus or revalidation we don't care to reply here. */
|
* In case of bogus or revalidation we don't care to reply here. */
|
||||||
if(must_validate && (rep->security == sec_status_bogus ||
|
if(must_validate && (msg->rep->security == sec_status_bogus ||
|
||||||
rep->security == sec_status_secure_sentinel_fail)) {
|
msg->rep->security == sec_status_secure_sentinel_fail)) {
|
||||||
verbose(VERB_ALGO, "Serve expired: bogus answer found in cache");
|
verbose(VERB_ALGO, "Serve expired: bogus answer found in cache");
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
} else if(rep->security == sec_status_unchecked && must_validate) {
|
} else if(msg->rep->security == sec_status_unchecked && must_validate) {
|
||||||
verbose(VERB_ALGO, "Serve expired: unchecked entry needs "
|
verbose(VERB_ALGO, "Serve expired: unchecked entry needs "
|
||||||
"validation");
|
"validation");
|
||||||
goto bail_out; /* need to validate cache entry first */
|
goto bail_out; /* need to validate cache entry first */
|
||||||
} else if(rep->security == sec_status_secure &&
|
} else if(msg->rep->security == sec_status_secure &&
|
||||||
!reply_all_rrsets_secure(rep) && must_validate) {
|
!reply_all_rrsets_secure(msg->rep) && must_validate) {
|
||||||
verbose(VERB_ALGO, "Serve expired: secure entry"
|
verbose(VERB_ALGO, "Serve expired: secure entry"
|
||||||
" changed status");
|
" changed status");
|
||||||
goto bail_out; /* rrset changed, re-verify */
|
goto bail_out; /* rrset changed, re-verify */
|
||||||
}
|
}
|
||||||
|
|
||||||
key = (struct msgreply_entry*)e->key;
|
|
||||||
data = (struct reply_info*)e->data;
|
|
||||||
msg = tomsg(qstate->env, &key->key, data, qstate->region, time_control,
|
|
||||||
qstate->env->cfg->serve_expired, qstate->env->scratch);
|
|
||||||
lock_rw_unlock(&e->lock);
|
lock_rw_unlock(&e->lock);
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue