debug work.

git-svn-id: file:///svn/unbound/trunk@371 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-06-05 15:04:01 +00:00
parent 523c1bdb06
commit aaec3572e4
11 changed files with 90 additions and 17 deletions

View 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;

View 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.

View 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))

View 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

View 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,

View 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 */

View 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);

View 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);
}

View 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.

View 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)

View 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