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