diff --git a/bin/named/server.c b/bin/named/server.c index dc16659341..fd12287d33 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10234,6 +10234,15 @@ get_matching_view(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr, return (*viewmatchresult); } + /* Also no offloading when there is no view at all to match against. */ + view = get_matching_view_next(NULL, message->rdclass); + if (view == NULL) { + *viewmatchresult = ISC_R_NOTFOUND; + return (*viewmatchresult); + } + + dns_message_resetsig(message); + matching_view_ctx_t *mvctx = isc_mem_get(message->mctx, sizeof(*mvctx)); *mvctx = (matching_view_ctx_t){ .srcaddr = srcaddr, @@ -10250,15 +10259,6 @@ get_matching_view(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr, isc_loop_attach(loop, &mvctx->loop); dns_message_attach(message, &mvctx->message); - dns_message_resetsig(message); - - view = get_matching_view_next(NULL, message->rdclass); - if (view == NULL) { - *mvctx->viewmatchresult = ISC_R_NOTFOUND; - isc_async_run(loop, get_matching_view_done, mvctx); - return (DNS_R_WAIT); - } - /* * If the message has a SIG0 signature which we are going to * check, and the client is not exempt from the SIG(0) quota, diff --git a/lib/ns/client.c b/lib/ns/client.c index 8d91ad07d0..7351c91923 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1683,6 +1683,16 @@ process_opt(ns_client_t *client, dns_rdataset_t *opt) { return (result); } +static void +ns_client_async_reset(ns_client_t *client) { + if (client->async) { + client->async = false; + if (client->handle != NULL) { + isc_nmhandle_unref(client->handle); + } + } +} + void ns__client_reset_cb(void *client0) { ns_client_t *client = client0; @@ -1709,12 +1719,7 @@ ns__client_reset_cb(void *client0) { client->keytag_len = 0; } - if (client->async) { - client->async = false; - if (client->handle != NULL) { - isc_nmhandle_unref(client->handle); - } - } + ns_client_async_reset(client); client->state = NS_CLIENTSTATE_READY; @@ -1749,12 +1754,7 @@ ns__client_put_cb(void *client0) { dns_message_puttemprdataset(client->message, &client->opt); } - if (client->async) { - client->async = false; - if (client->handle != NULL) { - isc_nmhandle_unref(client->handle); - } - } + ns_client_async_reset(client); dns_message_detach(&client->message); @@ -1786,19 +1786,22 @@ ns_client_setup_view(ns_client_t *client, isc_netaddr_t *netaddr) { ns_client_request_continue, client, &client->sigresult, &client->viewmatchresult, &client->view); + /* Async mode. */ if (result == DNS_R_WAIT) { INSIST(client->async == true); return (DNS_R_WAIT); } /* - * matchingview() is allowed to return anything other than DNS_R_WAIT - * only in non-async mode, in which case 'result' must be equal to + * matchingview() returning anything other than DNS_R_WAIT means it's + * not running in async mode, in which case 'result' must be equal to * 'client->viewmatchresult'. */ - INSIST(client->async == false); INSIST(result == client->viewmatchresult); + /* Non-async mode. */ + ns_client_async_reset(client); + return (result); } @@ -2480,17 +2483,7 @@ ns_client_request_continue(void *arg) { } cleanup: - - /* - * If we are running async then 'unref' the handle and reset the async - * flag, so that the destructor doesn't try to 'unref' the handle too. - */ - if (client->async) { - client->async = false; - if (client->handle != NULL) { - isc_nmhandle_unref(client->handle); - } - } + ns_client_async_reset(client); } isc_result_t