]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fix bug
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 13 Jan 2009 10:44:04 +0000 (10:44 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 13 Jan 2009 10:44:04 +0000 (10:44 +0000)
git-svn-id: file:///svn/unbound/trunk@1426 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iterator.c
services/cache/infra.c

index bda323cd1c37fd624fa832d55104b4412e302d39..2ab77d5fbb574926fcc4eaf7aaa2d58882de69ab 100644 (file)
@@ -1,3 +1,6 @@
+13 January 2009: Wouter
+       - fixed bug in lameness marking, removed printouts.
+
 12 January 2009: Wouter
        - fixed bug in infrastructure lameness cache, did not lowercase
          name of zone to hash when setting lame.
index ec7d6cb29dd3897d581e4f5984aacb4d977d9eed..522bed7cc24b3372a5ca663750c272414940ac3b 100644 (file)
@@ -840,6 +840,8 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq,
                        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);
                }
@@ -857,6 +859,7 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq,
                        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. */
@@ -1351,6 +1354,19 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
        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
@@ -1402,6 +1418,18 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
                        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) {
@@ -1529,25 +1557,10 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
                /* 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, 
@@ -1562,24 +1575,10 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
                /* 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");
index eeaaa79287878db7ba7c7a7ba7dbfdc95ac4ece4..f6ecb40a4dd648377760fa9d3673f9517ed00ccc 100644 (file)
@@ -300,15 +300,6 @@ infra_lookup_lame(struct infra_host_data* host,
        *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;
 }
@@ -428,8 +419,6 @@ infra_set_lame(struct infra_cache* infra,
                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;
@@ -537,13 +526,6 @@ infra_get_lame_rtt(struct infra_cache* infra,
        /* 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;