Adam Tkac 45783c
Index: bind9/bin/named/server.c
Adam Tkac 45783c
diff -u bind9/bin/named/server.c:1.483 bind9/bin/named/server.c:1.483.10.1
Adam Tkac 45783c
--- bind9/bin/named/server.c:1.483	Tue Apr 24 06:55:32 2007
Adam Tkac 45783c
+++ bind9/bin/named/server.c	Mon May 14 05:46:56 2007
Adam Tkac 45783c
@@ -4124,23 +4124,28 @@
Adam Tkac 45783c
 		result = dns_rdataclass_fromtext(&rdclass, &r);
Adam Tkac 45783c
 		if (result != ISC_R_SUCCESS)
Adam Tkac 45783c
 			goto fail1;
Adam Tkac 45783c
-	} else {
Adam Tkac 45783c
+	} else
Adam Tkac 45783c
 		rdclass = dns_rdataclass_in;
Adam Tkac 45783c
-	}
Adam Tkac 45783c
 	
Adam Tkac 45783c
-	if (viewtxt == NULL)
Adam Tkac 45783c
-		viewtxt = "_default";
Adam Tkac 45783c
-	result = dns_viewlist_find(&server->viewlist, viewtxt,
Adam Tkac 45783c
-				   rdclass, &view);
Adam Tkac 45783c
-	if (result != ISC_R_SUCCESS)
Adam Tkac 45783c
-		goto fail1;
Adam Tkac 45783c
+	if (viewtxt == NULL) {
Adam Tkac 45783c
+		result = dns_viewlist_findzone(&server->viewlist,
Adam Tkac 45783c
+					       dns_fixedname_name(&name),
Adam Tkac 45783c
+					       ISC_TF(classtxt == NULL),
Adam Tkac 45783c
+					       rdclass, zonep);
Adam Tkac 45783c
+	} else {
Adam Tkac 45783c
+		result = dns_viewlist_find(&server->viewlist, viewtxt,
Adam Tkac 45783c
+					   rdclass, &view);
Adam Tkac 45783c
+		if (result != ISC_R_SUCCESS)
Adam Tkac 45783c
+			goto fail1;
Adam Tkac 45783c
 	
Adam Tkac 45783c
-	result = dns_zt_find(view->zonetable, dns_fixedname_name(&name),
Adam Tkac 45783c
-			     0, NULL, zonep);
Adam Tkac 45783c
+		result = dns_zt_find(view->zonetable, dns_fixedname_name(&name),
Adam Tkac 45783c
+				     0, NULL, zonep);
Adam Tkac 45783c
+		dns_view_detach(&view);
Adam Tkac 45783c
+	}
Adam Tkac 45783c
+
Adam Tkac 45783c
 	/* Partial match? */
Adam Tkac 45783c
 	if (result != ISC_R_SUCCESS && *zonep != NULL)
Adam Tkac 45783c
 		dns_zone_detach(zonep);
Adam Tkac 45783c
-	dns_view_detach(&view);
Adam Tkac 45783c
  fail1:
Adam Tkac 45783c
 	return (result);
Adam Tkac 45783c
 }
Adam Tkac 45783c
Index: bind9/lib/dns/view.c
Adam Tkac 45783c
diff -u bind9/lib/dns/view.c:1.141 bind9/lib/dns/view.c:1.141.18.1
Adam Tkac 45783c
--- bind9/lib/dns/view.c:1.141	Thu Mar 29 06:36:30 2007
Adam Tkac 45783c
+++ bind9/lib/dns/view.c	Mon May 14 05:46:57 2007
Adam Tkac 45783c
@@ -1147,6 +1147,40 @@
Adam Tkac 205d5e
 }
Adam Tkac 205d5e
 
Adam Tkac 205d5e
 isc_result_t
Adam Tkac 45783c
+dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name,
Adam Tkac 45783c
+		      isc_boolean_t allclasses, dns_rdataclass_t rdclass,
Adam Tkac 45783c
+		      dns_zone_t **zonep)
Adam Tkac 205d5e
+{
Adam Tkac 205d5e
+	dns_view_t *view;
Adam Tkac 205d5e
+	isc_result_t result;
Adam Tkac 45783c
+	dns_zone_t *zone1 = NULL, *zone2 = NULL;
Adam Tkac 205d5e
+
Adam Tkac 205d5e
+	REQUIRE(list != NULL);
Adam Tkac 205d5e
+	for (view = ISC_LIST_HEAD(*list);
Adam Tkac 205d5e
+             view != NULL;
Adam Tkac 205d5e
+             view = ISC_LIST_NEXT(view, link)) {
Adam Tkac 45783c
+		if (allclasses == ISC_FALSE && view->rdclass != rdclass)
Adam Tkac 205d5e
+			continue;
Adam Tkac 45783c
+		result = dns_zt_find(view->zonetable, name, 0, NULL,
Adam Tkac 45783c
+				    (zone1 == NULL) ? &zone1 : &zone2);
Adam Tkac 45783c
+		INSIST(result == ISC_R_SUCCESS || result == ISC_R_NOTFOUND);
Adam Tkac 45783c
+		if (zone2 != NULL) {
Adam Tkac 45783c
+			dns_zone_detach(&zone1);
Adam Tkac 45783c
+			dns_zone_detach(&zone2);
Adam Tkac 45783c
+			return (ISC_R_NOTFOUND);
Adam Tkac 03f646
+		}
Adam Tkac 205d5e
+	}
Adam Tkac 45783c
+
Adam Tkac 45783c
+	if (zone1 != NULL) {
Adam Tkac 45783c
+		dns_zone_attach(zone1, zonep);
Adam Tkac 45783c
+		dns_zone_detach(&zone1);
Adam Tkac 45783c
+		return (ISC_R_SUCCESS);
Adam Tkac 45783c
+	}
Adam Tkac 45783c
+
Adam Tkac 45783c
+	return (ISC_R_NOTFOUND);
Adam Tkac 205d5e
+}
Adam Tkac 205d5e
+
Adam Tkac 205d5e
+isc_result_t
Adam Tkac 205d5e
 dns_view_load(dns_view_t *view, isc_boolean_t stop) {
Adam Tkac 205d5e
 
Adam Tkac 205d5e
 	REQUIRE(DNS_VIEW_VALID(view));
Adam Tkac 45783c
Index: bind9/lib/dns/include/dns/view.h
Adam Tkac 45783c
diff -u bind9/lib/dns/include/dns/view.h:1.105 bind9/lib/dns/include/dns/view.h:1.105.16.1
Adam Tkac 45783c
--- bind9/lib/dns/include/dns/view.h:1.105	Thu Mar 29 23:47:04 2007
Adam Tkac 45783c
+++ bind9/lib/dns/include/dns/view.h	Mon May 14 05:46:57 2007
Adam Tkac 45783c
@@ -595,6 +595,19 @@
Adam Tkac 205d5e
  */
Adam Tkac 205d5e
 
Adam Tkac 205d5e
 isc_result_t
Adam Tkac 03f646
+dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name, isc_boolean_t allclasses,
Adam Tkac 205d5e
+                      dns_rdataclass_t rdclass, dns_zone_t **zonep);
Adam Tkac 205d5e
+
Adam Tkac 205d5e
+/*%<
Adam Tkac 205d5e
+ * Search zone with 'name' in view with 'rdclass' in viewlist 'list'
Adam Tkac 03f646
+ * If found, zone is returned in *zonep. If allclasses is set rdclass is ignored
Adam Tkac 205d5e
+ *
Adam Tkac 205d5e
+ * Returns:
Adam Tkac 205d5e
+ *\li	#ISC_R_SUCCESS          A matching zone was found.
Adam Tkac 205d5e
+ *\li	#ISC_R_NOTFOUND         No matching zone was found.
Adam Tkac 205d5e
+ */
Adam Tkac 205d5e
+
Adam Tkac 205d5e
+isc_result_t
Adam Tkac 205d5e
 dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep);
Adam Tkac 205d5e
 /*%<
Adam Tkac 205d5e
  * Search for the zone 'name' in the zone table of 'view'.