2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Separate the single setter/getter functions for TCP timeouts

Previously all kinds of TCP timeouts had a single getter and setter
functions. Separate each timeout to its own getter/setter functions,
because in majority of cases only one is required at a time, and it's
not optimal expanding those functions every time a new timeout value
is implemented.
This commit is contained in:
Aram Sargsyan 2025-03-11 12:10:51 +00:00 committed by Arаm Sаrgsyаn
parent 797d865121
commit 74a8acdc8d
17 changed files with 232 additions and 118 deletions

View File

@ -2096,14 +2096,11 @@ sendquery(void *arg) {
dns_view_attach(view, &(dns_view_t *){ NULL }); dns_view_attach(view, &(dns_view_t *){ NULL });
uint32_t initial; const unsigned int timeout = isc_nm_getinitialtimeout(netmgr);
isc_nm_gettimeouts(netmgr, &initial, NULL, NULL, NULL, NULL);
const unsigned int connect_timeout = initial, timeout = initial;
CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL, CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL,
DNS_REQUESTOPT_TCP, NULL, connect_timeout, DNS_REQUESTOPT_TCP, NULL, timeout, timeout, 0,
timeout, 0, 0, isc_loop(), recvresponse, 0, isc_loop(), recvresponse, message,
message, &request)); &request));
return; return;
cleanup: cleanup:

View File

@ -8244,8 +8244,11 @@ load_configuration(const char *filename, named_server_t *server,
primaries = MIN_PRIMARIES_TIMEOUT; primaries = MIN_PRIMARIES_TIMEOUT;
} }
isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive, advertised, isc_nm_setinitialtimeout(named_g_netmgr, initial);
primaries); isc_nm_setprimariestimeout(named_g_netmgr, primaries);
isc_nm_setidletimeout(named_g_netmgr, idle);
isc_nm_setkeepalivetimeout(named_g_netmgr, keepalive);
isc_nm_setadvertisedtimeout(named_g_netmgr, advertised);
#define CAP_IF_NOT_ZERO(v, min, max) \ #define CAP_IF_NOT_ZERO(v, min, max) \
if (v > 0 && v < min) { \ if (v > 0 && v < min) { \
@ -15769,8 +15772,11 @@ named_server_tcptimeouts(isc_lex_t *lex, isc_buffer_t **text) {
return ISC_R_UNEXPECTEDEND; return ISC_R_UNEXPECTEDEND;
} }
isc_nm_gettimeouts(named_g_netmgr, &initial, &idle, &keepalive, initial = isc_nm_getinitialtimeout(named_g_netmgr);
&advertised, &primaries); primaries = isc_nm_getprimariestimeout(named_g_netmgr);
idle = isc_nm_getidletimeout(named_g_netmgr);
keepalive = isc_nm_getkeepalivetimeout(named_g_netmgr);
advertised = isc_nm_getadvertisedtimeout(named_g_netmgr);
/* Look for optional arguments. */ /* Look for optional arguments. */
ptr = next_token(lex, NULL); ptr = next_token(lex, NULL);
@ -15833,8 +15839,11 @@ named_server_tcptimeouts(isc_lex_t *lex, isc_buffer_t **text) {
CHECK(ISC_R_RANGE); CHECK(ISC_R_RANGE);
} }
isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive, isc_nm_setinitialtimeout(named_g_netmgr, initial);
advertised, primaries); isc_nm_setprimariestimeout(named_g_netmgr, primaries);
isc_nm_setidletimeout(named_g_netmgr, idle);
isc_nm_setkeepalivetimeout(named_g_netmgr, keepalive);
isc_nm_setadvertisedtimeout(named_g_netmgr, advertised);
} }
snprintf(msg, sizeof(msg), "tcp-initial-timeout=%u\n", initial / 100); snprintf(msg, sizeof(msg), "tcp-initial-timeout=%u\n", initial / 100);

View File

@ -3506,7 +3506,7 @@ getinput(void *arg) {
int int
main(int argc, char **argv) { main(int argc, char **argv) {
uint32_t timeoutms; const uint32_t timeoutms = timeout * MS_PER_SEC;
style = &dns_master_style_debug; style = &dns_master_style_debug;
@ -3531,9 +3531,11 @@ main(int argc, char **argv) {
parse_args(argc, argv); parse_args(argc, argv);
/* Set the network manager timeouts in milliseconds. */ /* Set the network manager timeouts in milliseconds. */
timeoutms = timeout * 1000; isc_nm_setinitialtimeout(netmgr, timeoutms);
isc_nm_settimeouts(netmgr, timeoutms, timeoutms, timeoutms, timeoutms, isc_nm_setprimariestimeout(netmgr, timeoutms);
timeoutms); isc_nm_setidletimeout(netmgr, timeoutms);
isc_nm_setkeepalivetimeout(netmgr, timeoutms);
isc_nm_setadvertisedtimeout(netmgr, timeoutms);
isc_loopmgr_setup(loopmgr, setup_system, NULL); isc_loopmgr_setup(loopmgr, setup_system, NULL);
isc_loopmgr_setup(loopmgr, getinput, NULL); isc_loopmgr_setup(loopmgr, getinput, NULL);

View File

@ -966,7 +966,10 @@ main(int argc, char **argv) {
isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr); isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr);
isc_loopmgr_setup(loopmgr, rndc_start, NULL); isc_loopmgr_setup(loopmgr, rndc_start, NULL);
isc_nm_settimeouts(netmgr, timeout, timeout, timeout, 0, timeout); isc_nm_setinitialtimeout(netmgr, timeout);
isc_nm_setprimariestimeout(netmgr, timeout);
isc_nm_setidletimeout(netmgr, timeout);
isc_nm_setkeepalivetimeout(netmgr, timeout);
logconfig = isc_logconfig_get(); logconfig = isc_logconfig_get();
isc_log_settag(logconfig, progname); isc_log_settag(logconfig, progname);

View File

@ -1313,8 +1313,8 @@ xfrin_start(dns_xfrin_t *xfr) {
goto failure; goto failure;
} }
isc_nm_gettimeouts(dns_dispatchmgr_getnetmgr(dispmgr), NULL, NULL, NULL, primaries_timeout =
NULL, &primaries_timeout); isc_nm_getprimariestimeout(dns_dispatchmgr_getnetmgr(dispmgr));
result = dns_dispatch_createtcp(dispmgr, &xfr->sourceaddr, result = dns_dispatch_createtcp(dispmgr, &xfr->sourceaddr,
&xfr->primaryaddr, xfr->transport, &xfr->primaryaddr, xfr->transport,
DNS_DISPATCHOPT_UNSHARED, &xfr->disp); DNS_DISPATCHOPT_UNSHARED, &xfr->disp);

View File

@ -12729,11 +12729,6 @@ notify_send_toaddr(void *arg) {
goto cleanup_key; goto cleanup_key;
} }
uint32_t initial_timeout;
isc_nm_gettimeouts(notify->zone->zmgr->netmgr, &initial_timeout, NULL,
NULL, NULL, NULL);
const unsigned int connect_timeout = initial_timeout / MS_PER_SEC;
again: again:
if ((notify->flags & DNS_NOTIFY_TCP) != 0) { if ((notify->flags & DNS_NOTIFY_TCP) != 0) {
options |= DNS_REQUESTOPT_TCP; options |= DNS_REQUESTOPT_TCP;
@ -12741,6 +12736,9 @@ again:
zmgr_tlsctx_attach(notify->zone->zmgr, &zmgr_tlsctx_cache); zmgr_tlsctx_attach(notify->zone->zmgr, &zmgr_tlsctx_cache);
const unsigned int connect_timeout =
isc_nm_getinitialtimeout(notify->zone->zmgr->netmgr) /
MS_PER_SEC;
result = dns_request_create( result = dns_request_create(
notify->zone->view->requestmgr, message, &src, &notify->dst, notify->zone->view->requestmgr, message, &src, &notify->dst,
notify->transport, zmgr_tlsctx_cache, options, key, notify->transport, zmgr_tlsctx_cache, options, key,
@ -14641,12 +14639,9 @@ again:
} }
} }
uint32_t primaries_timeout;
isc_nm_gettimeouts(zone->zmgr->netmgr, NULL, NULL, NULL, NULL,
&primaries_timeout);
const unsigned int connect_timeout = primaries_timeout / MS_PER_SEC;
zone_iattach(zone, &(dns_zone_t *){ NULL }); zone_iattach(zone, &(dns_zone_t *){ NULL });
const unsigned int connect_timeout =
isc_nm_getprimariestimeout(zone->zmgr->netmgr) / MS_PER_SEC;
result = dns_request_create( result = dns_request_create(
zone->view->requestmgr, message, &zone->sourceaddr, &curraddr, zone->view->requestmgr, message, &zone->sourceaddr, &curraddr,
NULL, NULL, options, key, connect_timeout, TCP_REQUEST_TIMEOUT, NULL, NULL, options, key, connect_timeout, TCP_REQUEST_TIMEOUT,
@ -14912,11 +14907,6 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
goto cleanup; goto cleanup;
} }
uint32_t primaries_timeout;
isc_nm_gettimeouts(zone->zmgr->netmgr, NULL, NULL, NULL, NULL,
&primaries_timeout);
const unsigned int connect_timeout = primaries_timeout / MS_PER_SEC;
/* /*
* Save request parameters so we can reuse them later on * Save request parameters so we can reuse them later on
* for resolving missing glue A/AAAA records. * for resolving missing glue A/AAAA records.
@ -14925,14 +14915,15 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
cb_args->stub = stub; cb_args->stub = stub;
cb_args->tsig_key = key; cb_args->tsig_key = key;
cb_args->udpsize = udpsize; cb_args->udpsize = udpsize;
cb_args->connect_timeout = connect_timeout; cb_args->connect_timeout =
isc_nm_getprimariestimeout(zone->zmgr->netmgr) / MS_PER_SEC;
cb_args->timeout = TCP_REQUEST_TIMEOUT; cb_args->timeout = TCP_REQUEST_TIMEOUT;
cb_args->reqnsid = reqnsid; cb_args->reqnsid = reqnsid;
result = dns_request_create( result = dns_request_create(
zone->view->requestmgr, message, &zone->sourceaddr, &curraddr, zone->view->requestmgr, message, &zone->sourceaddr, &curraddr,
NULL, NULL, DNS_REQUESTOPT_TCP, key, connect_timeout, NULL, NULL, DNS_REQUESTOPT_TCP, key, cb_args->connect_timeout,
TCP_REQUEST_TIMEOUT, UDP_REQUEST_TIMEOUT, UDP_REQUEST_RETRIES, cb_args->timeout, UDP_REQUEST_TIMEOUT, UDP_REQUEST_RETRIES,
zone->loop, stub_callback, cb_args, &zone->request); zone->loop, stub_callback, cb_args, &zone->request);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
zone_debuglog(zone, __func__, 1, zone_debuglog(zone, __func__, 1,
@ -18779,13 +18770,9 @@ next:
} }
} }
uint32_t primaries_timeout;
isc_nm_gettimeouts(zone->zmgr->netmgr, NULL, NULL, NULL, NULL,
&primaries_timeout);
const unsigned int connect_timeout = primaries_timeout / MS_PER_SEC;
zmgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache); zmgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache);
const unsigned int connect_timeout =
isc_nm_getprimariestimeout(zone->zmgr->netmgr) / MS_PER_SEC;
result = dns_request_createraw( result = dns_request_createraw(
forward->zone->view->requestmgr, forward->msgbuf, &src, forward->zone->view->requestmgr, forward->msgbuf, &src,
&forward->addr, forward->transport, zmgr_tlsctx_cache, &forward->addr, forward->transport, zmgr_tlsctx_cache,
@ -21442,12 +21429,10 @@ checkds_send_toaddr(void *arg) {
dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3), dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
"checkds: create request for DS query to %s", addrbuf); "checkds: create request for DS query to %s", addrbuf);
uint32_t initial_timeout;
isc_nm_gettimeouts(checkds->zone->zmgr->netmgr, &initial_timeout, NULL,
NULL, NULL, NULL);
const unsigned int connect_timeout = initial_timeout / MS_PER_SEC;
options |= DNS_REQUESTOPT_TCP; options |= DNS_REQUESTOPT_TCP;
const unsigned int connect_timeout =
isc_nm_getinitialtimeout(checkds->zone->zmgr->netmgr) /
MS_PER_SEC;
result = dns_request_create( result = dns_request_create(
checkds->zone->view->requestmgr, message, &src, &checkds->dst, checkds->zone->view->requestmgr, message, &src, &checkds->dst,
NULL, NULL, options, key, connect_timeout, TCP_REQUEST_TIMEOUT, NULL, NULL, options, key, connect_timeout, TCP_REQUEST_TIMEOUT,

View File

@ -536,13 +536,46 @@ isc_nm_proxyheader_info_init_complete(isc_nm_proxyheader_info_t *restrict info,
*/ */
void void
isc_nm_settimeouts(isc_nm_t *mgr, uint32_t init, uint32_t idle, isc_nm_setinitialtimeout(isc_nm_t *mgr, uint32_t timeout_ms);
uint32_t keepalive, uint32_t advertised, uint32_t primaries);
/*%< /*%<
* Sets the initial, idle, keepalive, advertised, and primaries timeout values * Sets the initial TCP timeout value (in milliseconds).
* (in milliseconds) to use for TCP connections, and the timeout value to *
* advertise in responses using the EDNS TCP Keepalive option (which should * Requires:
* ordinarily be the same as 'keepalive'), in milliseconds. * \li 'mgr' is a valid netmgr.
*/
void
isc_nm_setprimariestimeout(isc_nm_t *mgr, uint32_t timeout_ms);
/*%<
* Sets the primary servers connect TCP timeout value (in milliseconds).
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
void
isc_nm_setidletimeout(isc_nm_t *mgr, uint32_t timeout_ms);
/*%<
* Sets the idle TCP timeout value (in milliseconds).
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
void
isc_nm_setkeepalivetimeout(isc_nm_t *mgr, uint32_t timeout_ms);
/*%<
* Sets the keepalive TCP timeout value (in milliseconds), and the timeout value
* to advertise in responses using the EDNS TCP Keepalive option.
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
void
isc_nm_setadvertisedtimeout(isc_nm_t *mgr, uint32_t timeout_ms);
/*%<
* Sets the advertised TCP timeout value (in milliseconds).
* *
* Requires: * Requires:
* \li 'mgr' is a valid netmgr. * \li 'mgr' is a valid netmgr.
@ -570,16 +603,46 @@ isc_nm_setloadbalancesockets(isc_nm_t *mgr, bool enabled);
* \li 'mgr' is a valid netmgr. * \li 'mgr' is a valid netmgr.
*/ */
void uint32_t
isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle, isc_nm_getinitialtimeout(isc_nm_t *mgr);
uint32_t *keepalive, uint32_t *advertised,
uint32_t *primaries);
/*%< /*%<
* Gets the initial, idle, keepalive, advertised, or primaries timeout values, * Gets the initial TCP timeout value in milliseconds.
* in milliseconds.
* *
* Any integer pointer parameter not set to NULL will be updated to * Requires:
* contain the corresponding timeout value. * \li 'mgr' is a valid netmgr.
*/
uint32_t
isc_nm_getprimariestimeout(isc_nm_t *mgr);
/*%<
* Gets the primary servers connect TCP timeout value in milliseconds.
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
uint32_t
isc_nm_getidletimeout(isc_nm_t *mgr);
/*%<
* Gets the idle TCP timeout value in milliseconds.
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
uint32_t
isc_nm_getkeepalivetimeout(isc_nm_t *mgr);
/*%<
* Gets the keepalive TCP timeout value in milliseconds.
*
* Requires:
* \li 'mgr' is a valid netmgr.
*/
uint32_t
isc_nm_getadvertisedtimeout(isc_nm_t *mgr);
/*%<
* Gets the advertised TCP timeout value in milliseconds.
* *
* Requires: * Requires:
* \li 'mgr' is a valid netmgr. * \li 'mgr' is a valid netmgr.

View File

@ -338,16 +338,38 @@ isc_nmhandle_setwritetimeout(isc_nmhandle_t *handle, uint64_t write_timeout) {
} }
void void
isc_nm_settimeouts(isc_nm_t *mgr, uint32_t init, uint32_t idle, isc_nm_setinitialtimeout(isc_nm_t *mgr, uint32_t timeout_ms) {
uint32_t keepalive, uint32_t advertised,
uint32_t primaries) {
REQUIRE(VALID_NM(mgr)); REQUIRE(VALID_NM(mgr));
atomic_store_relaxed(&mgr->init, init); atomic_store_relaxed(&mgr->init, timeout_ms);
atomic_store_relaxed(&mgr->idle, idle); }
atomic_store_relaxed(&mgr->keepalive, keepalive);
atomic_store_relaxed(&mgr->advertised, advertised); void
atomic_store_relaxed(&mgr->primaries, primaries); isc_nm_setprimariestimeout(isc_nm_t *mgr, uint32_t timeout_ms) {
REQUIRE(VALID_NM(mgr));
atomic_store_relaxed(&mgr->primaries, timeout_ms);
}
void
isc_nm_setidletimeout(isc_nm_t *mgr, uint32_t timeout_ms) {
REQUIRE(VALID_NM(mgr));
atomic_store_relaxed(&mgr->idle, timeout_ms);
}
void
isc_nm_setkeepalivetimeout(isc_nm_t *mgr, uint32_t timeout_ms) {
REQUIRE(VALID_NM(mgr));
atomic_store_relaxed(&mgr->keepalive, timeout_ms);
}
void
isc_nm_setadvertisedtimeout(isc_nm_t *mgr, uint32_t timeout_ms) {
REQUIRE(VALID_NM(mgr));
atomic_store_relaxed(&mgr->advertised, timeout_ms);
} }
void void
@ -377,21 +399,39 @@ isc_nm_setloadbalancesockets(isc_nm_t *mgr, ISC_ATTR_UNUSED bool enabled) {
#endif #endif
} }
void uint32_t
isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle, isc_nm_getinitialtimeout(isc_nm_t *mgr) {
uint32_t *keepalive, uint32_t *advertised,
uint32_t *primaries) {
REQUIRE(VALID_NM(mgr)); REQUIRE(VALID_NM(mgr));
SET_IF_NOT_NULL(initial, atomic_load_relaxed(&mgr->init)); return atomic_load_relaxed(&mgr->init);
}
SET_IF_NOT_NULL(idle, atomic_load_relaxed(&mgr->idle)); uint32_t
isc_nm_getprimariestimeout(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
SET_IF_NOT_NULL(keepalive, atomic_load_relaxed(&mgr->keepalive)); return atomic_load_relaxed(&mgr->primaries);
}
SET_IF_NOT_NULL(advertised, atomic_load_relaxed(&mgr->advertised)); uint32_t
isc_nm_getidletimeout(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
SET_IF_NOT_NULL(primaries, atomic_load_relaxed(&mgr->primaries)); return atomic_load_relaxed(&mgr->idle);
}
uint32_t
isc_nm_getkeepalivetimeout(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
return atomic_load_relaxed(&mgr->keepalive);
}
uint32_t
isc_nm_getadvertisedtimeout(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
return atomic_load_relaxed(&mgr->advertised);
} }
bool bool

View File

@ -241,10 +241,7 @@ proxystream_sock_new(isc__networker_t *worker, const isc_nmsocket_type_t type,
isc__nmsocket_init(sock, worker, type, addr, NULL); isc__nmsocket_init(sock, worker, type, addr, NULL);
sock->result = ISC_R_UNSET; sock->result = ISC_R_UNSET;
if (type == isc_nm_proxystreamsocket) { if (type == isc_nm_proxystreamsocket) {
uint32_t initial = 0; sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr);
isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL,
NULL);
sock->read_timeout = initial;
sock->client = !is_server; sock->client = !is_server;
sock->connecting = !is_server; sock->connecting = !is_server;
if (is_server) { if (is_server) {

View File

@ -213,10 +213,7 @@ proxyudp_sock_new(isc__networker_t *worker, const isc_nmsocket_type_t type,
isc__nmsocket_init(sock, worker, type, addr, NULL); isc__nmsocket_init(sock, worker, type, addr, NULL);
sock->result = ISC_R_UNSET; sock->result = ISC_R_UNSET;
if (type == isc_nm_proxyudpsocket) { if (type == isc_nm_proxyudpsocket) {
uint32_t initial = 0; sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr);
isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL,
NULL);
sock->read_timeout = initial;
sock->client = !is_server; sock->client = !is_server;
sock->connecting = !is_server; sock->connecting = !is_server;
if (!is_server) { if (!is_server) {

View File

@ -271,10 +271,7 @@ streamdns_sock_new(isc__networker_t *worker, const isc_nmsocket_type_t type,
isc__nmsocket_init(sock, worker, type, addr, NULL); isc__nmsocket_init(sock, worker, type, addr, NULL);
sock->result = ISC_R_UNSET; sock->result = ISC_R_UNSET;
if (type == isc_nm_streamdnssocket) { if (type == isc_nm_streamdnssocket) {
uint32_t initial = 0; sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr);
isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL,
NULL);
sock->read_timeout = initial;
sock->client = !is_server; sock->client = !is_server;
sock->connecting = !is_server; sock->connecting = !is_server;
sock->streamdns.input = isc_dnsstream_assembler_new( sock->streamdns.input = isc_dnsstream_assembler_new(
@ -704,7 +701,6 @@ streamdns_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
isc_nmsocket_t *nsock; isc_nmsocket_t *nsock;
isc_sockaddr_t iface; isc_sockaddr_t iface;
int tid = isc_tid(); int tid = isc_tid();
uint32_t initial = 0;
REQUIRE(VALID_NMHANDLE(handle)); REQUIRE(VALID_NMHANDLE(handle));
REQUIRE(VALID_NMSOCK(handle->sock)); REQUIRE(VALID_NMSOCK(handle->sock));
@ -726,9 +722,8 @@ streamdns_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
nsock->peer = isc_nmhandle_peeraddr(handle); nsock->peer = isc_nmhandle_peeraddr(handle);
nsock->tid = tid; nsock->tid = tid;
isc_nm_gettimeouts(handle->sock->worker->netmgr, &initial, NULL, NULL, nsock->read_timeout =
NULL, NULL); isc_nm_getinitialtimeout(handle->sock->worker->netmgr);
nsock->read_timeout = initial;
nsock->accepting = true; nsock->accepting = true;
nsock->active = true; nsock->active = true;
@ -752,10 +747,10 @@ streamdns_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
nsock->closehandle_cb = streamdns_resume_processing; nsock->closehandle_cb = streamdns_resume_processing;
isc__nmhandle_set_manual_timer(nsock->outerhandle, true); isc__nmhandle_set_manual_timer(nsock->outerhandle, true);
isc_nm_gettimeouts(nsock->worker->netmgr, &initial, NULL, NULL, NULL,
NULL);
/* settimeout restarts the timer */ /* settimeout restarts the timer */
isc_nmhandle_settimeout(nsock->outerhandle, initial); isc_nmhandle_settimeout(
nsock->outerhandle,
isc_nm_getinitialtimeout(nsock->worker->netmgr));
(void)isc_nmhandle_set_tcp_nodelay(nsock->outerhandle, true); (void)isc_nmhandle_set_tcp_nodelay(nsock->outerhandle, true);
streamdns_handle_incoming_data(nsock, nsock->outerhandle, NULL, 0); streamdns_handle_incoming_data(nsock, nsock->outerhandle, NULL, 0);

View File

@ -1178,15 +1178,14 @@ no_nsid:
} }
if (TCP_CLIENT(client) && USEKEEPALIVE(client)) { if (TCP_CLIENT(client) && USEKEEPALIVE(client)) {
isc_buffer_t buf; isc_buffer_t buf;
uint32_t adv; uint32_t advertised_timeout = isc_nm_getadvertisedtimeout(
isc_nmhandle_netmgr(client->handle));
INSIST(count < DNS_EDNSOPTIONS); INSIST(count < DNS_EDNSOPTIONS);
isc_nm_gettimeouts(isc_nmhandle_netmgr(client->handle), NULL, advertised_timeout /= 100; /* units of 100 milliseconds */
NULL, NULL, &adv, NULL);
adv /= 100; /* units of 100 milliseconds */
isc_buffer_init(&buf, advtimo, sizeof(advtimo)); isc_buffer_init(&buf, advtimo, sizeof(advtimo));
isc_buffer_putuint16(&buf, (uint16_t)adv); isc_buffer_putuint16(&buf, (uint16_t)advertised_timeout);
ednsopts[count].code = DNS_OPT_TCP_KEEPALIVE; ednsopts[count].code = DNS_OPT_TCP_KEEPALIVE;
ednsopts[count].length = 2; ednsopts[count].length = 2;
ednsopts[count].value = advtimo; ednsopts[count].value = advtimo;

View File

@ -195,17 +195,21 @@ setup_test(void **state) {
} }
close(socket); close(socket);
isc_nm_settimeouts(netmgr, T_SERVER_INIT, T_SERVER_IDLE, isc_nm_setinitialtimeout(netmgr, T_SERVER_INIT);
T_SERVER_KEEPALIVE, T_SERVER_ADVERTISED, isc_nm_setprimariestimeout(netmgr, T_SERVER_PRIMARIES);
T_SERVER_PRIMARIES); isc_nm_setidletimeout(netmgr, T_SERVER_IDLE);
isc_nm_setkeepalivetimeout(netmgr, T_SERVER_KEEPALIVE);
isc_nm_setadvertisedtimeout(netmgr, T_SERVER_ADVERTISED);
/* /*
* Use shorter client-side timeouts, to ensure that clients * Use shorter client-side timeouts, to ensure that clients
* time out before the server. * time out before the server.
*/ */
isc_nm_settimeouts(connect_nm, T_CLIENT_INIT, T_CLIENT_IDLE, isc_nm_setinitialtimeout(connect_nm, T_CLIENT_INIT);
T_CLIENT_KEEPALIVE, T_CLIENT_ADVERTISED, isc_nm_setprimariestimeout(connect_nm, T_CLIENT_PRIMARIES);
T_CLIENT_PRIMARIES); isc_nm_setidletimeout(connect_nm, T_CLIENT_IDLE);
isc_nm_setkeepalivetimeout(connect_nm, T_CLIENT_KEEPALIVE);
isc_nm_setadvertisedtimeout(connect_nm, T_CLIENT_ADVERTISED);
memset(testdata.rbuf, 0, sizeof(testdata.rbuf)); memset(testdata.rbuf, 0, sizeof(testdata.rbuf));
testdata.region.base = testdata.rbuf; testdata.region.base = testdata.rbuf;

View File

@ -693,7 +693,11 @@ doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) {
* Shorten all the TCP client timeouts to 0.05 seconds. * Shorten all the TCP client timeouts to 0.05 seconds.
* timeout_retry_cb() will give up after five timeouts. * timeout_retry_cb() will give up after five timeouts.
*/ */
isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT, T_SOFT); isc_nm_setinitialtimeout(connect_nm, T_SOFT);
isc_nm_setprimariestimeout(connect_nm, T_SOFT);
isc_nm_setidletimeout(connect_nm, T_SOFT);
isc_nm_setkeepalivetimeout(connect_nm, T_SOFT);
isc_nm_setadvertisedtimeout(connect_nm, T_SOFT);
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url), sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
ISC_NM_HTTP_DEFAULT_PATH); ISC_NM_HTTP_DEFAULT_PATH);
isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url, isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url,

View File

@ -178,13 +178,19 @@ setup_netmgr_test(void **state) {
setup_loopmgr(state); setup_loopmgr(state);
isc_netmgr_create(mctx, loopmgr, &listen_nm); isc_netmgr_create(mctx, loopmgr, &listen_nm);
assert_non_null(listen_nm); assert_non_null(listen_nm);
isc_nm_settimeouts(listen_nm, T_INIT, T_IDLE, T_KEEPALIVE, T_ADVERTISED, isc_nm_setinitialtimeout(listen_nm, T_INIT);
T_PRIMARIES); isc_nm_setprimariestimeout(listen_nm, T_PRIMARIES);
isc_nm_setidletimeout(listen_nm, T_IDLE);
isc_nm_setkeepalivetimeout(listen_nm, T_KEEPALIVE);
isc_nm_setadvertisedtimeout(listen_nm, T_ADVERTISED);
isc_netmgr_create(mctx, loopmgr, &connect_nm); isc_netmgr_create(mctx, loopmgr, &connect_nm);
assert_non_null(connect_nm); assert_non_null(connect_nm);
isc_nm_settimeouts(connect_nm, T_INIT, T_IDLE, T_KEEPALIVE, isc_nm_setinitialtimeout(connect_nm, T_INIT);
T_ADVERTISED, T_PRIMARIES); isc_nm_setprimariestimeout(connect_nm, T_PRIMARIES);
isc_nm_setidletimeout(connect_nm, T_IDLE);
isc_nm_setkeepalivetimeout(connect_nm, T_KEEPALIVE);
isc_nm_setadvertisedtimeout(connect_nm, T_ADVERTISED);
isc_quota_init(&listener_quota, 0); isc_quota_init(&listener_quota, 0);
atomic_store(&check_listener_quota, false); atomic_store(&check_listener_quota, false);
@ -1026,7 +1032,11 @@ stream_timeout_recovery(void **state ISC_ATTR_UNUSED) {
/* /*
* Shorten all the client timeouts to 0.05 seconds. * Shorten all the client timeouts to 0.05 seconds.
*/ */
isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT, T_SOFT); isc_nm_setinitialtimeout(connect_nm, T_SOFT);
isc_nm_setprimariestimeout(connect_nm, T_SOFT);
isc_nm_setidletimeout(connect_nm, T_SOFT);
isc_nm_setkeepalivetimeout(connect_nm, T_SOFT);
isc_nm_setadvertisedtimeout(connect_nm, T_SOFT);
connect_readcb = timeout_retry_cb; connect_readcb = timeout_retry_cb;
stream_connect(connect_connect_cb, NULL, T_CONNECT); stream_connect(connect_connect_cb, NULL, T_CONNECT);
} }

View File

@ -100,7 +100,11 @@ ISC_LOOP_TEST_IMPL(tcpdns_timeout_recovery) {
* timeout_retry_cb() will give up after five timeouts. * timeout_retry_cb() will give up after five timeouts.
*/ */
connect_readcb = timeout_retry_cb; connect_readcb = timeout_retry_cb;
isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT, T_SOFT); isc_nm_setinitialtimeout(connect_nm, T_SOFT);
isc_nm_setprimariestimeout(connect_nm, T_SOFT);
isc_nm_setidletimeout(connect_nm, T_SOFT);
isc_nm_setkeepalivetimeout(connect_nm, T_SOFT);
isc_nm_setadvertisedtimeout(connect_nm, T_SOFT);
isc_async_current(stream_recv_send_connect, tcpdns_connect); isc_async_current(stream_recv_send_connect, tcpdns_connect);
} }

View File

@ -105,7 +105,12 @@ ISC_LOOP_TEST_IMPL(tlsdns_timeout_recovery) {
* timeout_retry_cb() will give up after five timeouts. * timeout_retry_cb() will give up after five timeouts.
*/ */
connect_readcb = timeout_retry_cb; connect_readcb = timeout_retry_cb;
isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT, T_SOFT); isc_nm_setinitialtimeout(connect_nm, T_SOFT);
isc_nm_setprimariestimeout(connect_nm, T_SOFT);
isc_nm_setidletimeout(connect_nm, T_SOFT);
isc_nm_setkeepalivetimeout(connect_nm, T_SOFT);
isc_nm_setadvertisedtimeout(connect_nm, T_SOFT);
isc_refcount_increment0(&active_cconnects); isc_refcount_increment0(&active_cconnects);
isc_nm_streamdnsconnect( isc_nm_streamdnsconnect(
connect_nm, &tcp_connect_addr, &tcp_listen_addr, connect_nm, &tcp_connect_addr, &tcp_listen_addr,