From 913d7fe7e1fc53b4827427fcf3719c96bbaf2c35 Mon Sep 17 00:00:00 2001 From: Otto Date: Fri, 12 Nov 2021 13:19:47 +0100 Subject: [PATCH] Disable the actual connect() in the test_dnsdisttcp_cc_c unit tests. They are not needed and cause (at least on OpenBSD) firewall state table clashes: they remain in a embryotic state because no actual activity occurs on them due to the rest of the tests using mockup code. tcpiohandler.cc is not linked into the tests, so define it locally in test-dnsdisttcp_cc.cc as well. --- pdns/dnsdistdist/test-dnsdisttcp_cc.cc | 2 ++ pdns/tcpiohandler.cc | 3 +++ pdns/tcpiohandler.hh | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc index 9884fdbba1..1fbb00e9ce 100644 --- a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc +++ b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc @@ -41,6 +41,8 @@ GlobalStateHolder g_dstates; QueryCount g_qcount; +const bool TCPIOHandler::s_disableConnectForUnitTests = true; + bool checkDNSCryptQuery(const ClientState& cs, PacketBuffer& query, std::unique_ptr& dnsCryptQuery, time_t now, bool tcp) { return false; diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index 4338f315c8..6068c1bc84 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -5,6 +5,8 @@ #include "lock.hh" #include "tcpiohandler.hh" +const bool TCPIOHandler::s_disableConnectForUnitTests = false; + #ifdef HAVE_LIBSODIUM #include #endif /* HAVE_LIBSODIUM */ @@ -20,6 +22,7 @@ #include "libssl.hh" + class OpenSSLFrontendContext { public: diff --git a/pdns/tcpiohandler.hh b/pdns/tcpiohandler.hh index 7afbef1ffe..5b23e00dc3 100644 --- a/pdns/tcpiohandler.hh +++ b/pdns/tcpiohandler.hh @@ -288,10 +288,14 @@ public: d_fastOpen = true; } else { - SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0}); + if (!s_disableConnectForUnitTests) { + SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0}); + } } #else - SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0}); + if (!s_disableConnectForUnitTests) { + SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0}); + } #endif /* MSG_FASTOPEN */ if (d_conn) { @@ -320,10 +324,14 @@ public: d_fastOpen = true; } else { - SConnectWithTimeout(d_socket, remote, timeout); + if (!s_disableConnectForUnitTests) { + SConnectWithTimeout(d_socket, remote, timeout); + } } #else - SConnectWithTimeout(d_socket, remote, timeout); + if (!s_disableConnectForUnitTests) { + SConnectWithTimeout(d_socket, remote, timeout); + } #endif /* MSG_FASTOPEN */ if (d_conn) { @@ -539,6 +547,8 @@ public: return d_conn->isUsable(); } + const static bool s_disableConnectForUnitTests; + private: std::unique_ptr d_conn{nullptr}; ComboAddress d_remote; -- 2.47.2