]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
TCP and TLS DNS tests: properly pass connection callback
authorArtem Boldariev <artem@boldariev.com>
Wed, 26 Oct 2022 12:17:54 +0000 (15:17 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 1 Nov 2022 12:42:08 +0000 (14:42 +0200)
After the loop manager refactoring TCP DNS and TLS DNS unit tests
ended up broken.

The problem is that in these unit tests the code is written in such a
way that for establishing a new connection tcpdns_connect() and
tlsdns_connect() functions are used. However, in these tests as a
connection callback function connect_connect_cb() is used. The
function logic is responsible for determining the function for
establishing subsequent connection.

To do so, it called get_stream_connect_function() ... which can return
only tcp_connect() or tls_connect(), not tcpdns_connect() or
tlsdns_connect(). That is definitely *not* what was implied.

All this time the unit tests were testing something, but now what was
intended.

This commit fixes the problem by passing the tcpdns_connect() and
tlsdns_connect() function pointers to connect_connect_cb().

tests/isc/netmgr_common.c
tests/isc/tcpdns_test.c
tests/isc/tlsdns_test.c

index 3d57d940d0c0c3cf441474a71ef7226421295fdf..2324555a6a26adf7ef83d01d33d1d5b3c6718ebf 100644 (file)
@@ -354,8 +354,6 @@ void
 connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
        isc_nmhandle_t *readhandle = NULL;
 
-       UNUSED(cbarg);
-
        F();
 
        isc_refcount_decrement(&active_cconnects);
@@ -369,7 +367,8 @@ connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
                do_cconnects_shutdown(loopmgr);
        } else if (do_send) {
                isc_job_run(loopmgr, stream_recv_send_connect,
-                           get_stream_connect_function());
+                           (cbarg == NULL ? get_stream_connect_function()
+                                          : (stream_connect_function)cbarg));
        }
 
        isc_refcount_increment0(&active_creads);
index 4a66629e0c2c5c255e26e9028aefb2a79ea7b805..43b75a70a3877b1e384a7c20e55dc0095ab897ba 100644 (file)
@@ -61,7 +61,7 @@ start_listening(uint32_t nworkers, isc_nm_accept_cb_t accept_cb,
 static void
 tcpdns_connect(isc_nm_t *nm) {
        isc_nm_tcpdnsconnect(nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_connect_cb, NULL, T_CONNECT);
+                            connect_connect_cb, tcpdns_connect, T_CONNECT);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_noop) {
@@ -70,7 +70,7 @@ ISC_LOOP_TEST_IMPL(tcpdns_noop) {
        connect_readcb = NULL;
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tcpdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_success_cb, NULL, T_CONNECT);
+                            connect_success_cb, tcpdns_connect, T_CONNECT);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_noresponse) {
@@ -78,7 +78,7 @@ ISC_LOOP_TEST_IMPL(tcpdns_noresponse) {
 
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tcpdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_connect_cb, NULL, T_CONNECT);
+                            connect_connect_cb, tcpdns_connect, T_CONNECT);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_timeout_recovery) {
index 2dbc3d532e647327bf3d9fc6ebcb3cd4f1d77cff..61b7fca51fc29107b7f7a69758347e27aaf0886f 100644 (file)
@@ -60,7 +60,7 @@ start_listening(uint32_t nworkers, isc_nm_accept_cb_t accept_cb,
 static void
 tlsdns_connect(isc_nm_t *nm) {
        isc_nm_tlsdnsconnect(nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_connect_cb, NULL, T_CONNECT,
+                            connect_connect_cb, tlsdns_connect, T_CONNECT,
                             tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache);
 }
 
@@ -70,7 +70,7 @@ ISC_LOOP_TEST_IMPL(tlsdns_noop) {
        connect_readcb = NULL;
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tlsdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_success_cb, NULL, T_CONNECT,
+                            connect_success_cb, tlsdns_connect, T_CONNECT,
                             tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache);
 }
 
@@ -79,7 +79,7 @@ ISC_LOOP_TEST_IMPL(tlsdns_noresponse) {
 
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tlsdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_connect_cb, NULL, T_CONNECT,
+                            connect_connect_cb, tlsdns_connect, T_CONNECT,
                             tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache);
 }
 
@@ -100,7 +100,7 @@ ISC_LOOP_TEST_IMPL(tlsdns_timeout_recovery) {
        isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tlsdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
-                            connect_connect_cb, NULL, T_SOFT,
+                            connect_connect_cb, tlsdns_connect, T_SOFT,
                             tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache);
 }