mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-10 08:42:53 -05:00
and the error looks good.
git-svn-id: file:///svn/unbound/trunk@4860 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
8385c462ed
commit
b0daf867c2
6 changed files with 47 additions and 21 deletions
|
|
@ -1853,7 +1853,8 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
|
|||
iq->qchase.qclass, NULL)) {
|
||||
/* fail -- no more targets, no more hope of targets, no hope
|
||||
* of a response. */
|
||||
errinf(qstate, "all the configured stub or forward servers failed");
|
||||
errinf(qstate, "all the configured stub or forward servers failed,");
|
||||
errinf_dname(qstate, "at zone", iq->dp->name);
|
||||
verbose(VERB_QUERY, "configured stub or forward servers failed -- returning SERVFAIL");
|
||||
return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL);
|
||||
}
|
||||
|
|
@ -1990,8 +1991,8 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
|
|||
iq->deleg_msg?iq->deleg_msg->rep:
|
||||
(iq->response?iq->response->rep:NULL));
|
||||
|
||||
errinf(qstate, "all servers for this domain failed");
|
||||
errinf_dname(qstate, ", at zonecut", iq->dp->name);
|
||||
errinf(qstate, "all servers for this domain failed,");
|
||||
errinf_dname(qstate, "at zone", iq->dp->name);
|
||||
verbose(VERB_QUERY, "out of query targets -- returning SERVFAIL");
|
||||
/* fail -- no more targets, no more hope of targets, no hope
|
||||
* of a response. */
|
||||
|
|
|
|||
|
|
@ -980,7 +980,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
|
|||
rcode = LDNS_RCODE_SERVFAIL;
|
||||
if(!rcode && (rep->security == sec_status_bogus ||
|
||||
rep->security == sec_status_secure_sentinel_fail)) {
|
||||
if(!(reason = errinf_to_str(&m->s)))
|
||||
if(!(reason = errinf_to_str_bogus(&m->s)))
|
||||
rcode = LDNS_RCODE_SERVFAIL;
|
||||
}
|
||||
/* send the reply */
|
||||
|
|
@ -1157,18 +1157,10 @@ void mesh_query_done(struct mesh_state* mstate)
|
|||
mstate->s.return_msg->rep:NULL);
|
||||
if(mstate->s.return_rcode == LDNS_RCODE_SERVFAIL ||
|
||||
(rep && FLAGS_GET_RCODE(rep->flags) == LDNS_RCODE_SERVFAIL)) {
|
||||
char* err = errinf_to_str(&mstate->s);
|
||||
if(err) {
|
||||
char nm[255+1];
|
||||
char* tp = sldns_wire2str_type(mstate->s.qinfo.qtype);
|
||||
char* cl = sldns_wire2str_class(mstate->s.qinfo.qclass);
|
||||
dname_str(mstate->s.qinfo.qname, nm);
|
||||
log_err("query %s %s %s SERVFAIL with reason: %s",
|
||||
nm, tp?tp:"t", cl?cl:"c", err);
|
||||
free(err);
|
||||
free(tp);
|
||||
free(cl);
|
||||
}
|
||||
char* err = errinf_to_str_servfail(&mstate->s);
|
||||
if(err)
|
||||
log_err("%s", err);
|
||||
free(err);
|
||||
}
|
||||
for(r = mstate->reply_list; r; r = r->next) {
|
||||
/* if a response-ip address block has been stored the
|
||||
|
|
|
|||
|
|
@ -2233,7 +2233,7 @@ void errinf_origin(struct module_qstate* qstate, struct sock_list *origin)
|
|||
}
|
||||
}
|
||||
|
||||
char* errinf_to_str(struct module_qstate* qstate)
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate)
|
||||
{
|
||||
char buf[20480];
|
||||
char* p = buf;
|
||||
|
|
@ -2258,6 +2258,31 @@ char* errinf_to_str(struct module_qstate* qstate)
|
|||
return p;
|
||||
}
|
||||
|
||||
char* errinf_to_str_servfail(struct module_qstate* qstate)
|
||||
{
|
||||
char buf[20480];
|
||||
char* p = buf;
|
||||
size_t left = sizeof(buf);
|
||||
struct config_strlist* s;
|
||||
char dname[LDNS_MAX_DOMAINLEN+1];
|
||||
char t[16], c[16];
|
||||
sldns_wire2str_type_buf(qstate->qinfo.qtype, t, sizeof(t));
|
||||
sldns_wire2str_class_buf(qstate->qinfo.qclass, c, sizeof(c));
|
||||
dname_str(qstate->qinfo.qname, dname);
|
||||
snprintf(p, left, "SERVFAIL <%s %s %s>:", dname, t, c);
|
||||
left -= strlen(p); p += strlen(p);
|
||||
if(!qstate->errinf)
|
||||
snprintf(p, left, " misc failure");
|
||||
else for(s=qstate->errinf; s; s=s->next) {
|
||||
snprintf(p, left, " %s", s->str);
|
||||
left -= strlen(p); p += strlen(p);
|
||||
}
|
||||
p = strdup(buf);
|
||||
if(!p)
|
||||
log_err("malloc failure in errinf_to_str");
|
||||
return p;
|
||||
}
|
||||
|
||||
void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr)
|
||||
{
|
||||
char buf[1024];
|
||||
|
|
|
|||
|
|
@ -1078,12 +1078,20 @@ void errinf_dname(struct module_qstate* qstate, const char* str,
|
|||
uint8_t* dname);
|
||||
|
||||
/**
|
||||
* Create error info in string
|
||||
* Create error info in string. For validation failures.
|
||||
* @param qstate: query state.
|
||||
* @return string or NULL on malloc failure (already logged).
|
||||
* This string is malloced and has to be freed by caller.
|
||||
*/
|
||||
char* errinf_to_str(struct module_qstate* qstate);
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate);
|
||||
|
||||
/**
|
||||
* Create error info in string. For other servfails.
|
||||
* @param qstate: query state.
|
||||
* @return string or NULL on malloc failure (already logged).
|
||||
* This string is malloced and has to be freed by caller.
|
||||
*/
|
||||
char* errinf_to_str_servfail(struct module_qstate* qstate);
|
||||
|
||||
/**
|
||||
* Used during options parsing
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ key_cache_insert(struct key_cache* kcache, struct key_entry_key* kkey,
|
|||
if(key_entry_isbad(k) && qstate->errinf &&
|
||||
qstate->env->cfg->val_log_level >= 2) {
|
||||
/* on malloc failure there is simply no reason string */
|
||||
key_entry_set_reason(k, errinf_to_str(qstate));
|
||||
key_entry_set_reason(k, errinf_to_str_bogus(qstate));
|
||||
}
|
||||
key_entry_hash(k);
|
||||
slabhash_insert(kcache->slab, k->entry.hash, &k->entry,
|
||||
|
|
|
|||
|
|
@ -2241,7 +2241,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq,
|
|||
log_query_info(0, "validation failure",
|
||||
&qstate->qinfo);
|
||||
else {
|
||||
char* err = errinf_to_str(qstate);
|
||||
char* err = errinf_to_str_bogus(qstate);
|
||||
if(err) log_info("%s", err);
|
||||
free(err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue