- priming failure returns SERVFAIL.

- priming gives LAME result, returns SERVFAIL.
       - debug routine to print dns_msg as handled by iterator.
       - memleak in config file stubs fixup.


git-svn-id: file:///svn/unbound/trunk@370 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-06-05 12:54:43 +00:00
parent 31b8352bc6
commit 523c1bdb06
9 changed files with 79 additions and 20 deletions

View file

@ -125,6 +125,7 @@ qstate_free(struct worker* worker, struct module_qstate* qstate)
{
if(!qstate)
return;
if(qstate->subquery_first) {
while(qstate->subquery_first) {
/* put subqueries on slumber list */
struct module_qstate* s = qstate->subquery_first;
@ -137,6 +138,7 @@ qstate_free(struct worker* worker, struct module_qstate* qstate)
}
verbose(VERB_ALGO, "worker: slumber list has %d entries",
module_subreq_num(worker->slumber_list));
}
qstate_cleanup(worker, qstate);
}

View file

@ -3,6 +3,10 @@
- subrequests without parent store in cache and stop.
- worker slumber list for ongoing promiscuous queries.
- subrequest error handling.
- priming failure returns SERVFAIL.
- priming gives LAME result, returns SERVFAIL.
- debug routine to print dns_msg as handled by iterator.
- memleak in config file stubs fixup.
4 June 2007: Wouter
- random selection of equally preferred nameserver targets.

View file

@ -23,3 +23,4 @@ o understand NSEC/NSEC3, aggressive negative caching, so that updates to
NSEC/NSEC3 will result in proper negative responses.
o fallback without EDNS if result is NOTIMPL, now only on FORMERR like in java.
o scrubber has slow pkt_subdomain and pkt_strict_subdomain functions.
o get serverselection algorithm out of local optimum.

View file

@ -116,7 +116,7 @@ response_type_from_server(struct dns_msg* msg, struct query_info* request,
/* Other response codes mean (so far) to throw the response away as
* meaningless and move on to the next nameserver. */
if(FLAGS_GET_RCODE(msg->rep->flags) == LDNS_RCODE_NOERROR)
if(FLAGS_GET_RCODE(msg->rep->flags) != LDNS_RCODE_NOERROR)
return RESPONSE_TYPE_THROWAWAY;
/* Note: TC bit has already been handled */

View file

@ -1504,10 +1504,12 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
memset(&edns, 0, sizeof(edns));
pkt = qstate->reply->c->buffer;
ldns_buffer_set_position(pkt, 0);
if(!parse_packet(pkt, prs, qstate->scratch))
if(parse_packet(pkt, prs, qstate->scratch) != LDNS_RCODE_NOERROR) {
verbose(VERB_ALGO, "parse error on reply packet");
goto handle_it;
}
/* edns is not examined, but removed from message to help cache */
if(!parse_extract_edns(prs, &edns))
if(parse_extract_edns(prs, &edns) != LDNS_RCODE_NOERROR)
goto handle_it;
/* normalize and sanitize: easy to delete items from linked lists */
@ -1519,6 +1521,8 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
iq->response = dns_alloc_msg(pkt, prs, qstate->region);
if(!iq->response)
goto handle_it;
log_dns_msg("incoming scrubbed packet", &iq->response->qinfo,
iq->response->rep);
handle_it:
outbound_list_remove(&iq->outlist, outbound);
@ -1544,7 +1548,7 @@ process_subq_error(struct module_qstate* qstate, struct iter_qstate* iq,
}
if(errinf.qtype == LDNS_RR_TYPE_NS) {
/* a priming query has failed. */
iter_handle(qstate, iq, ie, id);
(void)error_response(qstate, id, LDNS_RCODE_SERVFAIL);
return;
}
if(errinf.qtype != LDNS_RR_TYPE_A &&
@ -1576,6 +1580,8 @@ iter_operate(struct module_qstate* qstate, enum module_ev event, int id,
struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id];
verbose(VERB_ALGO, "iterator[module %d] operate: extstate:%s event:%s",
id, strextstate(qstate->ext_state[id]), strmodulevent(event));
if(iq) log_nametypeclass("for qstate", qstate->qinfo.qname,
qstate->qinfo.qtype, qstate->qinfo.qclass);
if(ie->fwd_addrlen != 0) {
perform_forward(qstate, event, id, outbound);
return;
@ -1627,12 +1633,14 @@ iter_clear(struct module_qstate* qstate, int id)
if(!qstate)
return;
iq = (struct iter_qstate*)qstate->minfo[id];
if(iq->orig_qname) {
if(iq && iq->orig_qname) {
/* so the correct qname gets free'd */
qstate->qinfo.qname = iq->orig_qname;
qstate->qinfo.qname_len = iq->orig_qnamelen;
}
if(iq) {
outbound_list_clear(&iq->outlist);
}
qstate->minfo[id] = NULL;
}

View file

@ -989,10 +989,11 @@ static void
serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
struct comm_reply* rep)
{
struct service_callback* p = sq->cblist;
struct service_callback* p = sq->cblist, *n;
while(p) {
n = p->next;
(void)(*p->cb)(c, p->cb_arg, error, rep);
p = p->next;
p = n;
}
}

View file

@ -178,6 +178,7 @@ config_delete(struct config_file* cfg)
free(p->name);
config_delstrlist(p->hosts);
config_delstrlist(p->addrs);
free(p);
p = np;
}
}

View file

@ -49,6 +49,7 @@
#include "util/data/dname.h"
#include "util/region-allocator.h"
#include "util/data/msgparse.h"
#include "util/data/msgencode.h"
/** allocate qinfo, return 0 on error. */
static int
@ -449,7 +450,6 @@ query_info_parse(struct query_info* m, ldns_buffer* query)
/* minimum size: header + \0 + qtype + qclass */
if(ldns_buffer_limit(query) < LDNS_HEADER_SIZE + 5)
return 0;
log_assert(!LDNS_QR_WIRE(q));
log_assert(LDNS_OPCODE_WIRE(q) == LDNS_PACKET_QUERY);
log_assert(LDNS_QDCOUNT(q) == 1);
log_assert(ldns_buffer_position(query) == 0);
@ -651,3 +651,36 @@ reply_find_answer_rrset(struct query_info* qinfo, struct reply_info* rep)
}
return NULL;
}
void
log_dns_msg(const char* str, struct query_info* qinfo, struct reply_info* rep)
{
/* not particularly fast but flexible, make wireformat and print */
ldns_buffer* buf = ldns_buffer_new(65535);
struct region* region = region_create(malloc, free);
if(!reply_info_encode(qinfo, rep, 0, rep->flags, buf, 0,
region, 65535)) {
log_info("%s: log_dns_msg: out of memory", str);
} else {
ldns_status s;
ldns_pkt* pkt = NULL;
s = ldns_buffer2pkt_wire(&pkt, buf);
if(s != LDNS_STATUS_OK) {
log_info("%s: log_dns_msg: ldns parse gave: %s",
str, ldns_get_errorstr_by_id(s));
} else {
ldns_buffer_clear(buf);
s = ldns_pkt2buffer_str(buf, pkt);
if(s != LDNS_STATUS_OK) {
log_info("%s: log_dns_msg: ldns tostr gave: %s",
str, ldns_get_errorstr_by_id(s));
} else {
log_info("%s %s",
str, (char*)ldns_buffer_begin(buf));
}
}
ldns_pkt_free(pkt);
}
ldns_buffer_free(buf);
region_destroy(region);
}

View file

@ -300,4 +300,13 @@ struct reply_info* reply_info_copy(struct reply_info* rep,
struct ub_packed_rrset_key* reply_find_answer_rrset(struct query_info* qinfo,
struct reply_info* rep);
/**
* Debug send the query info and reply info to the log in readable form.
* @param str: descriptive string printed with packet content.
* @param qinfo: query section.
* @param rep: rest of message.
*/
void log_dns_msg(const char* str, struct query_info* qinfo,
struct reply_info* rep);
#endif /* UTIL_DATA_MSGREPLY_H */