From a46ded25b681525270148dcea4ea6970b6e9092a Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Wed, 30 Oct 2019 17:21:25 +0000 Subject: [PATCH] Implement enabling and checking for TCP Fast Open. --- CMakeLists.txt | 22 +++++++++++++++++++++- cmake/include/cmakeconfig.h.in | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3b7cf94..3cbb833b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,8 @@ option(ENABLE_DRAFT_MDNS_SUPPORT "Enable draft mdns client support.") option(ENABLE_EDNS_COOKIES "Enable EDNS cookies." ON) option(ENABLE_NATIVE_STUB_DNSSEC "Enable native stub DNSSEC support." ON) option(ENABLE_POLL_EVENTLOOP "Enable default eventloop based on poll." ON) -option(ENABLE_STUB_ONLY "Restricts resolution modes to STUB." ON) +option(ENABLE_STUB_ONLY "Restrict resolution modes to STUB." ON) +option(ENABLE_TCP_FAST_OPEN "Enable use of TCP Fast Open." ON) option(ENABLE_UNBOUND_EVENT_API "Enable usage of libunbound's event API." ON) option(BUILD_GETDNS_QUERY "Compile and install the getdns_query tool." ON) @@ -478,6 +479,25 @@ if (HAVE_STRPTIME) check_c_source_runs("${STRPTIME_TEST_SOURCE}" STRPTIME_WORKS) endif () +# TCP Fast Open. +if (NOT ENABLE_TCP_FAST_OPEN) + message(WARNING "TCP Fast Open disabled.") +else () + if (APPLE AND HAVE_SYS_SOCKET_H) + check_symbol_exists(CONNECT_RESUME_ON_READ_WRITE "sys/socket.h" USE_OSX_TCP_FASTOPEN) + if (NOT USE_OSX_TCP_FASTOPEN) + message(WARNING "TCP Fast Open not available, continuing without.") + endif () + else () + check_symbol_exists(TCP_FASTOPEN "sys/socket.h;netinet/tcp.h" HAVE_DECL_TCP_FASTOPEN) + check_symbol_exists(TCP_FASTOPEN_CONNECT "sys/socket.h;netinet/tcp.h" HAVE_DECL_TCP_FASTOPEN_CONNECT) + check_symbol_exists(MSG_FASTOPEN "sys/socket.h;netinet/tcp.h" HAVE_DECL_MSG_FASTOPEN) + if (NOT TCP_FASTOPEN) + message(WARNING "TCP Fast Open not available, continuing without.") + endif () + endif () +endif () + # Main library add_library(getdns_objects OBJECT src/anchor.c diff --git a/cmake/include/cmakeconfig.h.in b/cmake/include/cmakeconfig.h.in index f07d9d45..20f8c05b 100644 --- a/cmake/include/cmakeconfig.h.in +++ b/cmake/include/cmakeconfig.h.in @@ -127,6 +127,10 @@ #cmakedefine HAVE_DECL_SIGADDSET 1 #cmakedefine HAVE_DECL_STRPTIME 1 +#cmakedefine USE_DECL_TCP_FASTOPEN 1 +#cmakedefine USE_DECL_TCP_FASTOPEN_CONNECT 1 +#cmakedefine USE_DECL_MSG_FASTOPEN 1 + #if defined(HAVE_DECL_INET_PTON) || defined(HAVE_WIN_DECL_INET_PTON) #undef HAVE_DECL_INET_PTON #define HAVE_DECL_INET_PTON 1 @@ -201,6 +205,8 @@ #cmakedefine USE_ED25519 1 #cmakedefine USE_ED448 1 +#cmakedefine USE_OSX_TCP_FASTOPEN 1 + #cmakedefine HAVE_TARGET_ENDIANNESS #cmakedefine TARGET_IS_BIG_ENDIAN