]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
debug work.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 5 Jun 2007 15:04:01 +0000 (15:04 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 5 Jun 2007 15:04:01 +0000 (15:04 +0000)
git-svn-id: file:///svn/unbound/trunk@371 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/worker.c
doc/Changelog
iterator/iter_delegpt.c
iterator/iter_resptype.c
iterator/iter_scrub.c
iterator/iter_utils.c
iterator/iterator.c
testcode/unitdname.c
util/alloc.c
util/data/packed_rrset.c
util/net_help.c

index d9e74f80507d8a48bb598513ae365dd9da5f3164..e1abbe5192e1da53744a6c24c62cd5ffb3a8513b 100644 (file)
@@ -215,9 +215,12 @@ static struct module_qstate*
 find_run_in(struct module_qstate* p)
 {
        struct module_qstate* q;
+       log_nametypeclass("find run in", p->qinfo.qname, p->qinfo.qtype, p->qinfo.qclass);
        for(p = p->subquery_first; p; p = p->subquery_next) {
+               log_nametypeclass("find run passed", p->qinfo.qname, p->qinfo.qtype, p->qinfo.qclass);
                if(p->ext_state[p->curmod] == module_state_initial)
                        return p;
+               log_nametypeclass("find run morepass", p->qinfo.qname, p->qinfo.qtype, p->qinfo.qclass);
                if((q=find_run_in(p)))
                        return q;
        }
@@ -229,6 +232,7 @@ static struct module_qstate*
 find_runnable(struct module_qstate* subq)
 {
        struct module_qstate* p = subq;
+       log_info("find runnable");
        if(p->subquery_next && p->subquery_next->ext_state[
                p->subquery_next->curmod] == module_state_initial)
                return p->subquery_next;
@@ -256,6 +260,8 @@ worker_process_query(struct worker* worker, struct work_query* w,
                region_free_all(worker->scratchpad);
                qstate->reply = NULL;
                s = qstate->ext_state[qstate->curmod];
+               log_info("worker_process_query: module exit state is %s",
+                       strextstate(s));
                /* examine results, start further modules, etc. */
                if(s == module_wait_subquery) {
                        if(!qstate->subquery_first) {
@@ -295,6 +301,7 @@ worker_process_query(struct worker* worker, struct work_query* w,
                                qstate = nxt;
                                entry = NULL;
                                event = module_event_pass;
+                               continue;
                        }
                }
                break;
index ab1f4f7b8c51baa3bf6c1172ee9aa103163fb1de..191367c7a0706d838c52edc1cf5eee7830ca31d3 100644 (file)
@@ -7,6 +7,10 @@
        - priming gives LAME result, returns SERVFAIL.
        - debug routine to print dns_msg as handled by iterator.
        - memleak in config file stubs fixup.
+       - more small bugs, in scrubber, query compare no ID for lookup,
+         in dname validation for NS targets.
+       - sets entry.key for new special allocs.
+       - lognametypeclass can display unknown types and classes.
 
 4 June 2007: Wouter
        - random selection of equally preferred nameserver targets.
index d06293fe26e0f6d0ac176c7e2159edb3b16653d8..db907946eb5d3a23337f8c34ac4afaaaa4296aa8 100644 (file)
@@ -262,7 +262,7 @@ delegpt_rrset_add_ns(struct delegpt* dp, struct region* region,
        for(i=0; i<nsdata->count; i++) {
                if(nsdata->rr_len[i] < 2+1) continue; /* len + root label */
                if(dname_valid(nsdata->rr_data[i]+2, nsdata->rr_len[i]-2) !=
-                       (size_t)ldns_read_uint16(nsdata->rr_data[i])-2)
+                       (size_t)ldns_read_uint16(nsdata->rr_data[i]))
                        continue; /* bad format */
                /* add rdata of NS (= wirefmt dname), skip rdatalen bytes */
                if(!delegpt_add_ns(dp, region, nsdata->rr_data[i]+2))
index a61fa0a92fe848a11ce503e0fceaf629be3eb660..fc2d7031b48e4cb6f835f8ebfd9e2c17790cfadf 100644 (file)
@@ -190,7 +190,7 @@ response_type_from_server(struct dns_msg* msg, struct query_info* request,
                        /* If we are getting an NS set for the zone we 
                         * thought we were contacting, then it is an answer.*/
                        /* FIXME: is this correct? */
-                       if(query_dname_compare(s->rk.dname, origzone)) {
+                       if(query_dname_compare(s->rk.dname, origzone) == 0) {
                                return RESPONSE_TYPE_ANSWER;
                        }
                        /* If we are getting a referral upwards (or to 
index bedce57f0ae909e419d161d0dce8619e9c7c6e62..3ae248f78267afd09c00832362ffa0e03a739c23 100644 (file)
@@ -277,20 +277,21 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias,
 static int
 pkt_strict_sub(ldns_buffer* pkt, uint8_t* sname, uint8_t* dr)
 {
-       uint8_t buf[LDNS_MAX_DOMAINLEN+1];
-       /* decompress DNAME name */
-       dname_pkt_copy(pkt, buf, dr);
-       return dname_strict_subdomain_c(sname, buf);
+       uint8_t buf1[LDNS_MAX_DOMAINLEN+1];
+       uint8_t buf2[LDNS_MAX_DOMAINLEN+1];
+       /* decompress names */
+       dname_pkt_copy(pkt, buf1, sname);
+       dname_pkt_copy(pkt, buf2, dr);
+       return dname_strict_subdomain_c(buf1, buf2);
 }
 
 /** check subdomain with decompression */
 static int
-pkt_sub(ldns_buffer* pkt, uint8_t* sname, uint8_t* dr)
+pkt_sub(ldns_buffer* pkt, uint8_t* comprname, uint8_t* zone)
 {
        uint8_t buf[LDNS_MAX_DOMAINLEN+1];
-       /* decompress DNAME name */
-       dname_pkt_copy(pkt, buf, dr);
-       return dname_subdomain_c(sname, buf);
+       dname_pkt_copy(pkt, buf, comprname);
+       return dname_subdomain_c(buf, zone);
 }
 
 /**
@@ -452,6 +453,7 @@ scrub_sanitize(ldns_buffer* pkt, struct msg_parse* msg, uint8_t* zonename)
        struct rrset_parse* rrset, *prev;
        prev = NULL;
        rrset = msg->rrset_first;
+       log_nametypeclass("sanitize for", zonename, 0, 0);
 
        /* At this point, we brutally remove ALL rrsets that aren't 
         * children of the originating zone. The idea here is that, 
index 83eaa21860b625e9d6e740be2ced00240981e9e1..94fb6ec9845f06aea308d382f7ac1c7ba20a1cfc 100644 (file)
@@ -247,15 +247,21 @@ iter_dns_store(struct module_env* env, struct dns_msg* msg, int is_referral)
                /* store rrsets */
                struct rrset_ref ref;
                uint32_t now = time(NULL);
-               size_t i;
-               reply_info_set_ttls(rep, now);
+               size_t i, j;
                for(i=0; i<rep->rrset_count; i++) {
+                       /* fixup rrset ttl */
+                       struct packed_rrset_data* data = (struct 
+                               packed_rrset_data*)rep->rrsets[i]->entry.data;
+                       data->ttl += now;
+                       for(j=0; j<data->count + data->rrsig_count; j++)
+                               data->rr_ttl[j] += now;
                        ref.key = rep->rrsets[i];
                        ref.id = rep->rrsets[i]->id;
                        /*ignore ret: it was in the cache, ref updated */
                        (void)rrset_cache_update(env->rrset_cache, &ref, 
                                env->alloc, now);
                }
+               free(rep);
                return 1;
        } else {
                /* store msg, and rrsets */
index e84aed2b44fd9ae50fefa3ede81e8826b0ee1839..da9f8e99ba19647927e4ef4e857d3218955dfc8c 100644 (file)
@@ -870,6 +870,8 @@ generate_target_query(struct module_qstate* qstate, struct iter_qstate* iq,
                free(subq);
                return 0;
        }
+       log_nametypeclass("new target", name, qtype, qclass);
+       delegpt_log(subiq->dp);
        return 1;
 }
 
@@ -1141,6 +1143,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
                iq->dp = delegpt_from_message(iq->response, qstate->region);
                if(!iq->dp)
                        return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
+               delegpt_log(iq->dp);
                iq->num_current_queries = 0;
                iq->num_target_queries = -1;
                /* Count this as a referral. */
@@ -1258,6 +1261,7 @@ processPrimeResponse(struct module_qstate* qstate, struct iter_qstate* iq,
 
        log_nametypeclass("priming successful for", qstate->qinfo.qname,
                qstate->qinfo.qtype, qstate->qinfo.qclass);
+       delegpt_log(dp);
        foriq = (struct iter_qstate*)forq->minfo[id];
        foriq->dp = dp;
        foriq->response = dns_copy_msg(iq->response, forq->region);
index 8789d2b66fd794b581136eb9994659d2145057d1..4473c40a80f4979f8d25f07cbb4ecbd404334eaa 100644 (file)
@@ -361,6 +361,42 @@ dname_test_dname_lab_cmp()
        unit_assert(ml == 4);
 }
 
+/** test dname_subdomain_c */
+static void
+dname_test_subdomain()
+{
+       unit_assert(dname_subdomain_c(
+               (uint8_t*)"",
+               (uint8_t*)""));
+       unit_assert(dname_subdomain_c(
+               (uint8_t*)"\003com",
+               (uint8_t*)""));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"",
+               (uint8_t*)"\003com"));
+       unit_assert(dname_subdomain_c(
+               (uint8_t*)"\007example\003com",
+               (uint8_t*)"\003com"));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"\003com",
+               (uint8_t*)"\007example\003com"));
+       unit_assert(dname_subdomain_c(
+               (uint8_t*)"\007example\003com",
+               (uint8_t*)""));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"\003net",
+               (uint8_t*)"\003com"));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"\003net",
+               (uint8_t*)"\003org"));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"\007example\003net",
+               (uint8_t*)"\003org"));
+       unit_assert(!dname_subdomain_c(
+               (uint8_t*)"\003net",
+               (uint8_t*)"\007example\003org"));
+}
+
 /** test dname_strict_subdomain */
 static void
 dname_test_strict_subdomain()
@@ -409,5 +445,6 @@ void dname_test()
        dname_test_dname_lab_cmp();
        dname_test_pkt_dname_len(buff);
        dname_test_strict_subdomain();
+       dname_test_subdomain();
        ldns_buffer_free(buff);
 }
index 3e25fbde8bf5863e652d0a5a5b8adea7834712dd..cdebd3c5255a25716f22cd7ebd878c64526e6e6a 100644 (file)
@@ -52,6 +52,7 @@ alloc_setup_special(alloc_special_t* t)
 {
        memset(t, 0, sizeof(*t));
        lock_rw_init(&t->entry.lock);
+       t->entry.key = t;
 }
 
 /** prealloc some entries in the cache. To minimize contention. 
index 1f2805764abecc310eb99573f45602403516335b..dc1099b30f330a54e175df013c90dcdedc596420 100644 (file)
@@ -93,7 +93,7 @@ ub_rrset_compare(void* k1, void* k2)
        struct ub_packed_rrset_key* key1 = (struct ub_packed_rrset_key*)k1;
        struct ub_packed_rrset_key* key2 = (struct ub_packed_rrset_key*)k2;
        int c;
-       if(key1 == key2 || key1->id == key2->id)
+       if(key1 == key2)
                return 0;
        if(key1->rk.type != key2->rk.type) {
                if(key1->rk.type < key2->rk.type)
index d0f1790f9545475b5938da5e2e812ff524a5c5e4..10e258a46345cb8fe31f9444298d61302a5cdb51 100644 (file)
@@ -183,11 +183,23 @@ log_nametypeclass(const char* str, uint8_t* name, uint16_t type,
        uint16_t dclass)
 {
        char buf[LDNS_MAX_DOMAINLEN+1];
+       char t[12], c[12];
+       const char *ts, *cs; 
        dname_str(name, buf);
-       log_info("%s <%s %s %s>", str, buf, 
-               ldns_rr_descript(type)?ldns_rr_descript(type)->_name: "??",
-               ldns_lookup_by_id(ldns_rr_classes, (int)dclass)?
-               ldns_lookup_by_id(ldns_rr_classes, (int)dclass)->name:"??");
+       if(ldns_rr_descript(type) && ldns_rr_descript(type)->_name)
+               ts = ldns_rr_descript(type)->_name;
+       else {
+               snprintf(t, 12, "TYPE%d", (int)type);
+               ts = t;
+       }
+       if(ldns_lookup_by_id(ldns_rr_classes, (int)dclass) &&
+               ldns_lookup_by_id(ldns_rr_classes, (int)dclass)->name)
+               cs = ldns_lookup_by_id(ldns_rr_classes, (int)dclass)->name;
+       else {
+               snprintf(c, 12, "CLASS%d", (int)dclass);
+               cs = c;
+       }
+       log_info("%s <%s %s %s>", str, buf, ts, cs);
 }
 
 int