]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- bug#327: Fix for cannot access stub zones until the root is primed.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Sep 2010 09:25:52 +0000 (09:25 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Sep 2010 09:25:52 +0000 (09:25 +0000)
git-svn-id: file:///svn/unbound/trunk@2228 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iter_hints.c
iterator/iterator.c
testdata/iter_stub_noroot.rpl [new file with mode: 0644]
testdata/val_stub_noroot.rpl [new file with mode: 0644]

index 0182bc75cb296785d9ba2038061e64265c9801ab..3acdac06ba91f21bed166b7366a77a67874ef2d9 100644 (file)
@@ -1,3 +1,6 @@
+13 September 2010: Wouter
+       - bug#327: Fix for cannot access stub zones until the root is primed.
+
 9 September 2010: Wouter
        - unresponsive servers are not completely blacklisted (because of
          firewalls), but also not probed all the time (because of the request
index ee2cb3118bf4de9333d40e77b8a2cc117f344402..9dde89c70d412f5d2b7b80eecba9e8330537fda1 100644 (file)
@@ -451,6 +451,13 @@ hints_lookup_stub(struct iter_hints* hints, uint8_t* qname,
                len, labs, qclass);
        if(!r) return NULL;
 
+       /* If there is no cache (root prime situation) */
+       if(cache_dp == NULL) {
+               if(r->dp->namelabs != 1)
+                       return r; /* no cache dp, use any non-root stub */
+               return NULL;
+       }
+
        /*
         * If the stub is same as the delegation we got
         * And has noprime set, we need to 'prime' to use this stub instead.
index d52cfea05a306886e6d5ea239fca454c6dae3be1..3edae50b1b0fa483d3bfb103ff199c52fda628c1 100644 (file)
@@ -594,6 +594,8 @@ prime_root(struct module_qstate* qstate, struct iter_qstate* iq,
  * @param q: request name.
  * @return true if a priming subrequest was made, false if not. The will only
  *         issue a priming request if it detects an unprimed stub.
+ *         Uses value of 2 to signal during stub-prime in root-prime situation
+ *         that a noprime-stub is available and resolution can continue.
  */
 static int
 prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, 
@@ -619,6 +621,8 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq,
 
        /* is it a noprime stub (always use) */
        if(stub->noprime) {
+               int r = 0;
+               if(iq->dp == NULL) r = 2;
                /* copy the dp out of the fixed hints structure, so that
                 * it can be changed when servicing this query */
                iq->dp = delegpt_copy(stub_dp, qstate->region);
@@ -629,7 +633,7 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq,
                }
                log_nametypeclass(VERB_DETAIL, "use stub", stub_dp->name, 
                        LDNS_RR_TYPE_NS, q->qclass);
-               return 0;
+               return r;
        }
 
        /* Otherwise, we need to (re)prime the stub. */
@@ -1031,6 +1035,12 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq,
                /* If the cache has returned nothing, then we have a 
                 * root priming situation. */
                if(iq->dp == NULL) {
+                       /* if there is a stub, then no root prime needed */
+                       int r = prime_stub(qstate, iq, ie, id, &iq->qchase);
+                       if(r == 2)
+                               break; /* got noprime-stub-zone, continue */
+                       else if(r)
+                               return 0; /* stub prime request made */
                        if(forwards_lookup_root(qstate->env->fwds, 
                                iq->qchase.qclass)) {
                                /* forward zone root, no root prime needed */
diff --git a/testdata/iter_stub_noroot.rpl b/testdata/iter_stub_noroot.rpl
new file mode 100644 (file)
index 0000000..0bc1ff5
--- /dev/null
@@ -0,0 +1,64 @@
+; config options
+server:
+       target-fetch-policy: "0 0 0 0 0"
+
+stub-zone:
+       name: "."
+       stub-addr: 81.187.81.187
+stub-zone:
+        name: "lp0.eu"
+       stub-addr: 81.2.80.65
+       stub-prime: no
+CONFIG_END
+
+SCENARIO_BEGIN Test resolve of stub zone without root prime.
+
+; this server does not respond. (for the root)
+RANGE_BEGIN 0 100
+       ADDRESS 81.187.81.187
+ENTRY_BEGIN
+MATCH
+ADJUST copy_id copy_query
+REPLY QR SERVFAIL
+SECTION QUESTION
+. IN NS
+ENTRY_END
+RANGE_END
+
+; lp0.eu server
+RANGE_BEGIN 0 100
+       ADDRESS 81.2.80.65
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR NOERROR
+SECTION QUESTION
+proxima.lp0.eu. IN A
+SECTION ANSWER
+proxima.lp0.eu. IN A 81.2.80.65
+SECTION AUTHORITY
+lp0.eu. IN NS proxima.lp0.eu.
+ENTRY_END
+RANGE_END
+
+STEP 1 QUERY
+ENTRY_BEGIN
+REPLY RD
+SECTION QUESTION
+proxima.lp0.eu. IN A
+ENTRY_END
+
+; recursion happens here.
+STEP 10 CHECK_ANSWER
+ENTRY_BEGIN
+MATCH all
+REPLY QR RD RA NOERROR
+SECTION QUESTION
+proxima.lp0.eu. IN A
+SECTION ANSWER
+proxima.lp0.eu. IN A 81.2.80.65
+SECTION AUTHORITY
+lp0.eu. IN NS proxima.lp0.eu.
+ENTRY_END
+
+SCENARIO_END
diff --git a/testdata/val_stub_noroot.rpl b/testdata/val_stub_noroot.rpl
new file mode 100644 (file)
index 0000000..cfa133b
--- /dev/null
@@ -0,0 +1,83 @@
+; config options
+server:
+       target-fetch-policy: "0 0 0 0 0"
+       trust-anchor: "lp0.eu. IN DNSKEY 257 3 5 AQPQ41chR9DEHt/aIzIFAqanbDlRflJoRs5yz1jFsoRIT7dWf0r+PeDuewdxkszNH6wnU4QL8pfKFRh5PIYVBLK3"
+       val-override-date: "20100913111500"
+       ; the dlv anchor is completely ignored, but here to test that.
+       dlv-anchor: "dlv.isc.org. IN DNSKEY 257 3 5 AQPQ41chR9DEHt/aIzIFAqanbDlRflJoRs5yz1jFsoRIT7dWf0r+PeDuewdxkszNH6wnU4QL8pfKFRh5PIYVBLK3"
+
+stub-zone:
+       name: "."
+       stub-addr: 81.187.81.187
+stub-zone:
+        name: "lp0.eu"
+       stub-addr: 81.2.80.65
+       stub-prime: no
+CONFIG_END
+
+SCENARIO_BEGIN Test validation of stub zone without root prime.
+
+; this server does not respond. (for the root)
+RANGE_BEGIN 0 100
+       ADDRESS 81.187.81.187
+ENTRY_BEGIN
+MATCH
+ADJUST copy_id copy_query
+REPLY QR SERVFAIL
+SECTION QUESTION
+. IN NS
+ENTRY_END
+RANGE_END
+
+; lp0.eu server
+RANGE_BEGIN 0 100
+       ADDRESS 81.2.80.65
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR NOERROR
+SECTION QUESTION
+lp0.eu. IN DNSKEY
+SECTION ANSWER
+lp0.eu.        3600    IN      DNSKEY  257 3 5 AQPQ41chR9DEHt/aIzIFAqanbDlRflJoRs5yz1jFsoRIT7dWf0r+PeDuewdxkszNH6wnU4QL8pfKFRh5PIYVBLK3 ;{id = 30900 (ksk), size = 512b}
+lp0.eu.        3600    IN      RRSIG   DNSKEY 5 2 3600 20101013111500 20100909111500 30900 lp0.eu. zWYOT1zmB2k7hMl7mke7k1UNp4lDveUxi2EnF0tW++j2/qJopiAAcFHBo2GOo88jHcLWycurf0Qo+YGXfFbpEg== ;{id = 30900}
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR NOERROR
+SECTION QUESTION
+proxima.lp0.eu. IN A
+SECTION ANSWER
+proxima.lp0.eu. IN A 81.2.80.65
+proxima.lp0.eu.        3600    IN      RRSIG   A 5 3 3600 20101013111500 20100909111500 30900 lp0.eu. xwS3PLSlxh500pDYh/t6fnLzxQAra6n3nhzk4fVqLzwmneBIfcx4F/vO44wRzXSprz1UbMkVUcruTbQYlLFBEg== ;{id = 30900}
+SECTION AUTHORITY
+lp0.eu. IN NS proxima.lp0.eu.
+lp0.eu.        3600    IN      RRSIG   NS 5 2 3600 20101013111500 20100909111500 30900 lp0.eu. KM7Zfwc1b0Ay8Ezer0ZAERPbmgGzKIrTfZMxzXzSkVx5DWirTtdgPTNVG/y9fkN4tUARNhElN2eb0ufb04Hdgw== ;{id = 30900}
+ENTRY_END
+RANGE_END
+
+STEP 1 QUERY
+ENTRY_BEGIN
+REPLY RD DO
+SECTION QUESTION
+proxima.lp0.eu. IN A
+ENTRY_END
+
+; recursion happens here.
+STEP 10 CHECK_ANSWER
+ENTRY_BEGIN
+MATCH all
+REPLY QR RD RA AD NOERROR
+SECTION QUESTION
+proxima.lp0.eu. IN A
+SECTION ANSWER
+proxima.lp0.eu. IN A 81.2.80.65
+proxima.lp0.eu.        3600    IN      RRSIG   A 5 3 3600 20101013111500 20100909111500 30900 lp0.eu. xwS3PLSlxh500pDYh/t6fnLzxQAra6n3nhzk4fVqLzwmneBIfcx4F/vO44wRzXSprz1UbMkVUcruTbQYlLFBEg== ;{id = 30900}
+SECTION AUTHORITY
+lp0.eu. IN NS proxima.lp0.eu.
+lp0.eu.        3600    IN      RRSIG   NS 5 2 3600 20101013111500 20100909111500 30900 lp0.eu. KM7Zfwc1b0Ay8Ezer0ZAERPbmgGzKIrTfZMxzXzSkVx5DWirTtdgPTNVG/y9fkN4tUARNhElN2eb0ufb04Hdgw== ;{id = 30900}
+ENTRY_END
+
+SCENARIO_END