iq->qchase.qname_len = slen;
/* This *is* a query restart, even if it is a cheap
* one. */
+ iq->dp = NULL;
+ iq->refetch_glue = 0;
iq->query_restart_count++;
return next_state(iq, INIT_REQUEST_STATE);
}
log_err("alloc failure for forward dp");
return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
}
+ iq->refetch_glue = 0;
/* the request has been forwarded.
* forwarded requests need to be immediately sent to the
* next state, QUERYTARGETS. */
return 0;
}
+/** find NS rrset in given list */
+static struct ub_packed_rrset_key*
+find_NS(struct reply_info* rep, size_t from, size_t to)
+{
+ size_t i;
+ for(i=from; i<to; i++) {
+ if(ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NS)
+ return rep->rrsets[i];
+ }
+ return NULL;
+}
+
+
/**
* Process the query response. All queries end up at this state first. This
* process generally consists of analyzing the response and routing the
dnsseclame = 1;
}
}
+ /* see if referral brings us close to the target */
+ if(type == RESPONSE_TYPE_REFERRAL) {
+ struct ub_packed_rrset_key* ns = find_NS(
+ iq->response->rep, iq->response->rep->an_numrrsets,
+ iq->response->rep->an_numrrsets
+ + iq->response->rep->ns_numrrsets);
+ if(!ns || !dname_strict_subdomain_c(ns->rk.dname, iq->dp->name)
+ || !dname_subdomain_c(iq->qchase.qname, ns->rk.dname)){
+ verbose(VERB_ALGO, "bad referral, throwaway");
+ type = RESPONSE_TYPE_THROWAWAY;
+ }
+ }
/* handle each of the type cases */
if(type == RESPONSE_TYPE_ANSWER) {
/* Cache the LAMEness. */
verbose(VERB_DETAIL, "query response was %sLAME",
dnsseclame?"DNSSEC ":"");
- if(qstate->reply) {
- /* @@@ DEBUG LAME @@@ */
- if(1) {
- log_info("LAME mark. %s time %d",
- dnsseclame?"dnsseclame":"lame",
- (int)*qstate->env->now);
- log_addr(0, "addr", &qstate->reply->addr,
- qstate->reply->addrlen);
- log_nametypeclass(0, "delegpt", iq->dp->name,
- iq->qchase.qtype, iq->qchase.qclass);
- log_dns_msg("from msg", &iq->response->qinfo,
- iq->response->rep);
- if(qstate->reply && qstate->reply->c &&
- qstate->reply->c->buffer)
- log_hex("hex packet",
- ldns_buffer_begin(qstate->reply->c->
- buffer), ldns_buffer_limit(qstate->
- reply->c->buffer));
- }
+ if(!dname_subdomain_c(iq->qchase.qname, iq->dp->name)) {
+ log_err("mark lame: mismatch in qname and dpname");
+ /* throwaway this reply below */
+ } else if(qstate->reply) {
/* need addr for lameness cache, but we may have
* gotten this from cache, so test to be sure */
if(!infra_set_lame(qstate->env->infra_cache,
/* Cache the LAMEness. */
verbose(VERB_DETAIL, "query response REC_LAME: "
"recursive but not authoritative server");
- if(qstate->reply) {
- /* @@@ DEBUG LAME @@@ */
- if(1) {
- log_info("REC_LAME mark. rec_lame time %d",
- (int)*qstate->env->now);
- log_addr(0, "addr", &qstate->reply->addr,
- qstate->reply->addrlen);
- log_nametypeclass(0, "delegpt", iq->dp->name,
- iq->qchase.qtype, iq->qchase.qclass);
- log_dns_msg("from msg", &iq->response->qinfo,
- iq->response->rep);
- if(qstate->reply && qstate->reply->c &&
- qstate->reply->c->buffer)
- log_hex("hex packet",
- ldns_buffer_begin(qstate->reply->c->
- buffer), ldns_buffer_limit(qstate->
- reply->c->buffer));
- }
+ if(!dname_subdomain_c(iq->qchase.qname, iq->dp->name)) {
+ log_err("mark rec_lame: mismatch in qname and dpname");
+ /* throwaway this reply below */
+ } else if(qstate->reply) {
/* need addr for lameness cache, but we may have
* gotten this from cache, so test to be sure */
verbose(VERB_DETAIL, "mark as REC_LAME");
*rlame = d->rec_lame;
*alame = d->lame_type_A;
*olame = d->lame_other;
- if(*dlame || *rlame || *alame || *olame) {
- /* @@@ DEBUG LAME @@@ */
- log_info("infra_lookup_lame: looked up LAME d%d r%d a%d o%d",
- *dlame, *rlame, *alame, *olame);
- log_nametypeclass(0, "search", name, 0, 0);
- log_nametypeclass(0, "found",
- ((struct infra_lame_key*)e->key)->zonename, 0, 0);
- }
-
lock_rw_unlock(&e->lock);
return *dlame || *rlame || *alame || *olame;
}
int dlame, rlame, alame, olame;
if(infra_lookup_lame(data, name, namelen, timenow,
&dlame, &rlame, &alame, &olame)) {
- /* @@@ DEBUG LAME ***/
- log_info("lookup_lame merge in set_lame");
/* merge data into new structure */
if(dlame) d->isdnsseclame = 1;
if(rlame) d->rec_lame = 1;
/* check lameness first, if so, ttl on host does not matter anymore */
if(infra_lookup_lame(host, name, namelen, timenow,
&dlm, &rlm, &alm, &olm)) {
- /* @@@ DEBUG LAME @@@ */
- log_info("lookup_lame in get_lame_rtt type %d", qtype);
- log_addr(0, "for addr", addr, addrlen);
- log_addr(0, "found addr",
- &((struct infra_host_key*)e->key)->addr,
- ((struct infra_host_key*)e->key)->addrlen);
-
if(alm && qtype == LDNS_RR_TYPE_A) {
lock_rw_unlock(&e->lock);
*lame = 1;