]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
use closer of stub and forward if both configured.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2018 13:00:06 +0000 (13:00 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2018 13:00:06 +0000 (13:00 +0000)
git-svn-id: file:///svn/unbound/trunk@4849 be551aaa-1e26-0410-a405-d3ace91eadb9

iterator/iterator.c

index 34c33e055e013a09e831497f27555706e9f4d09c..7a55980a9083650dee826a4def57a2dd56589bcf 100644 (file)
@@ -1135,6 +1135,19 @@ iter_stub_fwd_no_cache(struct module_qstate *qstate, struct iter_qstate *iq)
        /* Check for stub. */
        stub = hints_lookup_stub(qstate->env->hints, iq->qchase.qname,
            iq->qchase.qclass, iq->dp);
+       dp = forwards_lookup(qstate->env->fwds, iq->qchase.qname, iq->qchase.qclass);
+
+       /* see if forward or stub is more pertinent */
+       if(stub && stub->dp && dp) {
+               if(dname_strict_subdomain(dp->name, dp->namelabs,
+                       stub->dp->name, stub->dp->namelabs)) {
+                       stub = NULL; /* ignore stub, forward is lower */
+               } else {
+                       dp = NULL; /* ignore forward, stub is lower */
+               }
+       }
+
+       /* check stub */
        if (stub != NULL && stub->dp != NULL) {
                if(stub->dp->no_cache) {
                        char qname[255+1];
@@ -1147,7 +1160,6 @@ iter_stub_fwd_no_cache(struct module_qstate *qstate, struct iter_qstate *iq)
        }
 
        /* Check for forward. */
-       dp = forwards_lookup(qstate->env->fwds, iq->qchase.qname, iq->qchase.qclass);
        if (dp) {
                if(dp->no_cache) {
                        char qname[255+1];
@@ -1158,12 +1170,7 @@ iter_stub_fwd_no_cache(struct module_qstate *qstate, struct iter_qstate *iq)
                }
                return (dp->no_cache);
        }
-
-#if 0
-       verbose(VERB_ALGO, "%s: no stub or fwd for '%s' found no_cache 0",
-           __func__, iq->qchase.qname);
-#endif
-       return (0);
+       return 0;
 }
 
 /**