]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix that a local-zone with a local-zone-type that is transparent
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 30 Aug 2018 09:06:07 +0000 (09:06 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 30 Aug 2018 09:06:07 +0000 (09:06 +0000)
  in a view with view-first, makes queries check for answers from the
  local-zones defined outside of views.

git-svn-id: file:///svn/unbound/trunk@4879 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/localzone.c

index d78642d4b7fc6aa5b4e1ebb2106f4dc1664941ca..207f391b6ec18d0229b92c90cf269d6cbfdb8abf 100644 (file)
@@ -1,3 +1,8 @@
+30 August 2018: Wouter
+       - Fix that a local-zone with a local-zone-type that is transparent
+         in a view with view-first, makes queries check for answers from the
+         local-zones defined outside of views.
+
 28 August 2018: Ralph
        - Disable minimal-responses in ipsecmod unit tests.
        - Added serve-expired-ttl and serve-expired-ttl-reset options.
index e4c574f079b23c412223160d5f966efd00edd728..cf99126b333c1507e10ef926aba539be49969af7 100644 (file)
@@ -1382,6 +1382,35 @@ local_data_answer(struct local_zone* z, struct module_env* env,
                LDNS_RCODE_NOERROR);
 }
 
+/**
+ * See if the local zone does not cover the name, eg. the name is not
+ * in the zone and the zone is transparent */
+static int
+local_zone_does_not_cover(struct local_zone* z, struct query_info* qinfo,
+       int labs)
+{
+       struct local_data key;
+       struct local_data* ld = NULL;
+       struct local_rrset* lr = NULL;
+       if(z->type == local_zone_always_transparent)
+               return 1;
+       if(z->type != local_zone_transparent
+               && z->type != local_zone_typetransparent
+               && z->type != local_zone_inform)
+               return 0;
+       key.node.key = &key;
+       key.name = qinfo->qname;
+       key.namelen = qinfo->qname_len;
+       key.namelabs = labs;
+       ld = (struct local_data*)rbtree_search(&z->data, &key.node);
+       if(z->type == local_zone_transparent || z->type == local_zone_inform)
+               return (ld == NULL);
+       if(ld)
+               lr = local_data_find_type(ld, qinfo->qtype, 1);
+       /* local_zone_typetransparent */
+       return (lr == NULL);
+}
+
 /** 
  * Answer in case where no exact match is found.
  * @param z: zone for query.
@@ -1546,10 +1575,6 @@ local_zones_answer(struct local_zones* zones, struct module_env* env,
                        (z = local_zones_lookup(view->local_zones,
                        qinfo->qname, qinfo->qname_len, labs,
                        qinfo->qclass, qinfo->qtype))) {
-                       if(z->type != local_zone_noview)
-                               verbose(VERB_ALGO, 
-                                       "using localzone from view: %s", 
-                                       view->name);
                        lock_rw_rdlock(&z->lock);
                        lzt = z->type;
                }
@@ -1557,10 +1582,24 @@ local_zones_answer(struct local_zones* zones, struct module_env* env,
                        lock_rw_unlock(&z->lock);
                        z = NULL;
                }
+               if(z && (lzt == local_zone_transparent ||
+                       lzt == local_zone_typetransparent ||
+                       lzt == local_zone_inform ||
+                       lzt == local_zone_always_transparent) &&
+                       local_zone_does_not_cover(z, qinfo, labs)) {
+                       lock_rw_unlock(&z->lock);
+                       z = NULL;
+               }
                if(view->local_zones && !z && !view->isfirst){
                        lock_rw_unlock(&view->lock);
                        return 0;
                }
+               if(z && verbosity >= VERB_ALGO) {
+                       char zname[255+1];
+                       dname_str(z->name, zname);
+                       verbose(VERB_ALGO, "using localzone %s %s from view %s", 
+                               zname, local_zone_type2str(lzt), view->name);
+               }
                lock_rw_unlock(&view->lock);
        }
        if(!z) {
@@ -1573,10 +1612,15 @@ local_zones_answer(struct local_zones* zones, struct module_env* env,
                        return 0;
                }
                lock_rw_rdlock(&z->lock);
-
                lzt = lz_type(taglist, taglen, z->taglist, z->taglen,
                        tagactions, tagactionssize, z->type, repinfo,
                        z->override_tree, &tag, tagname, num_tags);
+               if(z && verbosity >= VERB_ALGO) {
+                       char zname[255+1];
+                       dname_str(z->name, zname);
+                       verbose(VERB_ALGO, "using localzone %s %s", zname,
+                               local_zone_type2str(lzt));
+               }
                lock_rw_unlock(&zones->lock);
        }
        if((env->cfg->log_local_actions ||