]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] "in-view" zone option
authorEvan Hunt <each@isc.org>
Thu, 14 Nov 2013 04:35:40 +0000 (20:35 -0800)
committerEvan Hunt <each@isc.org>
Thu, 14 Nov 2013 04:35:40 +0000 (20:35 -0800)
3673. [func] New "in-view" zone option allows direct sharing
of zones between views. [RT #32968]

26 files changed:
CHANGES
bin/named/server.c
bin/tests/system/checkconf/bad-sharedzone1.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-sharedzone2.conf [new file with mode: 0644]
bin/tests/system/checkconf/good.conf
bin/tests/system/views/clean.sh
bin/tests/system/views/ns2/clone.db [new file with mode: 0644]
bin/tests/system/views/ns2/named1.conf
bin/tests/system/views/ns2/named2.conf
bin/tests/system/views/ns3/child.clone.db [new file with mode: 0644]
bin/tests/system/views/ns3/named1.conf
bin/tests/system/views/ns3/named2.conf
bin/tests/system/views/ns4/child.clone.db [new file with mode: 0644]
bin/tests/system/views/ns4/named.conf [new file with mode: 0644]
bin/tests/system/views/tests.sh
doc/arm/Bv9ARM-book.xml
lib/bind9/check.c
lib/dns/zone.c
lib/dns/zt.c
lib/isc/include/isc/symtab.h
lib/isc/symtab.c
lib/isc/win32/libisc.def
lib/isccfg/include/isccfg/cfg.h
lib/isccfg/namedconf.c
lib/isccfg/parser.c
lib/isccfg/win32/libisccfg.def

diff --git a/CHANGES b/CHANGES
index a02ae9b3573c63583d00e69b0103049ed85c6d19..a9ff663e60b911bd2987f13b7ac0e12f3e20450a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3673.  [func]          New "in-view" zone option allows direct sharing
+                       of zones between views. [RT #32968]
+
 3672.  [func]          Local address can now be specified when using
                        dns_client API. [RT #34811]
 
index 29c8a9f884c326fc2eb7f228aab342641fccb94b..6725c3f585a0ca67f321d464d1fcccad913f7725 100644 (file)
@@ -379,8 +379,8 @@ configure_alternates(const cfg_obj_t *config, dns_view_t *view,
 static isc_result_t
 configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
               const cfg_obj_t *vconfig, isc_mem_t *mctx, dns_view_t *view,
-              cfg_aclconfctx_t *aclconf, isc_boolean_t added,
-              isc_boolean_t old_rpz_ok);
+              dns_viewlist_t *viewlist, cfg_aclconfctx_t *aclconf,
+              isc_boolean_t added, isc_boolean_t old_rpz_ok);
 
 static isc_result_t
 add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx);
@@ -2255,7 +2255,8 @@ create_empty_zone(dns_zone_t *zone, dns_name_t *name, dns_view_t *view,
  * global defaults in 'config' used exclusively.
  */
 static isc_result_t
-configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
+configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
+              cfg_obj_t *config, cfg_obj_t *vconfig,
               ns_cachelist_t *cachelist, const cfg_obj_t *bindkeys,
               isc_mem_t *mctx, cfg_aclconfctx_t *actx,
               isc_boolean_t need_hints)
@@ -2431,7 +2432,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
        {
                const cfg_obj_t *zconfig = cfg_listelt_value(element);
                CHECK(configure_zone(config, zconfig, vconfig, mctx, view,
-                                    actx, ISC_FALSE, old_rpz_ok));
+                                    viewlist, actx, ISC_FALSE, old_rpz_ok));
        }
 
        /*
@@ -2478,7 +2479,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
                {
                        const cfg_obj_t *zconfig = cfg_listelt_value(element);
                        CHECK(configure_zone(config, zconfig, vconfig,
-                                            mctx, view, actx,
+                                            mctx, view, NULL, actx,
                                             ISC_TRUE, ISC_FALSE));
                }
        }
@@ -4009,8 +4010,8 @@ create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist,
 static isc_result_t
 configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
               const cfg_obj_t *vconfig, isc_mem_t *mctx, dns_view_t *view,
-              cfg_aclconfctx_t *aclconf, isc_boolean_t added,
-              isc_boolean_t old_rpz_ok)
+              dns_viewlist_t *viewlist, cfg_aclconfctx_t *aclconf,
+              isc_boolean_t added, isc_boolean_t old_rpz_ok)
 {
        dns_view_t *pview = NULL;       /* Production view */
        dns_zone_t *zone = NULL;        /* New or reused zone */
@@ -4023,6 +4024,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
        const cfg_obj_t *forwardtype = NULL;
        const cfg_obj_t *only = NULL;
        const cfg_obj_t *signing = NULL;
+       const cfg_obj_t *viewobj = NULL;
        isc_result_t result;
        isc_result_t tresult;
        isc_buffer_t buffer;
@@ -4067,11 +4069,64 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
                goto cleanup;
        }
 
+       (void)cfg_map_get(zoptions, "in-view", &viewobj);
+       if (viewobj != NULL) {
+               const char *inview = cfg_obj_asstring(viewobj);
+               dns_view_t *otherview = NULL;
+
+               if (viewlist == NULL) {
+                       cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
+                                   "'in-view' option is not permitted in "
+                                   "dynamically added zones");
+                       result = ISC_R_FAILURE;
+                       goto cleanup;
+               }
+
+               result = dns_viewlist_find(viewlist, inview, view->rdclass,
+                                          &otherview);
+               if (result != ISC_R_SUCCESS) {
+                       cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
+                                   "view '%s' is not yet defined.", inview);
+                       result = ISC_R_FAILURE;
+                       goto cleanup;
+               }
+
+               result = dns_view_findzone(otherview, origin, &zone);
+               dns_view_detach(&otherview);
+               if (result != ISC_R_SUCCESS) {
+                       cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
+                                   "zone '%s' not defined in view '%s'",
+                                   zname, inview);
+                       result = ISC_R_FAILURE;
+                       goto cleanup;
+               }
+
+               CHECK(dns_view_addzone(view, zone));
+               dns_zone_detach(&zone);
+
+               /*
+                * If the zone contains a 'forwarders' statement, configure
+                * selective forwarding.  Note: this is not inherited from the
+                * other view.
+                */
+               forwarders = NULL;
+               result = cfg_map_get(zoptions, "forwarders", &forwarders);
+               if (result == ISC_R_SUCCESS) {
+                       forwardtype = NULL;
+                       (void)cfg_map_get(zoptions, "forward", &forwardtype);
+                       CHECK(configure_forward(config, view, origin,
+                                               forwarders, forwardtype));
+               }
+               result = ISC_R_SUCCESS;
+               goto cleanup;
+       }
+
        (void)cfg_map_get(zoptions, "type", &typeobj);
        if (typeobj == NULL) {
                cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
                            "zone '%s' 'type' not specified", zname);
-               return (ISC_R_FAILURE);
+               result = ISC_R_FAILURE;
+               goto cleanup;
        }
        ztypestr = cfg_obj_asstring(typeobj);
 
@@ -4154,7 +4209,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
                        result = ISC_R_EXISTS;
                        goto cleanup;
                }
-               result = dns_viewlist_find(&ns_g_server->viewlist, view->name,
+               result = dns_viewlist_find(viewlist, view->name,
                                           view->rdclass, &pview);
                if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS)
                        goto cleanup;
@@ -5699,7 +5754,7 @@ load_configuration(const char *filename, ns_server_t *server,
 
                view = NULL;
                CHECK(find_view(vconfig, &viewlist, &view));
-               CHECK(configure_view(view, config, vconfig,
+               CHECK(configure_view(view, &viewlist, config, vconfig,
                                     &cachelist, bindkeys, ns_g_mctx,
                                     ns_g_aclconfctx, ISC_TRUE));
                dns_view_freeze(view);
@@ -5713,7 +5768,7 @@ load_configuration(const char *filename, ns_server_t *server,
        if (views == NULL) {
                view = NULL;
                CHECK(find_view(NULL, &viewlist, &view));
-               CHECK(configure_view(view, config, NULL,
+               CHECK(configure_view(view, &viewlist, config, NULL,
                                     &cachelist, bindkeys,
                                     ns_g_mctx, ns_g_aclconfctx, ISC_TRUE));
                dns_view_freeze(view);
@@ -5733,7 +5788,7 @@ load_configuration(const char *filename, ns_server_t *server,
                cfg_obj_t *vconfig = cfg_listelt_value(element);
 
                CHECK(create_view(vconfig, &builtin_viewlist, &view));
-               CHECK(configure_view(view, config, vconfig,
+               CHECK(configure_view(view, &viewlist, config, vconfig,
                                     &cachelist, bindkeys,
                                     ns_g_mctx, ns_g_aclconfctx, ISC_FALSE));
                dns_view_freeze(view);
@@ -8616,8 +8671,8 @@ ns_server_add_zone(ns_server_t *server, char *args) {
        RUNTIME_CHECK(result == ISC_R_SUCCESS);
        dns_view_thaw(view);
        result = configure_zone(cfg->config, parms, vconfig,
-                               server->mctx, view, cfg->actx, ISC_FALSE,
-                               ISC_FALSE);
+                               server->mctx, view, NULL, cfg->actx,
+                               ISC_FALSE, ISC_FALSE);
        dns_view_freeze(view);
        isc_task_endexclusive(server->task);
        if (result != ISC_R_SUCCESS)
diff --git a/bin/tests/system/checkconf/bad-sharedzone1.conf b/bin/tests/system/checkconf/bad-sharedzone1.conf
new file mode 100644 (file)
index 0000000..6a38bca
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+view "first" {
+       match-clients {
+               "none";
+       };
+       zone "clone" {
+               type master;
+               file "xxx";
+       };
+};
+view "second" {
+       match-clients {
+               "any";
+       };
+       zone "clone" {
+               in-view "first";
+               type slave;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-sharedzone2.conf b/bin/tests/system/checkconf/bad-sharedzone2.conf
new file mode 100644 (file)
index 0000000..0cdb7d4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+view "first" {
+       match-clients {
+               "none";
+       };
+       zone "clone" {
+               type master;
+               file "xxx";
+       };
+};
+view "second" {
+       match-clients {
+               "any";
+       };
+       zone "clone" {
+               in-view "first";
+               forward only;
+               forwarders { 10.0.0.100; };
+               type slave;
+       };
+};
index 8f0312b49f598c81cb2bb21d0060528950e01740..f30798713fd0d71f64014096636eeb3e9389a0aa 100644 (file)
@@ -81,6 +81,10 @@ view "first" {
                update-policy local;
                notify-source 10.10.10.10 port 53 dscp 55;
        };
+       zone "clone" {
+               type master;
+               file "yyy";
+       };
        dnssec-lookaside auto;
        dnssec-validation auto;
        zone-statistics terse;
@@ -103,7 +107,22 @@ view "second" {
                };
                zone-statistics no;
        };
+       zone "clone" {
+               in-view "first";
+       };
        dnssec-lookaside "." trust-anchor "dlv.isc.org.";
        dnssec-validation auto;
        zone-statistics full;
 };
+view "third" {
+       match-clients {
+               "none";
+       };
+       zone "clone" {
+               in-view "first";
+               forward only;
+               forwarders {
+                       10.0.0.100;
+               };
+       };
+};
index 091fe31fb3a366bdbdda7807f0b83a524cddf934..d22c0328d525c0e832430197517c8e246a1a98a9 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2004, 2005, 2007, 2012  Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2004, 2005, 2007, 2012, 2013  Internet Systems Consortium, Inc. ("ISC")
 # Copyright (C) 2000, 2001  Internet Software Consortium.
 #
 # Permission to use, copy, modify, and/or distribute this software for any
@@ -23,4 +23,5 @@
 
 rm -f ns3/example.bk dig.out.ns?.?
 rm -f ns2/named.conf ns2/example.db ns3/named.conf ns3/internal.bk
+rm -f */*.jnl
 rm -f */named.memstats
diff --git a/bin/tests/system/views/ns2/clone.db b/bin/tests/system/views/ns2/clone.db
new file mode 100644 (file)
index 0000000..4867a69
--- /dev/null
@@ -0,0 +1,28 @@
+; Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+;
+; Permission to use, copy, modify, and/or distribute this software for any
+; purpose with or without fee is hereby granted, provided that the above
+; copyright notice and this permission notice appear in all copies.
+;
+; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+; AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+; PERFORMANCE OF THIS SOFTWARE.
+
+$TTL   600
+@              IN SOA  mname1. . (
+                       2          ; serial
+                       20         ; refresh (20 seconds)
+                       20         ; retry (20 seconds)
+                       1814400    ; expire (3 weeks)
+                       3600       ; minimum (1 hour)
+                       )
+@              IN      NS              ns2
+ns2            IN      A       10.53.0.2
+
+a              IN      A       10.1.0.1
+child          IN      NS      ns3.child
+ns3.child      IN      A       10.53.0.3
index a09d0691e39b3e538df732e9c6c9ad82dfa96c3a..ef5e3a0df74dc7e7aacd972b395d6a785bc8e03f 100644 (file)
@@ -27,7 +27,7 @@ options {
        pid-file "named.pid";
        listen-on { 10.53.0.2; };
        listen-on-v6 { none; };
-       recursion no;
+       recursion yes;
        notify yes;
 };
 
index e4180f2a773778a75ef7554867c9c27997603f31..3c8e033ca79e75346be91f8d1c6d1290a49c33b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2007, 2013  Internet Systems Consortium, Inc. ("ISC")
  * Copyright (C) 2000, 2001  Internet Software Consortium.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
@@ -27,7 +27,7 @@ options {
        pid-file "named.pid";
        listen-on { 10.53.0.2; 10.53.0.4; };
        listen-on-v6 { none; };
-       recursion no;
+       recursion yes;
        notify yes;
 };
 
@@ -47,6 +47,12 @@ view "internal" {
                file "internal.db";
                allow-update { any; };
        };
+
+       zone "clone" {
+               type master;
+               file "clone.db";
+               allow-update { any; };
+       };
 };
 
 view "external" {
@@ -61,5 +67,10 @@ view "external" {
                type master;
                file "example.db";
        };
-};
 
+       zone "clone" {
+               in-view internal;
+               forward only;
+               forwarders { 10.53.0.4; };
+       };
+};
diff --git a/bin/tests/system/views/ns3/child.clone.db b/bin/tests/system/views/ns3/child.clone.db
new file mode 100644 (file)
index 0000000..4fc7462
--- /dev/null
@@ -0,0 +1,26 @@
+; Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+;
+; Permission to use, copy, modify, and/or distribute this software for any
+; purpose with or without fee is hereby granted, provided that the above
+; copyright notice and this permission notice appear in all copies.
+;
+; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+; AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+; PERFORMANCE OF THIS SOFTWARE.
+
+
+$TTL 300       ; 5 minutes
+@              IN SOA  ns3. . (
+                       1          ; serial
+                       20         ; refresh (20 seconds)
+                       20         ; retry (20 seconds)
+                       1814400    ; expire (3 weeks)
+                       3600       ; minimum (1 hour)
+                       )
+@              NS      ns3
+@              TXT     This is NS3.
+ns3            A       10.53.0.3
index 11a105e241da4b92ead832d4b472b9f9044959e1..8f2976dd95c7b6a89eedae96bc91e212522b8d97 100644 (file)
@@ -52,4 +52,7 @@ zone "example" {
        file "internal.db";
 };
 
-
+zone "child.clone" {
+       type master;
+       file "child.clone.db";
+};
index 495bdc432eb0cccfb728d5ad2f5c3ac2d34d5b21..061e9fea80d824866f83048b3aa606465981eb05 100644 (file)
@@ -52,3 +52,9 @@ zone "example" {
        allow-update { any; };
        file "internal.bk";
 };
+
+zone "child.clone" {
+       type master;
+       file "child.clone.db";
+};
+
diff --git a/bin/tests/system/views/ns4/child.clone.db b/bin/tests/system/views/ns4/child.clone.db
new file mode 100644 (file)
index 0000000..a5c6e64
--- /dev/null
@@ -0,0 +1,26 @@
+; Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+;
+; Permission to use, copy, modify, and/or distribute this software for any
+; purpose with or without fee is hereby granted, provided that the above
+; copyright notice and this permission notice appear in all copies.
+;
+; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+; AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+; PERFORMANCE OF THIS SOFTWARE.
+
+
+$TTL 300       ; 5 minutes
+@              IN SOA  ns3. . (
+                       1          ; serial
+                       20         ; refresh (20 seconds)
+                       20         ; retry (20 seconds)
+                       1814400    ; expire (3 weeks)
+                       3600       ; minimum (1 hour)
+                       )
+@              NS      ns3
+@              TXT     This is NS4.
+ns3            A       10.53.0.3
diff --git a/bin/tests/system/views/ns4/named.conf b/bin/tests/system/views/ns4/named.conf
new file mode 100644 (file)
index 0000000..bf9d0e2
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004, 2007, 2013  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id: named1.conf,v 1.19 2007/06/19 23:47:07 tbox Exp $ */
+
+controls { /* empty */ };
+
+options {
+       query-source address 10.53.0.4;
+       notify-source 10.53.0.4;
+       transfer-source 10.53.0.4;
+       port 5300;
+       directory ".";
+       pid-file "named.pid";
+       listen-on { 10.53.0.4; };
+       listen-on-v6 { none; };
+       recursion yes;
+       notify yes;
+};
+
+key rndc_key {
+        secret "1234abcd8765";
+        algorithm hmac-sha256;
+};
+
+controls {
+        inet 10.53.0.3 port 9953 allow { any; } keys { rndc_key; };
+};
+
+zone "." {
+       type hint;
+       file "../../common/root.hint";
+};
+
+zone "child.clone" {
+       type master;
+       file "child.clone.db";
+};
index 71674c9ace6aee0e335f8f7fd93925e207869c2a..3912defcba02072ab37e0da48bb367fd724e24df 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2004, 2007, 2012  Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2004, 2007, 2012, 2013  Internet Systems Consortium, Inc. ("ISC")
 # Copyright (C) 2000, 2001  Internet Software Consortium.
 #
 # Permission to use, copy, modify, and/or distribute this software for any
@@ -79,5 +79,47 @@ then
        status=1
 fi
 
+echo "I:updating cloned zone in internal view"
+$NSUPDATE << EOF
+server 10.53.0.2 5300
+zone clone
+update add b.clone. 300 in a 10.1.0.3
+send
+EOF
+echo "I:sleeping to allow update to take effect"
+sleep 5
+
+echo "I:verifying update affected both views"
+ret=0
+one=`$DIG +tcp +short -p 5300 -b 10.53.0.2 @10.53.0.2 b.clone a`
+two=`$DIG +tcp +short -p 5300 -b 10.53.0.4 @10.53.0.2 b.clone a`
+if [ "$one" != "$two" ]; then
+        echo "'$one' does not match '$two'"
+        ret=1
+fi
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:verifying forwarder in cloned zone works"
+ret=0
+one=`$DIG +tcp +short -p 5300 -b 10.53.0.2 @10.53.0.2 child.clone txt`
+two=`$DIG +tcp +short -p 5300 -b 10.53.0.4 @10.53.0.2 child.clone txt`
+three=`$DIG +tcp +short -p 5300 @10.53.0.3 child.clone txt`
+four=`$DIG +tcp +short -p 5300 @10.53.0.4 child.clone txt`
+if [ "$one" = "$two" ]; then
+        echo "'$one' matches '$two'"
+        ret=1
+fi
+if [ "$one" != "$three" ]; then
+        echo "'$one' does not match '$three'"
+        ret=1
+fi
+if [ "$two" != "$four" ]; then
+        echo "'$two' does not match '$four'"
+        ret=1
+fi
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 exit $status
index 8d883d607bc321a6371a95d8374b96711d709665..fe6a3511b5d7b3725cf126d1766b2e81dc12d1ff 100644 (file)
@@ -10792,6 +10792,10 @@ zone <replaceable>zone_name</replaceable> <optional><replaceable>class</replacea
     type delegation-only;
 };
 
+zone <replaceable>zone_name</replaceable> <optional><replaceable>class</replaceable></optional> {
+    <optional> in-view <replaceable>string</replaceable> ; </optional>
+};
+
 </programlisting>
 
         </sect2>
@@ -11138,8 +11142,8 @@ zone <replaceable>zone_name</replaceable> <optional><replaceable>class</replacea
               in the mid-1970s. Zone data for it can be specified with the <literal>CHAOS</literal> class.
             </para>
           </sect3>
-          <sect3>
 
+          <sect3>
             <title>Zone Options</title>
 
             <variablelist>
@@ -12327,6 +12331,52 @@ example.com. NS ns2.example.net.
              checked for each existing record type.
            </para>
           </sect3>
+
+          <sect3>
+            <title>Multiple views</title>
+            <para>
+              When multiple views are in use, a zone may be
+              referenced by more than one of them. Often, the views
+              will contain different zones with the same name, allowing
+              different clients to receive different answers for the same
+              queries. At times, however, it is desirable for multiple
+              views to contain identical zones.  The
+              <command>in-view</command> zone option provides an efficient
+              way to do this: it allows a view to reference a zone that
+              was defined in a previously configured view. Example:
+            </para>
+            <programlisting>
+view internal {
+    match-clients { 10/8; };
+
+    zone example.com {
+        type master;
+        file "example-external.db";
+    };
+};
+
+view external {
+    match-clients { any; };
+
+    zone example.com {
+        in-view internal;
+    };
+};
+            </programlisting>
+            <para>
+              An <command>in-view</command> option cannot refer to a view
+              that is configured later in the configuration file.
+            </para>
+            <para>
+              A <command>zone</command> statement which uses the
+              <command>in-view</command> option may not use any other
+              options with the exception of <command>forward</command>
+              and <command>forwarders</command>. (These options control
+              the behavior of the containing view, rather than changing
+              the zone object itself.)
+            </para>
+          </sect3>
+
         </sect2>
       </sect1>
       <sect1>
index 33dd1639f2847c1b5a2ebb7aef714bf48df7a786..1636bc0c49aff0ad381466bf9919ebc131b0d3d1 100644 (file)
@@ -1509,6 +1509,28 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
        if (config != NULL)
                cfg_map_get(config, "options", &goptions);
 
+       obj = NULL;
+       (void)cfg_map_get(zoptions, "in-view", &obj);
+       if (obj != NULL) {
+               const cfg_obj_t *fwd = NULL;
+               unsigned int maxopts = 1;
+               (void)cfg_map_get(zoptions, "forward", &fwd);
+               if (fwd != NULL)
+                       maxopts++;
+               fwd = NULL;
+               (void)cfg_map_get(zoptions, "forwarders", &fwd);
+               if (fwd != NULL)
+                       maxopts++;
+               if (cfg_map_count(zoptions) > maxopts) {
+                       cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
+                                   "zone '%s': 'in-view' used "
+                                   "with incompatible zone options",
+                                   znamestr);
+                       return (ISC_R_FAILURE);
+               }
+               return (ISC_R_SUCCESS);
+       }
+
        obj = NULL;
        (void)cfg_map_get(zoptions, "type", &obj);
        if (obj == NULL) {
index d7a72117e6901d47264a35038de95a25fd64d41e..a8381442d3233744e5821a245b47016bcd0a8f95 100644 (file)
@@ -1932,6 +1932,10 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) {
        if (zone->zmgr == NULL)
                return (ISC_R_FAILURE);
 
+       /* If we already have a load pending, stop now */
+       if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING))
+               done(arg, zone, NULL);
+
        asl = isc_mem_get(zone->mctx, sizeof (*asl));
        if (asl == NULL)
                CHECK(ISC_R_NOMEMORY);
index eb1e42472475fc3105b263283f2f67435c3ef855..7e58546ec2451947fe5b43bc9f62480929052b36 100644 (file)
@@ -74,8 +74,7 @@ static isc_result_t
 doneloading(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task);
 
 isc_result_t
-dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp)
-{
+dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) {
        dns_zt_t *zt;
        isc_result_t result;
 
@@ -534,6 +533,5 @@ auto_detach(void *data, void *arg) {
        dns_zone_t *zone = data;
 
        UNUSED(arg);
-
        dns_zone_detach(&zone);
 }
index 9d0e5e2f23f04933187e63a624efd71e615f32c2..fe27eb3706e563149432e41baee48d28e350e192 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2007, 2009, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007, 2009, 2011-2013  Internet Systems Consortium, Inc. ("ISC")
  * Copyright (C) 1996-2001  Internet Software Consortium.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
@@ -134,6 +134,9 @@ isc_symtab_define(isc_symtab_t *symtab, const char *key, unsigned int type,
 isc_result_t
 isc_symtab_undefine(isc_symtab_t *symtab, const char *key, unsigned int type);
 
+/*% Return the number of items in a symbol table. */
+unsigned int
+isc_symtab_count(isc_symtab_t *symtab);
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_SYMTAB_H */
index 1f294fb9c02e9cb1f36b9ff07833e7feb6fda2b9..a5e7768b020d7417a32094c67fe7e3f2a4c26607 100644 (file)
@@ -301,3 +301,9 @@ isc_symtab_undefine(isc_symtab_t *symtab, const char *key, unsigned int type) {
 
        return (ISC_R_SUCCESS);
 }
+
+unsigned int
+isc_symtab_count(isc_symtab_t *symtab) {
+       REQUIRE(VALID_SYMTAB(symtab));
+       return (symtab->count);
+}
index 8258e35585176148a4964557742098f99684968b..fc1c1955dd4de041633845a26b71e702f48d0034 100644 (file)
@@ -528,6 +528,7 @@ isc_string_separate
 isc_string_strlcat
 isc_string_strlcpy
 isc_string_touint64
+isc_symtab_count
 isc_symtab_create
 isc_symtab_define
 isc_symtab_destroy
index 9771395b0473c0c19e4fc8b273698a1bba893aa0..567bd30e04b2b0031ce54f1c266e2efcf1607df0 100644 (file)
@@ -193,6 +193,18 @@ cfg_map_getname(const cfg_obj_t *mapobj);
  *     or NULL if the map object does not have a name.
  */
 
+unsigned int
+cfg_map_count(const cfg_obj_t *mapobj);
+/*%<
+ * Get the number of elements defined in the symbol table of a map object.
+ *
+ * Requires:
+ *    \li  'mapobj' points to a valid configuration object of a map type.
+ *
+ * Returns:
+ * \li     The number of elements in the map object.
+ */
+
 isc_boolean_t
 cfg_obj_istuple(const cfg_obj_t *obj);
 /*%<
index f0f7aed421a6ccd097af5046352c872fbf995e99..0638b3fd29ccb3b32a9ce622f08e739606768e71 100644 (file)
@@ -1666,6 +1666,7 @@ zone_only_clauses[] = {
         * the zone options and the global/view options.  Ugh.
         */
        { "check-names", &cfg_type_checkmode, 0 },
+       { "in-view", &cfg_type_astring, 0 },
        { "ixfr-from-differences", &cfg_type_boolean, 0 },
        { "server-addresses", &cfg_type_bracketed_sockaddrlist, 0 },
        { "server-names", &cfg_type_namelist, 0 },
index 775d7c323cd8400cd8030740e355525f7b5a4ef4..38325d7fb00481ce5c7c790218443c91e365b173 100644 (file)
@@ -1605,6 +1605,13 @@ cfg_map_getname(const cfg_obj_t *mapobj) {
        return (mapobj->value.map.id);
 }
 
+unsigned int
+cfg_map_count(const cfg_obj_t *mapobj) {
+       const cfg_map_t *map;
+       REQUIRE(mapobj != NULL && mapobj->type->rep == &cfg_rep_map);
+       map = &mapobj->value.map;
+       return (isc_symtab_count(map->symtab));
+}
 
 /* Parse an arbitrary token, storing its raw text representation. */
 static isc_result_t
index e5d5bd873a8f1e2b346ffc4556dcd0c5f6cb618c..c9b9a9127fd7ce073d1c5f86625481ce4efa9403 100644 (file)
@@ -11,6 +11,7 @@ cfg_list_first
 cfg_list_next
 cfg_listelt_value
 cfg_log_init
+cfg_map_count
 cfg_map_get
 cfg_map_getname
 cfg_obj_asboolean