mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
Simplify dns_dispatchmgr_create with fixed buffersize
- UDP buffersize is now established when creating dispatch manager and is always set to 4096. - Set up the default port range in dispatchmgr before setting the magic number. - Magic is not set until dispatchmgr is fully created.
This commit is contained in:
parent
57fce0e895
commit
ca11f68d61
@ -1334,9 +1334,9 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af,
|
||||
}
|
||||
|
||||
disp = NULL;
|
||||
result = dns_dispatch_getudp(
|
||||
named_g_dispatchmgr, named_g_socketmgr, named_g_taskmgr, &sa,
|
||||
4096, maxdispatchbuffers, 32768, 16411, 16433, attrs, &disp);
|
||||
result = dns_dispatch_getudp(named_g_dispatchmgr, named_g_socketmgr,
|
||||
named_g_taskmgr, &sa, maxdispatchbuffers,
|
||||
32768, 16411, 16433, attrs, &disp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_sockaddr_t any;
|
||||
char buf[ISC_SOCKADDR_FORMATSIZE];
|
||||
@ -10394,7 +10394,7 @@ named_add_reserved_dispatch(named_server_t *server,
|
||||
}
|
||||
|
||||
result = dns_dispatch_getudp(named_g_dispatchmgr, named_g_socketmgr,
|
||||
named_g_taskmgr, &dispatch->addr, 4096,
|
||||
named_g_taskmgr, &dispatch->addr,
|
||||
UDPBUFFERS, 32768, 16411, 16433, attrs,
|
||||
&dispatch->dispatch);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
@ -97,7 +97,6 @@
|
||||
|
||||
#define MAXCMD (128 * 1024)
|
||||
#define MAXWIRE (64 * 1024)
|
||||
#define PACKETSIZE ((64 * 1024) - 1)
|
||||
#define INITTEXT (2 * 1024)
|
||||
#define MAXTEXT (128 * 1024)
|
||||
#define FIND_TIMEOUT 5
|
||||
@ -943,8 +942,8 @@ setup_system(void) {
|
||||
attrs |= DNS_DISPATCHATTR_IPV6;
|
||||
isc_sockaddr_any6(&bind_any6);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
&bind_any6, PACKETSIZE, 4, 2, 3, 5,
|
||||
attrs, &dispatchv6);
|
||||
&bind_any6, 4, 2, 3, 5, attrs,
|
||||
&dispatchv6);
|
||||
check_result(result, "dns_dispatch_getudp (v6)");
|
||||
}
|
||||
|
||||
@ -954,8 +953,8 @@ setup_system(void) {
|
||||
attrs |= DNS_DISPATCHATTR_IPV4;
|
||||
isc_sockaddr_any(&bind_any);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
&bind_any, PACKETSIZE, 4, 2, 3, 5,
|
||||
attrs, &dispatchv4);
|
||||
&bind_any, 4, 2, 3, 5, attrs,
|
||||
&dispatchv4);
|
||||
check_result(result, "dns_dispatch_getudp (v4)");
|
||||
}
|
||||
|
||||
|
@ -286,8 +286,8 @@ main(int argc, char *argv[]) {
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
have_src ? &srcaddr : &bind_any, 4096, 4,
|
||||
2, 3, 5, attrs, &dispatchv4));
|
||||
have_src ? &srcaddr : &bind_any, 4, 2, 3,
|
||||
5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
@ -245,7 +245,7 @@ main(int argc, char *argv[]) {
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
|
||||
4096, 4, 2, 3, 5, attrs, &dispatchv4));
|
||||
4, 2, 3, 5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
@ -188,7 +188,7 @@ main(int argc, char **argv) {
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
|
||||
4096, 4, 2, 3, 5, attrs, &dispatchv4));
|
||||
4, 2, 3, 5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
@ -759,7 +759,7 @@ sendquery(struct query *query, isc_task_t *task) {
|
||||
requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, dscp,
|
||||
options, NULL, query->timeout, query->udptimeout,
|
||||
query->udpretries, task, recvresponse, message, &request);
|
||||
CHECK("dns_request_createvia4", result);
|
||||
CHECK("dns_request_createvia", result);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@ -2141,8 +2141,8 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
dispatchvx = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
have_src ? &srcaddr : &bind_any, 4096, 100,
|
||||
100, 17, 19, attrs, &dispatchvx));
|
||||
have_src ? &srcaddr : &bind_any, 100, 100,
|
||||
17, 19, attrs, &dispatchvx));
|
||||
RUNCHECK(dns_requestmgr_create(
|
||||
mctx, timermgr, socketmgr, taskmgr, dispatchmgr,
|
||||
have_ipv4 ? dispatchvx : NULL, have_ipv6 ? dispatchvx : NULL,
|
||||
|
@ -207,7 +207,7 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
const isc_sockaddr_t *localaddr) {
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *disp;
|
||||
unsigned buffersize, maxbuffers, maxrequests, buckets, increment;
|
||||
unsigned maxbuffers, maxrequests, buckets, increment;
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t anyaddr;
|
||||
|
||||
@ -230,7 +230,6 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
localaddr = &anyaddr;
|
||||
}
|
||||
|
||||
buffersize = 4096;
|
||||
maxbuffers = is_shared ? 1000 : 8;
|
||||
maxrequests = 32768;
|
||||
buckets = is_shared ? 16411 : 3;
|
||||
@ -238,8 +237,8 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
|
||||
disp = NULL;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, localaddr,
|
||||
buffersize, maxbuffers, maxrequests,
|
||||
buckets, increment, attrs, &disp);
|
||||
maxbuffers, maxrequests, buckets,
|
||||
increment, attrs, &disp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
*dispp = disp;
|
||||
}
|
||||
|
@ -139,6 +139,13 @@ struct dns_dispentry {
|
||||
#define DNS_DISPATCH_SOCKSQUOTA 3072
|
||||
#endif /* ifndef DNS_DISPATCH_SOCKSQUOTA */
|
||||
|
||||
/*%
|
||||
* Fixed UDP buffer size.
|
||||
*/
|
||||
#ifndef DNS_DISPATCH_UDPBUFSIZE
|
||||
#define DNS_DISPATCH_UDPBUFSIZE 4096
|
||||
#endif /* ifndef DNS_DISPATCH_UDPBUFSIZE */
|
||||
|
||||
struct dispsocket {
|
||||
unsigned int magic;
|
||||
isc_socket_t *socket;
|
||||
@ -587,7 +594,6 @@ new_portentry(dns_dispatch_t *disp, in_port_t port) {
|
||||
REQUIRE(disp->port_table != NULL);
|
||||
|
||||
portentry = isc_mem_get(disp->mgr->mctx, sizeof(*portentry));
|
||||
|
||||
portentry->port = port;
|
||||
isc_refcount_init(&portentry->refs, 1);
|
||||
ISC_LINK_INIT(portentry, link);
|
||||
@ -730,10 +736,6 @@ get_dispsocket(dns_dispatch_t *disp, const isc_sockaddr_t *dest,
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (portentry == NULL) {
|
||||
portentry = new_portentry(disp, port);
|
||||
if (portentry == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
isc_refcount_increment(&portentry->refs);
|
||||
}
|
||||
@ -794,7 +796,6 @@ destroy_dispsocket(dns_dispatch_t *disp, dispsocket_t **dispsockp) {
|
||||
disp->nsockets--;
|
||||
dispsock->magic = 0;
|
||||
if (dispsock->portentry != NULL) {
|
||||
/* socket_search() tests and dereferences portentry. */
|
||||
LOCK(&qid->lock);
|
||||
deref_portentry(disp, &dispsock->portentry);
|
||||
UNLOCK(&qid->lock);
|
||||
@ -833,7 +834,7 @@ deactivate_dispsocket(dns_dispatch_t *disp, dispsocket_t *dispsock) {
|
||||
}
|
||||
|
||||
INSIST(dispsock->portentry != NULL);
|
||||
/* socket_search() tests and dereferences portentry. */
|
||||
|
||||
LOCK(&qid->lock);
|
||||
deref_portentry(disp, &dispsock->portentry);
|
||||
UNLOCK(&qid->lock);
|
||||
@ -890,8 +891,7 @@ entry_search(dns_qid_t *qid, const isc_sockaddr_t *dest, dns_messageid_t id,
|
||||
|
||||
static void
|
||||
free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
unsigned int buffersize;
|
||||
INSIST(buf != NULL && len != 0);
|
||||
REQUIRE(buf != NULL && len != 0);
|
||||
|
||||
switch (disp->socktype) {
|
||||
case isc_sockettype_tcp:
|
||||
@ -902,11 +902,10 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
case isc_sockettype_udp:
|
||||
LOCK(&disp->mgr->buffer_lock);
|
||||
INSIST(disp->mgr->buffers > 0);
|
||||
INSIST(len == disp->mgr->buffersize);
|
||||
INSIST(len == DNS_DISPATCH_UDPBUFSIZE);
|
||||
disp->mgr->buffers--;
|
||||
buffersize = disp->mgr->buffersize;
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
isc_mem_put(disp->mgr->mctx, buf, buffersize);
|
||||
isc_mem_put(disp->mgr->mctx, buf, len);
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
@ -916,18 +915,15 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
|
||||
static void *
|
||||
allocate_udp_buffer(dns_dispatch_t *disp) {
|
||||
unsigned int buffersize;
|
||||
|
||||
LOCK(&disp->mgr->buffer_lock);
|
||||
if (disp->mgr->buffers >= disp->mgr->maxbuffers) {
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
return (NULL);
|
||||
}
|
||||
buffersize = disp->mgr->buffersize;
|
||||
disp->mgr->buffers++;
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
|
||||
return (isc_mem_get(disp->mgr->mctx, buffersize));
|
||||
return (isc_mem_get(disp->mgr->mctx, DNS_DISPATCH_UDPBUFSIZE));
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -1520,7 +1516,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) {
|
||||
* UDP reads are always maximal.
|
||||
*/
|
||||
case isc_sockettype_udp:
|
||||
region.length = disp->mgr->buffersize;
|
||||
region.length = DNS_DISPATCH_UDPBUFSIZE;
|
||||
region.base = allocate_udp_buffer(disp);
|
||||
if (region.base == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
@ -1699,98 +1695,17 @@ open_socket(isc_socketmgr_t *mgr, const isc_sockaddr_t *local,
|
||||
* normally set the ports explicitly, but is provided to fill some minor corner
|
||||
* cases.
|
||||
*/
|
||||
static isc_result_t
|
||||
static void
|
||||
create_default_portset(isc_mem_t *mctx, isc_portset_t **portsetp) {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_portset_create(mctx, portsetp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
isc_portset_create(mctx, portsetp);
|
||||
isc_portset_addrange(*portsetp, 1024, 65535);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Publics.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp) {
|
||||
dns_dispatchmgr_t *mgr;
|
||||
isc_result_t result;
|
||||
isc_portset_t *v4portset = NULL;
|
||||
isc_portset_t *v6portset = NULL;
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(mgrp != NULL && *mgrp == NULL);
|
||||
|
||||
mgr = isc_mem_get(mctx, sizeof(dns_dispatchmgr_t));
|
||||
*mgr = (dns_dispatchmgr_t){ 0 };
|
||||
|
||||
isc_mem_attach(mctx, &mgr->mctx);
|
||||
|
||||
isc_mutex_init(&mgr->lock);
|
||||
isc_mutex_init(&mgr->buffer_lock);
|
||||
|
||||
isc_refcount_init(&mgr->irefs, 0);
|
||||
|
||||
ISC_LIST_INIT(mgr->list);
|
||||
|
||||
mgr->magic = DNS_DISPATCHMGR_MAGIC;
|
||||
|
||||
result = create_default_portset(mctx, &v4portset);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = create_default_portset(mctx, &v6portset);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = dns_dispatchmgr_setavailports(mgr, v4portset,
|
||||
v6portset);
|
||||
}
|
||||
}
|
||||
if (v4portset != NULL) {
|
||||
isc_portset_destroy(mctx, &v4portset);
|
||||
}
|
||||
if (v6portset != NULL) {
|
||||
isc_portset_destroy(mctx, &v6portset);
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto kill_dpool;
|
||||
}
|
||||
|
||||
*mgrp = mgr;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
kill_dpool:
|
||||
isc_mutex_destroy(&mgr->buffer_lock);
|
||||
isc_mutex_destroy(&mgr->lock);
|
||||
isc_mem_putanddetach(&mctx, mgr, sizeof(dns_dispatchmgr_t));
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
dns_dispatchmgr_setblackhole(dns_dispatchmgr_t *mgr, dns_acl_t *blackhole) {
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
if (mgr->blackhole != NULL) {
|
||||
dns_acl_detach(&mgr->blackhole);
|
||||
}
|
||||
dns_acl_attach(blackhole, &mgr->blackhole);
|
||||
}
|
||||
|
||||
dns_acl_t *
|
||||
dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr) {
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
return (mgr->blackhole);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
|
||||
isc_portset_t *v6portset) {
|
||||
in_port_t *v4ports, *v6ports, p;
|
||||
unsigned int nv4ports, nv6ports, i4, i6;
|
||||
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
static isc_result_t
|
||||
setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
|
||||
isc_portset_t *v6portset) {
|
||||
in_port_t *v4ports, *v6ports, p = 0;
|
||||
unsigned int nv4ports, nv6ports, i4 = 0, i6 = 0;
|
||||
|
||||
nv4ports = isc_portset_nports(v4portset);
|
||||
nv6ports = isc_portset_nports(v6portset);
|
||||
@ -1804,9 +1719,6 @@ dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
|
||||
v6ports = isc_mem_get(mgr->mctx, sizeof(in_port_t) * nv6ports);
|
||||
}
|
||||
|
||||
p = 0;
|
||||
i4 = 0;
|
||||
i6 = 0;
|
||||
do {
|
||||
if (isc_portset_isset(v4portset, p)) {
|
||||
INSIST(i4 < nv4ports);
|
||||
@ -1838,14 +1750,74 @@ dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Publics.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp) {
|
||||
dns_dispatchmgr_t *mgr = NULL;
|
||||
isc_portset_t *v4portset = NULL;
|
||||
isc_portset_t *v6portset = NULL;
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(mgrp != NULL && *mgrp == NULL);
|
||||
|
||||
mgr = isc_mem_get(mctx, sizeof(dns_dispatchmgr_t));
|
||||
*mgr = (dns_dispatchmgr_t){ .maxbuffers = 20000 };
|
||||
|
||||
isc_mem_attach(mctx, &mgr->mctx);
|
||||
|
||||
isc_mutex_init(&mgr->lock);
|
||||
isc_mutex_init(&mgr->buffer_lock);
|
||||
|
||||
isc_refcount_init(&mgr->irefs, 0);
|
||||
|
||||
ISC_LIST_INIT(mgr->list);
|
||||
|
||||
create_default_portset(mctx, &v4portset);
|
||||
create_default_portset(mctx, &v6portset);
|
||||
|
||||
setavailports(mgr, v4portset, v6portset);
|
||||
|
||||
isc_portset_destroy(mctx, &v4portset);
|
||||
isc_portset_destroy(mctx, &v6portset);
|
||||
|
||||
mgr->magic = DNS_DISPATCHMGR_MAGIC;
|
||||
|
||||
*mgrp = mgr;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
dns_dispatchmgr_setblackhole(dns_dispatchmgr_t *mgr, dns_acl_t *blackhole) {
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
if (mgr->blackhole != NULL) {
|
||||
dns_acl_detach(&mgr->blackhole);
|
||||
}
|
||||
dns_acl_attach(blackhole, &mgr->blackhole);
|
||||
}
|
||||
|
||||
dns_acl_t *
|
||||
dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr) {
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
return (mgr->blackhole);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
|
||||
isc_portset_t *v6portset) {
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
return (setavailports(mgr, v4portset, v6portset));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int buffersize,
|
||||
unsigned int maxbuffers, unsigned int maxrequests,
|
||||
unsigned int buckets, unsigned int increment) {
|
||||
dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment) {
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(VALID_DISPATCHMGR(mgr));
|
||||
REQUIRE(buffersize >= 512 && buffersize < (64 * 1024));
|
||||
REQUIRE(maxbuffers > 0);
|
||||
REQUIRE(buckets < 2097169); /* next prime > 65536 * 32 */
|
||||
REQUIRE(increment > buckets);
|
||||
@ -1868,31 +1840,29 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int buffersize,
|
||||
maxbuffers = 8;
|
||||
}
|
||||
|
||||
/* Adjust buffer pool if needed
|
||||
*
|
||||
* We only increase maxbuffers to avoid accidental buffer
|
||||
* shortage. Ideally we'd separate the manager-wide maximum
|
||||
* from per-dispatch limits and respect the latter within the
|
||||
* global limit. But at this moment that's deemed to be
|
||||
* overkilling and isn't worth additional implementation
|
||||
* complexity.
|
||||
*/
|
||||
LOCK(&mgr->buffer_lock);
|
||||
|
||||
if (maxbuffers > mgr->maxbuffers) {
|
||||
mgr->maxbuffers = maxbuffers;
|
||||
}
|
||||
|
||||
/* Create or adjust socket pool */
|
||||
if (mgr->qid != NULL) {
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
result = qid_allocate(mgr, buckets, increment, &mgr->qid, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mgr->buffersize = buffersize;
|
||||
mgr->maxbuffers = maxbuffers;
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
|
||||
if (mgr->qid == NULL) {
|
||||
result = qid_allocate(mgr, buckets, increment, &mgr->qid, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2351,10 +2321,9 @@ dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr,
|
||||
isc_result_t
|
||||
dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
dns_dispatch_t **dispp) {
|
||||
unsigned int maxbuffers, unsigned int maxrequests,
|
||||
unsigned int buckets, unsigned int increment,
|
||||
unsigned int attributes, dns_dispatch_t **dispp) {
|
||||
isc_result_t result;
|
||||
dns_dispatch_t *disp = NULL;
|
||||
|
||||
@ -2362,15 +2331,14 @@ dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
REQUIRE(sockmgr != NULL);
|
||||
REQUIRE(localaddr != NULL);
|
||||
REQUIRE(taskmgr != NULL);
|
||||
REQUIRE(buffersize >= 512 && buffersize < (64 * 1024));
|
||||
REQUIRE(maxbuffers > 0);
|
||||
REQUIRE(buckets < 2097169); /* next prime > 65536 * 32 */
|
||||
REQUIRE(increment > buckets);
|
||||
REQUIRE(dispp != NULL && *dispp == NULL);
|
||||
REQUIRE((attributes & DNS_DISPATCHATTR_TCP) == 0);
|
||||
|
||||
result = dns_dispatchmgr_setudp(mgr, buffersize, maxbuffers,
|
||||
maxrequests, buckets, increment);
|
||||
result = dispatchmgr_setudp(mgr, maxbuffers, maxrequests, buckets,
|
||||
increment);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
@ -139,7 +139,8 @@ struct dns_dispatchset {
|
||||
isc_result_t
|
||||
dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp);
|
||||
/*%<
|
||||
* Creates a new dispatchmgr object.
|
||||
* Creates a new dispatchmgr object, and sets the available ports
|
||||
* to the default range (1024-65535).
|
||||
*
|
||||
* Requires:
|
||||
*\li "mctx" be a valid memory context.
|
||||
@ -215,10 +216,9 @@ dns_dispatchmgr_setstats(dns_dispatchmgr_t *mgr, isc_stats_t *stats);
|
||||
isc_result_t
|
||||
dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
dns_dispatch_t **dispp);
|
||||
unsigned int maxbuffers, unsigned int maxrequests,
|
||||
unsigned int buckets, unsigned int increment,
|
||||
unsigned int attributes, dns_dispatch_t **dispp);
|
||||
/*%<
|
||||
* Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find,
|
||||
* otherwise create a new UDP dispatch.
|
||||
|
@ -630,8 +630,8 @@ find_udp_dispatch(dns_requestmgr_t *requestmgr, const isc_sockaddr_t *srcaddr,
|
||||
}
|
||||
return (dns_dispatch_getudp(requestmgr->dispatchmgr,
|
||||
requestmgr->socketmgr, requestmgr->taskmgr,
|
||||
srcaddr, 4096, 32768, 32768, 16411, 16433,
|
||||
attrs, dispatchp));
|
||||
srcaddr, 32768, 32768, 16411, 16433, attrs,
|
||||
dispatchp));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
@ -2175,7 +2175,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
}
|
||||
result = dns_dispatch_getudp(
|
||||
res->dispatchmgr, res->socketmgr, res->taskmgr,
|
||||
&addr, 4096, 20000, 32768, 16411, 16433, attrs,
|
||||
&addr, 20000, 32768, 16411, 16433, attrs,
|
||||
&query->dispatch);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_query;
|
||||
|
@ -76,8 +76,8 @@ make_dispatchset(unsigned int ndisps) {
|
||||
|
||||
isc_sockaddr_any(&any);
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &any, 512,
|
||||
6, 1024, 17, 19, attrs, &disp);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &any, 6,
|
||||
1024, 17, 19, attrs, &disp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
@ -274,8 +274,8 @@ dispatch_getnext(void **state) {
|
||||
ina.s_addr = htonl(INADDR_LOOPBACK);
|
||||
isc_sockaddr_fromin(&local, &ina, 0);
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local,
|
||||
512, 6, 1024, 17, 19, attrs, &dispatch);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local, 6,
|
||||
1024, 17, 19, attrs, &dispatch);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
@ -58,7 +58,7 @@ _setup(void **state) {
|
||||
|
||||
isc_sockaddr_any(&local);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local,
|
||||
4096, 100, 100, 100, 500, 0, &dispatch);
|
||||
100, 100, 100, 500, 0, &dispatch);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
return (0);
|
||||
|
@ -14603,8 +14603,7 @@ again:
|
||||
zone->task, refresh_callback, zone, &zone->request);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
zone_idetach(&dummy);
|
||||
zone_debuglog(zone, me, 1,
|
||||
"dns_request_createvia4() failed: %s",
|
||||
zone_debuglog(zone, me, 1, "dns_request_createvia() failed: %s",
|
||||
dns_result_totext(result));
|
||||
goto skip_master;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user