]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup validator classification of root referrals.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 8 Feb 2008 12:24:01 +0000 (12:24 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 8 Feb 2008 12:24:01 +0000 (12:24 +0000)
git-svn-id: file:///svn/unbound/trunk@936 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
validator/val_utils.c
validator/val_utils.h
validator/validator.c

index ff85eb9a95d6173adf2a9b8aafe283ca1f91fdf5..e978906b8559a970aa5b7ec83f2a12391a5cbb6b 100644 (file)
@@ -2,6 +2,8 @@
        - test program for multiple queries over a TCP channel.
        - tpkg test for stream tcp queries.
        - unbound replies to multiple TCP queries on a TCP channel.
+       - fixup misclassification of root referral with NS in answer
+         when validating a nonrec query.
 
 7 February 2008: Wouter
        - moved up all current level 2 to be level 3. And 3 to 4.
index 79cd5f4be2ff58156e69dcad498ea09e2ad7b3d5..f95e8014a6c0e4e43b22dcf652b13c7d9c08556c 100644 (file)
@@ -53,8 +53,8 @@
 #include "util/regional.h"
 
 enum val_classification 
-val_classify_response(uint16_t query_flags, struct query_info* qinf, 
-       struct reply_info* rep, size_t skip)
+val_classify_response(uint16_t query_flags, struct query_info* origqinf,
+       struct query_info* qinf, struct reply_info* rep, size_t skip)
 {
        int rcode = (int)FLAGS_GET_RCODE(rep->flags);
        size_t i;
@@ -82,7 +82,14 @@ val_classify_response(uint16_t query_flags, struct query_info* qinf,
                }
                return saw_ns?VAL_CLASS_REFERRAL:VAL_CLASS_NODATA;
        }
-       
+       /* root referral where NS set is in the answer section */
+       if(!(query_flags&BIT_RD) && rep->ns_numrrsets == 0 &&
+               rep->an_numrrsets == 1 && rcode == LDNS_RCODE_NOERROR &&
+               ntohs(rep->rrsets[0]->rk.type) == LDNS_RR_TYPE_NS &&
+               query_dname_compare(rep->rrsets[0]->rk.dname, 
+                       origqinf->qname) != 0)
+               return VAL_CLASS_REFERRAL;
+
        /* dump bad messages */
        if(rcode != LDNS_RCODE_NOERROR)
                return VAL_CLASS_UNKNOWN;
index 415e8fbfd9903fe435065725f73d50c871559cbc..db1a77a67f537450349f36a0a0d54161ab1bc131 100644 (file)
@@ -80,6 +80,7 @@ enum val_classification {
 /**
  * Given a response, classify ANSWER responses into a subtype.
  * @param query_flags: query flags for the original query.
+ * @param origqinf: query info. The original query name.
  * @param qinf: query info. The chased query name.
  * @param rep: response. The original response.
  * @param skip: offset into the original response answer section.
@@ -88,7 +89,8 @@ enum val_classification {
  *     Then, another CNAME type, CNAME_NOANSWER or POSITIVE are possible.
  */
 enum val_classification val_classify_response(uint16_t query_flags,
-       struct query_info* qinf, struct reply_info* rep, size_t skip);
+       struct query_info* origqinf, struct query_info* qinf, 
+       struct reply_info* rep, size_t skip);
 
 /**
  * Given a response, determine the name of the "signer". This is primarily
index 2f2e0115a28955e7f5498528c3e0252704dfecf1..2e719f5629912fc0743fd492ee8afe43deecfe8a 100644 (file)
@@ -1090,8 +1090,8 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq,
        uint8_t* lookup_name;
        size_t lookup_len;
        enum val_classification subtype = val_classify_response(
-               qstate->query_flags, &vq->qchase, vq->orig_msg->rep
-               vq->rrset_skip);
+               qstate->query_flags, &qstate->qinfo, &vq->qchase
+               vq->orig_msg->rep, vq->rrset_skip);
        verbose(VERB_ALGO, "validator classification %s", 
                val_classification_to_string(subtype));
        if(subtype == VAL_CLASS_REFERRAL && 
@@ -1388,8 +1388,8 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq,
                return 1;
        }
 
-       subtype = val_classify_response(qstate->query_flags, &vq->qchase, 
-               vq->orig_msg->rep, vq->rrset_skip);
+       subtype = val_classify_response(qstate->query_flags, &qstate->qinfo,
+               &vq->qchase, vq->orig_msg->rep, vq->rrset_skip);
        switch(subtype) {
                case VAL_CLASS_POSITIVE:
                        verbose(VERB_ALGO, "Validating a positive response");
@@ -1478,8 +1478,8 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq,
        struct val_env* ve, int id)
 {
        enum val_classification subtype = val_classify_response(
-               qstate->query_flags, &vq->qchase, vq->orig_msg->rep
-               vq->rrset_skip);
+               qstate->query_flags, &qstate->qinfo, &vq->qchase
+               vq->orig_msg->rep, vq->rrset_skip);
 
        /* store overall validation result in orig_msg */
        if(vq->rrset_skip == 0)
@@ -1787,7 +1787,7 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq,
                goto return_bogus;
        }
 
-       subtype = val_classify_response(BIT_RD, qinfo, msg->rep, 0);
+       subtype = val_classify_response(BIT_RD, qinfo, qinfo, msg->rep, 0);
        if(subtype == VAL_CLASS_POSITIVE) {
                struct ub_packed_rrset_key* ds;
                enum sec_status sec;