diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 041254bb1a..d7a5f477d0 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -2096,14 +2096,11 @@ sendquery(void *arg) { dns_view_attach(view, &(dns_view_t *){ NULL }); - uint32_t initial; - isc_nm_gettimeouts(netmgr, &initial, NULL, NULL, NULL, NULL); - const unsigned int connect_timeout = initial, timeout = initial; - + const unsigned int timeout = isc_nm_getinitialtimeout(netmgr); CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL, - DNS_REQUESTOPT_TCP, NULL, connect_timeout, - timeout, 0, 0, isc_loop(), recvresponse, - message, &request)); + DNS_REQUESTOPT_TCP, NULL, timeout, timeout, 0, + 0, isc_loop(), recvresponse, message, + &request)); return; cleanup: diff --git a/bin/named/server.c b/bin/named/server.c index fa428f62d1..0b3e735285 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -8244,8 +8244,11 @@ load_configuration(const char *filename, named_server_t *server, primaries = MIN_PRIMARIES_TIMEOUT; } - isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive, advertised, - primaries); + isc_nm_setinitialtimeout(named_g_netmgr, initial); + 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) \ if (v > 0 && v < min) { \ @@ -15769,8 +15772,11 @@ named_server_tcptimeouts(isc_lex_t *lex, isc_buffer_t **text) { return ISC_R_UNEXPECTEDEND; } - isc_nm_gettimeouts(named_g_netmgr, &initial, &idle, &keepalive, - &advertised, &primaries); + initial = isc_nm_getinitialtimeout(named_g_netmgr); + 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. */ ptr = next_token(lex, NULL); @@ -15833,8 +15839,11 @@ named_server_tcptimeouts(isc_lex_t *lex, isc_buffer_t **text) { CHECK(ISC_R_RANGE); } - isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive, - advertised, primaries); + isc_nm_setinitialtimeout(named_g_netmgr, initial); + 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); diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 9b087a0ad0..51015dc065 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -3506,7 +3506,7 @@ getinput(void *arg) { int main(int argc, char **argv) { - uint32_t timeoutms; + const uint32_t timeoutms = timeout * MS_PER_SEC; style = &dns_master_style_debug; @@ -3531,9 +3531,11 @@ main(int argc, char **argv) { parse_args(argc, argv); /* Set the network manager timeouts in milliseconds. */ - timeoutms = timeout * 1000; - isc_nm_settimeouts(netmgr, timeoutms, timeoutms, timeoutms, timeoutms, - timeoutms); + isc_nm_setinitialtimeout(netmgr, timeoutms); + isc_nm_setprimariestimeout(netmgr, 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, getinput, NULL); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 95a5f6a6cf..e7a04a24a5 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -966,7 +966,10 @@ main(int argc, char **argv) { isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr); 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(); isc_log_settag(logconfig, progname); diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 243222b5e5..ca0f3d23ce 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1313,8 +1313,8 @@ xfrin_start(dns_xfrin_t *xfr) { goto failure; } - isc_nm_gettimeouts(dns_dispatchmgr_getnetmgr(dispmgr), NULL, NULL, NULL, - NULL, &primaries_timeout); + primaries_timeout = + isc_nm_getprimariestimeout(dns_dispatchmgr_getnetmgr(dispmgr)); result = dns_dispatch_createtcp(dispmgr, &xfr->sourceaddr, &xfr->primaryaddr, xfr->transport, DNS_DISPATCHOPT_UNSHARED, &xfr->disp); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 593f34c22f..177608fa59 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -12729,11 +12729,6 @@ notify_send_toaddr(void *arg) { 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: if ((notify->flags & DNS_NOTIFY_TCP) != 0) { options |= DNS_REQUESTOPT_TCP; @@ -12741,6 +12736,9 @@ again: 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( notify->zone->view->requestmgr, message, &src, ¬ify->dst, 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 }); + const unsigned int connect_timeout = + isc_nm_getprimariestimeout(zone->zmgr->netmgr) / MS_PER_SEC; result = dns_request_create( zone->view->requestmgr, message, &zone->sourceaddr, &curraddr, 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; } - 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 * 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->tsig_key = key; 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->reqnsid = reqnsid; result = dns_request_create( zone->view->requestmgr, message, &zone->sourceaddr, &curraddr, - NULL, NULL, DNS_REQUESTOPT_TCP, key, connect_timeout, - TCP_REQUEST_TIMEOUT, UDP_REQUEST_TIMEOUT, UDP_REQUEST_RETRIES, + NULL, NULL, DNS_REQUESTOPT_TCP, key, cb_args->connect_timeout, + cb_args->timeout, UDP_REQUEST_TIMEOUT, UDP_REQUEST_RETRIES, zone->loop, stub_callback, cb_args, &zone->request); if (result != ISC_R_SUCCESS) { 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); - + const unsigned int connect_timeout = + isc_nm_getprimariestimeout(zone->zmgr->netmgr) / MS_PER_SEC; result = dns_request_createraw( forward->zone->view->requestmgr, forward->msgbuf, &src, &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), "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; + const unsigned int connect_timeout = + isc_nm_getinitialtimeout(checkds->zone->zmgr->netmgr) / + MS_PER_SEC; result = dns_request_create( checkds->zone->view->requestmgr, message, &src, &checkds->dst, NULL, NULL, options, key, connect_timeout, TCP_REQUEST_TIMEOUT, diff --git a/lib/isc/include/isc/netmgr.h b/lib/isc/include/isc/netmgr.h index 3fff80d5c6..8825c8c77d 100644 --- a/lib/isc/include/isc/netmgr.h +++ b/lib/isc/include/isc/netmgr.h @@ -536,13 +536,46 @@ isc_nm_proxyheader_info_init_complete(isc_nm_proxyheader_info_t *restrict info, */ void -isc_nm_settimeouts(isc_nm_t *mgr, uint32_t init, uint32_t idle, - uint32_t keepalive, uint32_t advertised, uint32_t primaries); +isc_nm_setinitialtimeout(isc_nm_t *mgr, uint32_t timeout_ms); /*%< - * Sets the initial, idle, keepalive, advertised, and primaries timeout values - * (in milliseconds) to use for TCP connections, and the timeout value to - * advertise in responses using the EDNS TCP Keepalive option (which should - * ordinarily be the same as 'keepalive'), in milliseconds. + * Sets the initial TCP timeout value (in milliseconds). + * + * Requires: + * \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: * \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. */ -void -isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle, - uint32_t *keepalive, uint32_t *advertised, - uint32_t *primaries); +uint32_t +isc_nm_getinitialtimeout(isc_nm_t *mgr); /*%< - * Gets the initial, idle, keepalive, advertised, or primaries timeout values, - * in milliseconds. + * Gets the initial TCP timeout value in milliseconds. * - * Any integer pointer parameter not set to NULL will be updated to - * contain the corresponding timeout value. + * Requires: + * \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: * \li 'mgr' is a valid netmgr. diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 312c1a3a04..723f72c023 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -338,16 +338,38 @@ isc_nmhandle_setwritetimeout(isc_nmhandle_t *handle, uint64_t write_timeout) { } void -isc_nm_settimeouts(isc_nm_t *mgr, uint32_t init, uint32_t idle, - uint32_t keepalive, uint32_t advertised, - uint32_t primaries) { +isc_nm_setinitialtimeout(isc_nm_t *mgr, uint32_t timeout_ms) { REQUIRE(VALID_NM(mgr)); - atomic_store_relaxed(&mgr->init, init); - atomic_store_relaxed(&mgr->idle, idle); - atomic_store_relaxed(&mgr->keepalive, keepalive); - atomic_store_relaxed(&mgr->advertised, advertised); - atomic_store_relaxed(&mgr->primaries, primaries); + atomic_store_relaxed(&mgr->init, timeout_ms); +} + +void +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 @@ -377,21 +399,39 @@ isc_nm_setloadbalancesockets(isc_nm_t *mgr, ISC_ATTR_UNUSED bool enabled) { #endif } -void -isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle, - uint32_t *keepalive, uint32_t *advertised, - uint32_t *primaries) { +uint32_t +isc_nm_getinitialtimeout(isc_nm_t *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 diff --git a/lib/isc/netmgr/proxystream.c b/lib/isc/netmgr/proxystream.c index 65bb9df42f..bf2ca1feb9 100644 --- a/lib/isc/netmgr/proxystream.c +++ b/lib/isc/netmgr/proxystream.c @@ -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); sock->result = ISC_R_UNSET; if (type == isc_nm_proxystreamsocket) { - uint32_t initial = 0; - isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL, - NULL); - sock->read_timeout = initial; + sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr); sock->client = !is_server; sock->connecting = !is_server; if (is_server) { diff --git a/lib/isc/netmgr/proxyudp.c b/lib/isc/netmgr/proxyudp.c index 6d4359264d..be575cea0d 100644 --- a/lib/isc/netmgr/proxyudp.c +++ b/lib/isc/netmgr/proxyudp.c @@ -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); sock->result = ISC_R_UNSET; if (type == isc_nm_proxyudpsocket) { - uint32_t initial = 0; - isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL, - NULL); - sock->read_timeout = initial; + sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr); sock->client = !is_server; sock->connecting = !is_server; if (!is_server) { diff --git a/lib/isc/netmgr/streamdns.c b/lib/isc/netmgr/streamdns.c index 2a8007254f..a0bc22ed53 100644 --- a/lib/isc/netmgr/streamdns.c +++ b/lib/isc/netmgr/streamdns.c @@ -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); sock->result = ISC_R_UNSET; if (type == isc_nm_streamdnssocket) { - uint32_t initial = 0; - isc_nm_gettimeouts(worker->netmgr, &initial, NULL, NULL, NULL, - NULL); - sock->read_timeout = initial; + sock->read_timeout = isc_nm_getinitialtimeout(worker->netmgr); sock->client = !is_server; sock->connecting = !is_server; 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_sockaddr_t iface; int tid = isc_tid(); - uint32_t initial = 0; REQUIRE(VALID_NMHANDLE(handle)); 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->tid = tid; - isc_nm_gettimeouts(handle->sock->worker->netmgr, &initial, NULL, NULL, - NULL, NULL); - nsock->read_timeout = initial; + nsock->read_timeout = + isc_nm_getinitialtimeout(handle->sock->worker->netmgr); nsock->accepting = 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; isc__nmhandle_set_manual_timer(nsock->outerhandle, true); - isc_nm_gettimeouts(nsock->worker->netmgr, &initial, NULL, NULL, NULL, - NULL); /* 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); streamdns_handle_incoming_data(nsock, nsock->outerhandle, NULL, 0); diff --git a/lib/ns/client.c b/lib/ns/client.c index d5934c0883..439a3168a4 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1178,15 +1178,14 @@ no_nsid: } if (TCP_CLIENT(client) && USEKEEPALIVE(client)) { isc_buffer_t buf; - uint32_t adv; + uint32_t advertised_timeout = isc_nm_getadvertisedtimeout( + isc_nmhandle_netmgr(client->handle)); INSIST(count < DNS_EDNSOPTIONS); - isc_nm_gettimeouts(isc_nmhandle_netmgr(client->handle), NULL, - NULL, NULL, &adv, NULL); - adv /= 100; /* units of 100 milliseconds */ + advertised_timeout /= 100; /* units of 100 milliseconds */ 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].length = 2; ednsopts[count].value = advtimo; diff --git a/tests/dns/dispatch_test.c b/tests/dns/dispatch_test.c index 54ebd6f8da..685d6a11c9 100644 --- a/tests/dns/dispatch_test.c +++ b/tests/dns/dispatch_test.c @@ -195,17 +195,21 @@ setup_test(void **state) { } close(socket); - isc_nm_settimeouts(netmgr, T_SERVER_INIT, T_SERVER_IDLE, - T_SERVER_KEEPALIVE, T_SERVER_ADVERTISED, - T_SERVER_PRIMARIES); + isc_nm_setinitialtimeout(netmgr, T_SERVER_INIT); + isc_nm_setprimariestimeout(netmgr, 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 * time out before the server. */ - isc_nm_settimeouts(connect_nm, T_CLIENT_INIT, T_CLIENT_IDLE, - T_CLIENT_KEEPALIVE, T_CLIENT_ADVERTISED, - T_CLIENT_PRIMARIES); + isc_nm_setinitialtimeout(connect_nm, T_CLIENT_INIT); + isc_nm_setprimariestimeout(connect_nm, 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)); testdata.region.base = testdata.rbuf; diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index 4b52b3ac36..2e07c6f6ad 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -693,7 +693,11 @@ doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) { * Shorten all the TCP client timeouts to 0.05 seconds. * 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), ISC_NM_HTTP_DEFAULT_PATH); isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url, diff --git a/tests/isc/netmgr_common.c b/tests/isc/netmgr_common.c index cc8d324aeb..05c61d2d5d 100644 --- a/tests/isc/netmgr_common.c +++ b/tests/isc/netmgr_common.c @@ -178,13 +178,19 @@ setup_netmgr_test(void **state) { setup_loopmgr(state); isc_netmgr_create(mctx, loopmgr, &listen_nm); assert_non_null(listen_nm); - isc_nm_settimeouts(listen_nm, T_INIT, T_IDLE, T_KEEPALIVE, T_ADVERTISED, - T_PRIMARIES); + isc_nm_setinitialtimeout(listen_nm, T_INIT); + 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); assert_non_null(connect_nm); - isc_nm_settimeouts(connect_nm, T_INIT, T_IDLE, T_KEEPALIVE, - T_ADVERTISED, T_PRIMARIES); + isc_nm_setinitialtimeout(connect_nm, T_INIT); + 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); 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. */ - 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; stream_connect(connect_connect_cb, NULL, T_CONNECT); } diff --git a/tests/isc/tcpdns_test.c b/tests/isc/tcpdns_test.c index 30ffdda463..f0744aff6f 100644 --- a/tests/isc/tcpdns_test.c +++ b/tests/isc/tcpdns_test.c @@ -100,7 +100,11 @@ ISC_LOOP_TEST_IMPL(tcpdns_timeout_recovery) { * timeout_retry_cb() will give up after five timeouts. */ 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); } diff --git a/tests/isc/tlsdns_test.c b/tests/isc/tlsdns_test.c index 69acc31e6c..ae7e355073 100644 --- a/tests/isc/tlsdns_test.c +++ b/tests/isc/tlsdns_test.c @@ -105,7 +105,12 @@ ISC_LOOP_TEST_IMPL(tlsdns_timeout_recovery) { * timeout_retry_cb() will give up after five timeouts. */ 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_nm_streamdnsconnect( connect_nm, &tcp_connect_addr, &tcp_listen_addr,