(msg->rep->ns_numrrsets + msg->rep->ar_numrrsets) *
sizeof(struct ub_packed_rrset_key*));
- /* if the rcode was NXDOMAIN, and we prepended DNAME/CNAMEs, then
- * it should now be NOERROR. */
- if(FLAGS_GET_RCODE(msg->rep->flags) == LDNS_RCODE_NXDOMAIN) {
- FLAGS_SET_RCODE(msg->rep->flags, LDNS_RCODE_NOERROR);
- }
+ /* NXDOMAIN rcode can stay if we prepended DNAME/CNAMEs, because
+ * this is what recursors should give. */
msg->rep->rrset_count += num_an + num_ns;
msg->rep->an_numrrsets += num_an;
msg->rep->ns_numrrsets += num_ns;
return VAL_CLASS_REFERRAL;
/* dump bad messages */
- if(rcode != LDNS_RCODE_NOERROR)
+ if(rcode != LDNS_RCODE_NOERROR && rcode != LDNS_RCODE_NXDOMAIN)
return VAL_CLASS_UNKNOWN;
- log_assert(rcode == LDNS_RCODE_NOERROR);
/* next check if the skip into the answer section shows no answer */
if(skip>0 && rep->an_numrrsets <= skip)
return VAL_CLASS_CNAMENOANSWER;
/* Next is NODATA */
- if(rep->an_numrrsets == 0)
+ if(rcode == LDNS_RCODE_NOERROR && rep->an_numrrsets == 0)
return VAL_CLASS_NODATA;
/* We distinguish between CNAME response and other positive/negative
/* We distinguish between ANY and CNAME or POSITIVE because
* ANY responses are validated differently. */
- if(qinf->qtype == LDNS_RR_TYPE_ANY)
+ if(rcode == LDNS_RCODE_NOERROR && qinf->qtype == LDNS_RR_TYPE_ANY)
return VAL_CLASS_ANY;
/* Note that DNAMEs will be ignored here, unless qtype=DNAME. Unless
* qtype=CNAME, this will yield a CNAME response. */
for(i=skip; i<rep->an_numrrsets; i++) {
- if(ntohs(rep->rrsets[i]->rk.type) == qinf->qtype)
+ if(rcode == LDNS_RCODE_NOERROR &&
+ ntohs(rep->rrsets[i]->rk.type) == qinf->qtype)
return VAL_CLASS_POSITIVE;
if(ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_CNAME)
return VAL_CLASS_CNAME;