From ebf7b31aa36c379b5adef6ebd999d3ef0ebfd308 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 8 Sep 2022 11:43:41 -0700 Subject: [PATCH] merge dns_request_createvia() into dns_request_create() dns_request_create() was a front-end to dns_request_createvia() that was only used by test binaries. dns_request_createvia() has been renamed to dns_request_create(), and the test programs that formerly used dns_request_create() have been updated to use the new parameters. --- bin/nsupdate/nsupdate.c | 40 ++++++++++----------- bin/tests/system/pipelined/pipequeries.c | 8 ++--- bin/tests/system/tkey/keycreate.c | 6 ++-- bin/tests/system/tkey/keydelete.c | 6 ++-- bin/tools/mdig.c | 4 +-- lib/dns/include/dns/request.h | 46 +++--------------------- lib/dns/request.c | 29 +++++---------- lib/dns/zone.c | 29 ++++++++------- 8 files changed, 60 insertions(+), 108 deletions(-) diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 625fa0925c..4f4a349420 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -2480,11 +2480,11 @@ send_update(dns_name_t *zone, isc_sockaddr_t *primary) { updatemsg->tsigname->attributes |= DNS_NAMEATTR_NOCOMPRESS; } - result = dns_request_createvia(requestmgr, updatemsg, srcaddr, primary, - -1, options, tsigkey, timeout, - udp_timeout, udp_retries, global_task, - update_completed, NULL, &request); - check_result(result, "dns_request_createvia"); + result = dns_request_create(requestmgr, updatemsg, srcaddr, primary, -1, + options, tsigkey, timeout, udp_timeout, + udp_retries, global_task, update_completed, + NULL, &request); + check_result(result, "dns_request_create"); if (debugging) { show_message(stdout, updatemsg, "Outgoing update query:"); @@ -2589,11 +2589,11 @@ recvsoa(isc_task_t *task, isc_event_t *event) { srcaddr = localaddr4; } - result = dns_request_createvia( - requestmgr, soaquery, srcaddr, addr, -1, 0, NULL, - FIND_TIMEOUT * 20, FIND_TIMEOUT, 3, global_task, - recvsoa, reqinfo, &request); - check_result(result, "dns_request_createvia"); + result = dns_request_create(requestmgr, soaquery, srcaddr, addr, + -1, 0, NULL, FIND_TIMEOUT * 20, + FIND_TIMEOUT, 3, global_task, + recvsoa, reqinfo, &request); + check_result(result, "dns_request_create"); requests++; return; } @@ -2808,11 +2808,11 @@ sendrequest(isc_sockaddr_t *destaddr, dns_message_t *msg, srcaddr = localaddr4; } - result = dns_request_createvia(requestmgr, msg, srcaddr, destaddr, -1, - 0, default_servers ? NULL : tsigkey, - FIND_TIMEOUT * 20, FIND_TIMEOUT, 3, - global_task, recvsoa, reqinfo, request); - check_result(result, "dns_request_createvia"); + result = dns_request_create(requestmgr, msg, srcaddr, destaddr, -1, 0, + default_servers ? NULL : tsigkey, + FIND_TIMEOUT * 20, FIND_TIMEOUT, 3, + global_task, recvsoa, reqinfo, request); + check_result(result, "dns_request_create"); requests++; } @@ -3010,11 +3010,11 @@ send_gssrequest(isc_sockaddr_t *destaddr, dns_message_t *msg, srcaddr = localaddr4; } - result = dns_request_createvia(requestmgr, msg, srcaddr, destaddr, -1, - options, tsigkey, FIND_TIMEOUT * 20, - FIND_TIMEOUT, 3, global_task, recvgss, - reqinfo, request); - check_result(result, "dns_request_createvia"); + result = dns_request_create(requestmgr, msg, srcaddr, destaddr, -1, + options, tsigkey, FIND_TIMEOUT * 20, + FIND_TIMEOUT, 3, global_task, recvgss, + reqinfo, request); + check_result(result, "dns_request_create"); if (debugging) { show_message(stdout, msg, "Outgoing update query:"); } diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index e2f31df368..8003a390e8 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -169,10 +169,10 @@ sendquery(isc_task_t *task) { ISC_LIST_APPEND(qname->list, qrdataset, link); dns_message_addname(message, qname, DNS_SECTION_QUESTION); - result = dns_request_createvia(requestmgr, message, - have_src ? &srcaddr : NULL, &dstaddr, -1, - DNS_REQUESTOPT_TCP, NULL, TIMEOUT, 0, 0, - task, recvresponse, message, &request); + result = dns_request_create(requestmgr, message, + have_src ? &srcaddr : NULL, &dstaddr, -1, + DNS_REQUESTOPT_TCP, NULL, TIMEOUT, 0, 0, + task, recvresponse, message, &request); CHECK("dns_request_create", result); return (ISC_R_SUCCESS); diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index 7725704333..26f2aa7b13 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -178,9 +178,9 @@ sendquery(void *arg) { DNS_TSIG_HMACMD5_NAME, &nonce, 3600); CHECK("dns_tkey_builddhquery", result); - result = dns_request_create(requestmgr, query, &address, - DNS_REQUESTOPT_TCP, initialkey, TIMEOUT, - task, recvquery, query, &request); + result = dns_request_create(requestmgr, query, NULL, &address, -1, + DNS_REQUESTOPT_TCP, initialkey, TIMEOUT, 0, + 0, task, recvquery, query, &request); CHECK("dns_request_create", result); } diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index fc863bb906..a3083d755b 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -122,9 +122,9 @@ sendquery(void *arg) { result = dns_tkey_builddeletequery(query, tsigkey); CHECK("dns_tkey_builddeletequery", result); - result = dns_request_create(requestmgr, query, &address, - DNS_REQUESTOPT_TCP, tsigkey, TIMEOUT, task, - recvquery, query, &request); + result = dns_request_create(requestmgr, query, NULL, &address, -1, + DNS_REQUESTOPT_TCP, tsigkey, TIMEOUT, 0, 0, + task, recvquery, query, &request); CHECK("dns_request_create", result); } diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 1d28ea979f..df7bc22e32 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -754,12 +754,12 @@ sendquery(struct query *query) { options |= DNS_REQUESTOPT_TCP; } - result = dns_request_createvia( + result = dns_request_create( requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, dscp, options, NULL, query->timeout, query->udptimeout, query->udpretries, global_task, recvresponse, message, &request); - CHECK("dns_request_createvia", result); + CHECK("dns_request_create", result); return (ISC_R_SUCCESS); } diff --git a/lib/dns/include/dns/request.h b/lib/dns/include/dns/request.h index 342277c9f2..c454161a60 100644 --- a/lib/dns/include/dns/request.h +++ b/lib/dns/include/dns/request.h @@ -129,49 +129,13 @@ dns_requestmgr_detach(dns_requestmgr_t **requestmgrp); isc_result_t dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *address, unsigned int options, - dns_tsigkey_t *key, unsigned int timeout, isc_task_t *task, + const isc_sockaddr_t *srcaddr, + const isc_sockaddr_t *destaddr, isc_dscp_t dscp, + unsigned int options, dns_tsigkey_t *key, + unsigned int timeout, unsigned int udptimeout, + unsigned int udpretries, isc_task_t *task, isc_taskaction_t action, void *arg, dns_request_t **requestp); -/*%< - * Create and send a request. - * - * Notes: - * - *\li 'message' will be rendered and sent to 'address'. If the - * #DNS_REQUESTOPT_TCP option is set, TCP will be used, - * #DNS_REQUESTOPT_SHARE option is set too, connecting TCP - * (vs. connected) will be shared too. The request - * will timeout after 'timeout' seconds. - * - *\li If the #DNS_REQUESTOPT_CASE option is set, use case sensitive - * compression. - * - *\li When the request completes, successfully, due to a timeout, or - * because it was canceled, a completion event will be sent to 'task'. - * - * Requires: - * - *\li 'message' is a valid DNS message. - * - *\li 'address' is a valid sockaddr. - * - *\li 'timeout' > 0 - * - *\li 'task' is a valid task. - * - *\li requestp != NULL && *requestp == NULL - */ - -isc_result_t -dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, isc_dscp_t dscp, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp); /*%< * Create and send a request. * diff --git a/lib/dns/request.c b/lib/dns/request.c index 393fc330cf..9e78d5b9c7 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -571,24 +571,13 @@ cleanup: isc_result_t dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *address, unsigned int options, - dns_tsigkey_t *key, unsigned int timeout, isc_task_t *task, + const isc_sockaddr_t *srcaddr, + const isc_sockaddr_t *destaddr, isc_dscp_t dscp, + unsigned int options, dns_tsigkey_t *key, + unsigned int timeout, unsigned int udptimeout, + unsigned int udpretries, isc_task_t *task, isc_taskaction_t action, void *arg, dns_request_t **requestp) { - return (dns_request_createvia(requestmgr, message, NULL, address, -1, - options, key, timeout, 0, 0, task, action, - arg, requestp)); -} - -isc_result_t -dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, isc_dscp_t dscp, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp) { dns_request_t *request = NULL; isc_result_t result; isc_mem_t *mctx = NULL; @@ -606,7 +595,7 @@ dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message, mctx = requestmgr->mctx; - req_log(ISC_LOG_DEBUG(3), "dns_request_createvia"); + req_log(ISC_LOG_DEBUG(3), "dns_request_create"); if (atomic_load_acquire(&requestmgr->exiting)) { return (ISC_R_SHUTTINGDOWN); @@ -723,7 +712,7 @@ again: } } - req_log(ISC_LOG_DEBUG(3), "dns_request_createvia: request %p", request); + req_log(ISC_LOG_DEBUG(3), "dns_request_create: request %p", request); *requestp = request; return (ISC_R_SUCCESS); @@ -740,7 +729,7 @@ cleanup: isc_task_detach(&(isc_task_t *){ task }); /* final detach to shut down request */ req_detach(&request); - req_log(ISC_LOG_DEBUG(3), "dns_request_createvia: failed %s", + req_log(ISC_LOG_DEBUG(3), "dns_request_create: failed %s", isc_result_totext(result)); return (result); } @@ -966,7 +955,7 @@ req_connected(isc_result_t eresult, isc_region_t *region, void *arg) { } UNLOCK(&request->requestmgr->locks[request->hash]); - /* attached in dns_request_createvia/_createraw() */ + /* attached in dns_request_create/_createraw() */ req_detach(&(dns_request_t *){ request }); } diff --git a/lib/dns/zone.c b/lib/dns/zone.c index bcdd3ce720..08e140ca09 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -12788,10 +12788,10 @@ notify_send_toaddr(isc_task_t *task, isc_event_t *event) { if (DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_DIALNOTIFY)) { timeout = 30; } - result = dns_request_createvia( - notify->zone->view->requestmgr, message, &src, ¬ify->dst, - dscp, options, key, timeout * 3, timeout, 2, notify->zone->task, - notify_done, notify, ¬ify->request); + result = dns_request_create(notify->zone->view->requestmgr, message, + &src, ¬ify->dst, dscp, options, key, + timeout * 3, timeout, 2, notify->zone->task, + notify_done, notify, ¬ify->request); if (result == ISC_R_SUCCESS) { if (isc_sockaddr_pf(¬ify->dst) == AF_INET) { inc_stats(notify->zone, @@ -13496,7 +13496,7 @@ stub_request_nameserver_address(struct stub_cb_args *args, bool ipv4, atomic_fetch_add_release(&args->stub->pending_requests, 1); - result = dns_request_createvia( + result = dns_request_create( zone->view->requestmgr, message, &zone->sourceaddr, &zone->primaryaddr, args->dscp, DNS_REQUESTOPT_TCP, args->tsig_key, args->timeout * 3, args->timeout, 2, zone->task, @@ -13507,7 +13507,7 @@ stub_request_nameserver_address(struct stub_cb_args *args, bool ipv4, pr = atomic_fetch_sub_release(&args->stub->pending_requests, 1); INSIST(pr > 1); zone_debuglog(zone, __func__, 1, - "dns_request_createvia() failed: %s", + "dns_request_create() failed: %s", isc_result_totext(result)); goto fail; } @@ -14739,14 +14739,14 @@ again: if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH)) { timeout = 30; } - result = dns_request_createvia( + result = dns_request_create( zone->view->requestmgr, message, &zone->sourceaddr, &zone->primaryaddr, dscp, options, key, timeout * 3, timeout, 2, zone->task, refresh_callback, zone, &zone->request); if (result != ISC_R_SUCCESS) { zone_idetach(&dummy); zone_debuglog(zone, __func__, 1, - "dns_request_createvia() failed: %s", + "dns_request_create() failed: %s", isc_result_totext(result)); goto skip_primary; } else { @@ -15024,13 +15024,13 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) { cb_args->timeout = timeout; cb_args->reqnsid = reqnsid; - result = dns_request_createvia( + result = dns_request_create( zone->view->requestmgr, message, &zone->sourceaddr, &zone->primaryaddr, dscp, DNS_REQUESTOPT_TCP, key, timeout * 3, timeout, 2, zone->task, stub_callback, cb_args, &zone->request); if (result != ISC_R_SUCCESS) { zone_debuglog(zone, __func__, 1, - "dns_request_createvia() failed: %s", + "dns_request_create() failed: %s", isc_result_totext(result)); goto cleanup; } @@ -21215,15 +21215,14 @@ checkds_send_toaddr(isc_task_t *task, isc_event_t *event) { timeout = 15; options |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia( + result = dns_request_create( checkds->zone->view->requestmgr, message, &src, &checkds->dst, dscp, options, key, timeout * 3, timeout, 2, checkds->zone->task, checkds_done, checkds, &checkds->request); if (result != ISC_R_SUCCESS) { - dns_zone_log( - checkds->zone, ISC_LOG_DEBUG(3), - "checkds: dns_request_createvia() to %s failed: %s", - addrbuf, isc_result_totext(result)); + dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3), + "checkds: dns_request_create() to %s failed: %s", + addrbuf, isc_result_totext(result)); } cleanup_key: