]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
and the error looks good.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 17 Aug 2018 14:17:48 +0000 (14:17 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 17 Aug 2018 14:17:48 +0000 (14:17 +0000)
git-svn-id: file:///svn/unbound/trunk@4860 be551aaa-1e26-0410-a405-d3ace91eadb9

iterator/iterator.c
services/mesh.c
util/config_file.c
util/config_file.h
validator/val_kcache.c
validator/validator.c

index db7cdf539abbefb75a85bda9921cd54189140c78..52cfe7af67ec9b46ff89aaaea752a9f3381f3604 100644 (file)
@@ -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. */
index 38f9d99f8be538717c3b686d5216c7c21d9a5f52..536293a2f767a6308a32d56790173b26e8662991 100644 (file)
@@ -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
index a2efbd87dd9c8bed8fe30fffc11c74f54b8c84fa..03296c87879291c65b747a1c3171628703d2d15d 100644 (file)
@@ -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];
index 0f188e6243c432a4c06c46cbfa5fdae55d2f3a84..64794705b3b0fd497b146c3aa76b9bc5b08fadf1 100644 (file)
@@ -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
index 22070cc6a90ef181b1fde5c3d39018ec615b3706..e0b88b6df81dcc333e1014600a8c6497e2294072 100644 (file)
@@ -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, 
index 7b1ebc7b7aa491bd3a88c11f47f084b22eb4fded..2f13dc005ced73aae9edda49b7d050eee9990bac 100644 (file)
@@ -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);
                        }