diff --git a/CHANGES b/CHANGES
index a02ae9b357..a9ff663e60 100644
--- 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]
diff --git a/bin/named/server.c b/bin/named/server.c
index 29c8a9f884..6725c3f585 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -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
index 0000000000..6a38bca248
--- /dev/null
+++ b/bin/tests/system/checkconf/bad-sharedzone1.conf
@@ -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
index 0000000000..0cdb7d446f
--- /dev/null
+++ b/bin/tests/system/checkconf/bad-sharedzone2.conf
@@ -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;
+ };
+};
diff --git a/bin/tests/system/checkconf/good.conf b/bin/tests/system/checkconf/good.conf
index 8f0312b49f..f30798713f 100644
--- a/bin/tests/system/checkconf/good.conf
+++ b/bin/tests/system/checkconf/good.conf
@@ -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;
+ };
+ };
+};
diff --git a/bin/tests/system/views/clean.sh b/bin/tests/system/views/clean.sh
index 091fe31fb3..d22c0328d5 100644
--- a/bin/tests/system/views/clean.sh
+++ b/bin/tests/system/views/clean.sh
@@ -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
index 0000000000..4867a6980e
--- /dev/null
+++ b/bin/tests/system/views/ns2/clone.db
@@ -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
diff --git a/bin/tests/system/views/ns2/named1.conf b/bin/tests/system/views/ns2/named1.conf
index a09d0691e3..ef5e3a0df7 100644
--- a/bin/tests/system/views/ns2/named1.conf
+++ b/bin/tests/system/views/ns2/named1.conf
@@ -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;
};
diff --git a/bin/tests/system/views/ns2/named2.conf b/bin/tests/system/views/ns2/named2.conf
index e4180f2a77..3c8e033ca7 100644
--- a/bin/tests/system/views/ns2/named2.conf
+++ b/bin/tests/system/views/ns2/named2.conf
@@ -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
index 0000000000..4fc7462365
--- /dev/null
+++ b/bin/tests/system/views/ns3/child.clone.db
@@ -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
diff --git a/bin/tests/system/views/ns3/named1.conf b/bin/tests/system/views/ns3/named1.conf
index 11a105e241..8f2976dd95 100644
--- a/bin/tests/system/views/ns3/named1.conf
+++ b/bin/tests/system/views/ns3/named1.conf
@@ -52,4 +52,7 @@ zone "example" {
file "internal.db";
};
-
+zone "child.clone" {
+ type master;
+ file "child.clone.db";
+};
diff --git a/bin/tests/system/views/ns3/named2.conf b/bin/tests/system/views/ns3/named2.conf
index 495bdc432e..061e9fea80 100644
--- a/bin/tests/system/views/ns3/named2.conf
+++ b/bin/tests/system/views/ns3/named2.conf
@@ -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
index 0000000000..a5c6e64a17
--- /dev/null
+++ b/bin/tests/system/views/ns4/child.clone.db
@@ -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
index 0000000000..bf9d0e257c
--- /dev/null
+++ b/bin/tests/system/views/ns4/named.conf
@@ -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";
+};
diff --git a/bin/tests/system/views/tests.sh b/bin/tests/system/views/tests.sh
index 71674c9ace..3912defcba 100644
--- a/bin/tests/system/views/tests.sh
+++ b/bin/tests/system/views/tests.sh
@@ -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
diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml
index 8d883d607b..fe6a3511b5 100644
--- a/doc/arm/Bv9ARM-book.xml
+++ b/doc/arm/Bv9ARM-book.xml
@@ -10792,6 +10792,10 @@ zone zone_name classzone_name class {
+ in-view string ;
+};
+
@@ -11138,8 +11142,8 @@ zone zone_name classCHAOS class.
-
+
Zone Options
@@ -12327,6 +12331,52 @@ example.com. NS ns2.example.net.
checked for each existing record type.
+
+
+ Multiple views
+
+ 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
+ in-view 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:
+
+
+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;
+ };
+};
+
+
+ An in-view option cannot refer to a view
+ that is configured later in the configuration file.
+
+
+ A zone statement which uses the
+ in-view option may not use any other
+ options with the exception of forward
+ and forwarders. (These options control
+ the behavior of the containing view, rather than changing
+ the zone object itself.)
+
+
+
diff --git a/lib/bind9/check.c b/lib/bind9/check.c
index 33dd1639f2..1636bc0c49 100644
--- a/lib/bind9/check.c
+++ b/lib/bind9/check.c
@@ -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) {
diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index d7a72117e6..a8381442d3 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -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);
diff --git a/lib/dns/zt.c b/lib/dns/zt.c
index eb1e424724..7e58546ec2 100644
--- a/lib/dns/zt.c
+++ b/lib/dns/zt.c
@@ -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);
}
diff --git a/lib/isc/include/isc/symtab.h b/lib/isc/include/isc/symtab.h
index 9d0e5e2f23..fe27eb3706 100644
--- a/lib/isc/include/isc/symtab.h
+++ b/lib/isc/include/isc/symtab.h
@@ -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 */
diff --git a/lib/isc/symtab.c b/lib/isc/symtab.c
index 1f294fb9c0..a5e7768b02 100644
--- a/lib/isc/symtab.c
+++ b/lib/isc/symtab.c
@@ -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);
+}
diff --git a/lib/isc/win32/libisc.def b/lib/isc/win32/libisc.def
index 8258e35585..fc1c1955dd 100644
--- a/lib/isc/win32/libisc.def
+++ b/lib/isc/win32/libisc.def
@@ -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
diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h
index 9771395b04..567bd30e04 100644
--- a/lib/isccfg/include/isccfg/cfg.h
+++ b/lib/isccfg/include/isccfg/cfg.h
@@ -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);
/*%<
diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c
index f0f7aed421..0638b3fd29 100644
--- a/lib/isccfg/namedconf.c
+++ b/lib/isccfg/namedconf.c
@@ -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 },
diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c
index 775d7c323c..38325d7fb0 100644
--- a/lib/isccfg/parser.c
+++ b/lib/isccfg/parser.c
@@ -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
diff --git a/lib/isccfg/win32/libisccfg.def b/lib/isccfg/win32/libisccfg.def
index e5d5bd873a..c9b9a9127f 100644
--- a/lib/isccfg/win32/libisccfg.def
+++ b/lib/isccfg/win32/libisccfg.def
@@ -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