]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Separate the single setter/getter functions for TCP timeouts
authorAram Sargsyan <aram@isc.org>
Tue, 11 Mar 2025 12:10:51 +0000 (12:10 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Wed, 23 Apr 2025 17:03:05 +0000 (17:03 +0000)
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.

17 files changed:
bin/delv/delv.c
bin/named/server.c
bin/nsupdate/nsupdate.c
bin/rndc/rndc.c
lib/dns/xfrin.c
lib/dns/zone.c
lib/isc/include/isc/netmgr.h
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/proxystream.c
lib/isc/netmgr/proxyudp.c
lib/isc/netmgr/streamdns.c
lib/ns/client.c
tests/dns/dispatch_test.c
tests/isc/doh_test.c
tests/isc/netmgr_common.c
tests/isc/tcpdns_test.c
tests/isc/tlsdns_test.c

index 041254bb1a001ba14f9b8846bf1ddf3e610bb0c8..d7a5f477d0118636895eb0251cb0affcddce7695 100644 (file)
@@ -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:
index fa428f62d1e56d9ddc4fc5df229b6679947e9a6f..0b3e735285502d989cf77aa206b8eb2ef035bb97 100644 (file)
@@ -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);
index 9b087a0ad0079c53d50d73777af299f790d29a4f..51015dc065a4c7f36d18c7708ad84b59ee080f77 100644 (file)
@@ -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);
index 95a5f6a6cf4f8203664e86baf6018980f2e5bfb0..e7a04a24a5d4181cb7599c6277097e523e34bc11 100644 (file)
@@ -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);
index 243222b5e5eab477951dcfedd79ecba6b5f38b75..ca0f3d23ce1befdba4f66aa61c8eae8e8e28438e 100644 (file)
@@ -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);
index 593f34c22fc4134c674c96aa51b4388d549037ba..177608fa59db98bc3dbdf754f80a52e7f6fbb4da 100644 (file)
@@ -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, &notify->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,
index 3fff80d5c60fb95a4abb8db5bf983d6e0267c024..8825c8c77d6b01adf2a360cab725ceb808beb8f0 100644 (file)
@@ -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 TCP timeout value in milliseconds.
+ *
+ * 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 initial, idle, keepalive, advertised, or primaries timeout values,
- * in milliseconds.
+ * Gets the idle 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_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.
index 312c1a3a04fe34594b61d9e5b81bab3191551fc8..723f72c023baf98d27f9d36cfddaa15bc6a9087b 100644 (file)
@@ -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));
+
+       return atomic_load_relaxed(&mgr->init);
+}
+
+uint32_t
+isc_nm_getprimariestimeout(isc_nm_t *mgr) {
        REQUIRE(VALID_NM(mgr));
 
-       SET_IF_NOT_NULL(initial, atomic_load_relaxed(&mgr->init));
+       return atomic_load_relaxed(&mgr->primaries);
+}
+
+uint32_t
+isc_nm_getidletimeout(isc_nm_t *mgr) {
+       REQUIRE(VALID_NM(mgr));
+
+       return atomic_load_relaxed(&mgr->idle);
+}
 
-       SET_IF_NOT_NULL(idle, atomic_load_relaxed(&mgr->idle));
+uint32_t
+isc_nm_getkeepalivetimeout(isc_nm_t *mgr) {
+       REQUIRE(VALID_NM(mgr));
 
-       SET_IF_NOT_NULL(keepalive, atomic_load_relaxed(&mgr->keepalive));
+       return atomic_load_relaxed(&mgr->keepalive);
+}
 
-       SET_IF_NOT_NULL(advertised, atomic_load_relaxed(&mgr->advertised));
+uint32_t
+isc_nm_getadvertisedtimeout(isc_nm_t *mgr) {
+       REQUIRE(VALID_NM(mgr));
 
-       SET_IF_NOT_NULL(primaries, atomic_load_relaxed(&mgr->primaries));
+       return atomic_load_relaxed(&mgr->advertised);
 }
 
 bool
index 65bb9df42f833262ad39e0b01b250903dccbaf7e..bf2ca1feb9737506e0ecfe348b09650d13d7efde 100644 (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);
        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) {
index 6d4359264daaebeddfe56511e8227e50513a60e1..be575cea0d6da47cb96f42dfe364e15c3db2c49a 100644 (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);
        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) {
index 2a8007254f37d363615ddf7a92ebf38084602b36..a0bc22ed53200b13dcf35ff6255b9a208b0731b7 100644 (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);
        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);
 
index d5934c088338ca2d8f0beb7f9c7e2827d7281546..439a3168a4ba65a10455220f6a9f3d03e164088c 100644 (file)
@@ -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;
index 54ebd6f8dab3f5929e58646643c93ba74ffb237a..685d6a11c900331be15e5e1699983d4dc403c9e2 100644 (file)
@@ -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;
index 4b52b3ac365ed92161329c5e517bfdb19335a24a..2e07c6f6ad859046e10bb4023dbd871a5cbd1db8 100644 (file)
@@ -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,
index cc8d324aeb8bb61304a76527c451442be6d1cbe3..05c61d2d5d729e5052b359214c089846e5c29b76 100644 (file)
@@ -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);
 }
index 30ffdda463f8efa23cd7a7ce6dc33f8dd1377ff3..f0744aff6f4c7fdc12baf5b2eeeda123ca3fec97 100644 (file)
@@ -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);
 }
index 69acc31e6c0559fcee2baf7059d9946ebe7ab792..ae7e35507302361cd2886ce4b21e8bc1817e528f 100644 (file)
@@ -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,