From: Andrew Bartlett Date: Thu, 14 Dec 2017 23:30:50 +0000 (+1300) Subject: dns_server: Do the exact match query first, then do the wildcard lookup X-Git-Tag: talloc-2.1.11~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3efc879d98ba136d4d70e0e2d77fac9614186ab3;p=thirdparty%2Fsamba.git dns_server: Do the exact match query first, then do the wildcard lookup The wildcard lookup is SCOPE_ONELEVEL combined with an index on the name attribute. This is not as efficient as a base DN lookup, so we try for that first. A not-found and wildcard response will still fall back to the ONELEVEL index. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/source4/dns_server/dnsserver_common.c b/source4/dns_server/dnsserver_common.c index 3e161f81ac7..6c7ab802575 100644 --- a/source4/dns_server/dnsserver_common.c +++ b/source4/dns_server/dnsserver_common.c @@ -563,6 +563,20 @@ WERROR dns_common_wildcard_lookup(struct ldb_context *samdb, return werr; } + /* + * Do a point search first, then fall back to a wildcard + * lookup if it does not exist + */ + werr = dns_common_lookup(samdb, + mem_ctx, + dn, + records, + num_records, + NULL); + if (!W_ERROR_EQUAL(werr, WERR_DNS_ERROR_NAME_DOES_NOT_EXIST)) { + return werr; + } + ret = dns_wildcard_lookup(samdb, mem_ctx, dn, &msg); if (ret == LDB_ERR_OPERATIONS_ERROR) { return DNS_ERR(SERVER_FAILURE);