diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a26ff83350..d0ca6a924f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ set(ENABLE_TPROXY 'X' where X is a number to use as the IP_TRANSPARENT sockopt, anything else to enable." ) +option(ENABLE_QUICHE "Use quiche (default OFF)") option(ENABLE_UNWIND "Use libunwind if found on system (default ON)" ON) option(ENABLE_WCCP "Use WCCP v2 (default OFF)") set(TS_MAX_HOST_NAME_LEN 256 CACHE STRING "Max host name length (default 256)") @@ -187,6 +188,19 @@ if(ENABLE_UNWIND) set(TS_USE_REMOTE_UNWINDING ${unwind_FOUND}) endif() +if(ENABLE_QUICHE) + find_package(quiche REQUIRED) + + set(TS_HAS_QUICHE ${quiche_FOUND}) + set(TS_USE_QUIC ${TS_HAS_QUICHE}) + + include(CheckOpenSSLIsBoringSSL) + check_openssl_is_boringssl(TS_HAVE_BORINGSSL "${OPENSSL_INCLUDE_DIR}") + if(NOT TS_HAVE_BORINGSSL) + message(FATAL_ERROR "Use of BoringSSL is required if quiche is used.") + endif() +endif() + find_package(ZLIB REQUIRED) include(Check128BitCas) diff --git a/cmake/CheckOpenSSLIsBoringSSL.cmake b/cmake/CheckOpenSSLIsBoringSSL.cmake new file mode 100644 index 00000000000..8d12c4702dd --- /dev/null +++ b/cmake/CheckOpenSSLIsBoringSSL.cmake @@ -0,0 +1,35 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# +####################### + +function(CHECK_OPENSSL_IS_BORINGSSL OUT_VAR OPENSSL_INCLUDE_DIR) + set(CHECK_PROGRAM + " + #include + + #ifndef OPENSSL_IS_BORINGSSL + #error check failed + #endif + + int main() { + return 0; + } + " + ) + set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("${CHECK_PROGRAM}" ${OUT_VAR}) +endfunction() diff --git a/cmake/Findquiche.cmake b/cmake/Findquiche.cmake new file mode 100644 index 00000000000..66123227bd1 --- /dev/null +++ b/cmake/Findquiche.cmake @@ -0,0 +1,49 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# +####################### + +# Findquiche.cmake +# +# This will define the following variables +# +# quiche_FOUND +# quiche_LIBRARY +# quiche_INCLUDE_DIRS +# +# and the following imported targets +# +# quiche::quiche +# + +find_library(quiche_LIBRARY NAMES quiche) +find_path(quiche_INCLUDE_DIR NAMES quiche.h PATH_SUFFIXES) + +mark_as_advanced(quiche_FOUND quiche_LIBRARY quiche_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(quiche + REQUIRED_VARS quiche_LIBRARY quiche_INCLUDE_DIR +) + +if(quiche_FOUND) + set(quiche_INCLUDE_DIRS "${quiche_INCLUDE_DIR}") +endif() + +if(quiche_FOUND AND NOT TARGET quiche::quiche) + add_library(quiche::quiche INTERFACE IMPORTED) + target_include_directories(quiche::quiche INTERFACE ${quiche_INCLUDE_DIRS}) + target_link_libraries(quiche::quiche INTERFACE "${quiche_LIBRARY}") +endif() diff --git a/include/tscore/ink_config.h.cmake.in b/include/tscore/ink_config.h.cmake.in index 12f39fee4be..e1a21d1782c 100644 --- a/include/tscore/ink_config.h.cmake.in +++ b/include/tscore/ink_config.h.cmake.in @@ -119,10 +119,11 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@; #cmakedefine01 TS_HAS_IP_TOS #cmakedefine01 TS_HAS_JEMALLOC #cmakedefine01 TS_HAS_TCMALLOC -#cmakedefine01 TS_HAS_TESTS #cmakedefine01 TS_HAS_PROFILER +#cmakedefine01 TS_HAS_QUICHE #cmakedefine01 TS_HAS_SO_MARK #cmakedefine01 TS_HAS_SO_PEERCRED +#cmakedefine01 TS_HAS_TESTS #cmakedefine01 TS_HAS_WCCP #cmakedefine01 TS_USE_DIAGS #cmakedefine01 TS_USE_EPOLL @@ -133,6 +134,7 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@; #cmakedefine01 TS_USE_LINUX_IO_URING #cmakedefine01 TS_USE_LINUX_NATIVE_AIO #cmakedefine01 TS_USE_POSIX_CAP +#cmakedefine01 TS_USE_QUIC #cmakedefine01 TS_USE_REMOTE_UNWINDING #cmakedefine01 TS_USE_SET_RBIO #cmakedefine01 TS_USE_TLS13 diff --git a/iocore/eventsystem/CMakeLists.txt b/iocore/eventsystem/CMakeLists.txt index 556336aa1a9..7100794c32a 100644 --- a/iocore/eventsystem/CMakeLists.txt +++ b/iocore/eventsystem/CMakeLists.txt @@ -35,5 +35,23 @@ add_library(inkevent STATIC ConfigProcessor.cc RecRawStatsImpl.cc RecProcess.cc) -target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(inkevent ${PCRE_LIBRARIES} ${OPENSSL_LIBRARIES} yaml-cpp::yaml-cpp tscpputil resolv libswoc tscore records_p) \ No newline at end of file +add_library(ts::inkevent ALIAS inkevent) + +target_include_directories(inkevent PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(inkevent + PUBLIC + ts::records_p + ts::tscore + PRIVATE + libswoc + ${OPENSSL_LIBRARIES} # transitive + ${PCRE_LIBRARIES} # transitive + resolv # transitive + tscpputil # transitive + yaml-cpp::yaml-cpp # transitive +) + +if(TS_USE_HWLOC) + target_link_libraries(inkevent PRIVATE hwloc::hwloc) +endif() diff --git a/iocore/io_uring/CMakeLists.txt b/iocore/io_uring/CMakeLists.txt index 0ae18bdd5d1..223ed949a5b 100644 --- a/iocore/io_uring/CMakeLists.txt +++ b/iocore/io_uring/CMakeLists.txt @@ -30,7 +30,15 @@ include_directories( add_executable(test_iouring unit_tests/test_diskIO.cc) -target_link_libraries(test_iouring PRIVATE tscore inkuring tscpputil libswoc uring) +target_link_libraries(test_iouring + PRIVATE + inkuring + libswoc + ts::tscore + tscpputil + uring +) + target_include_directories(test_iouring PRIVATE ${CMAKE_SOURCE_DIR}/include ${CATCH_INCLUDE_DIR}) add_test(NAME test_iouring COMMAND $) diff --git a/iocore/net/CMakeLists.txt b/iocore/net/CMakeLists.txt index d726cc9c3b2..7aed806c984 100644 --- a/iocore/net/CMakeLists.txt +++ b/iocore/net/CMakeLists.txt @@ -64,12 +64,37 @@ add_library(inknet STATIC SSLDynlock.cc SNIActionPerformer.cc ) +add_library(ts::inknet ALIAS inknet) + +if(TS_USE_QUIC) + add_subdirectory(quic) + + target_sources(inknet + PRIVATE + QUICClosedConCollector.cc + QUICMultiCertConfigLoader.cc + QUICNet.cc + QUICNetProcessor_quiche.cc + QUICNetVConnection_quiche.cc + QUICNextProtocolAccept_quiche.cc + QUICPacketHandler_quiche.cc + ) + + target_link_libraries(inknet + PUBLIC + quiche::quiche + ts::quic + ) +endif() + + if(BUILD_REGRESSION_TESTING) target_sources(inknet PRIVATE NetVCTest.cc) endif() + target_link_libraries(inknet PUBLIC inkevent records_p) target_compile_options(inknet PUBLIC -Wno-deprecated-declarations) -target_include_directories(inknet PRIVATE +target_include_directories(inknet PUBLIC ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/dns ${CMAKE_SOURCE_DIR}/iocore/io_uring diff --git a/iocore/net/quic/CMakeLists.txt b/iocore/net/quic/CMakeLists.txt new file mode 100644 index 00000000000..73ed59206a8 --- /dev/null +++ b/iocore/net/quic/CMakeLists.txt @@ -0,0 +1,45 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# +####################### + +add_library(quic STATIC + QUICApplication.cc + QUICApplicationMap.cc + QUICConfig.cc + QUICContext.cc + QUICConnectionTable.cc + QUICGlobals.cc + QUICTypes.cc + QUICIntUtil.cc + QUICStream.cc + QUICStream_quiche.cc + QUICStreamManager.cc + QUICStreamManager_quiche.cc + QUICStreamAdapter.cc + QUICStreamVCAdapter.cc +) +add_library(ts::quic ALIAS quic) + +target_include_directories(quic PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(quic + PUBLIC + inkevent + inknet + ${OPENSSL_LIBRARY} + quiche::quiche + ts::tscore +) diff --git a/iocore/utils/CMakeLists.txt b/iocore/utils/CMakeLists.txt index 2035a2dcafa..14c2bfe27fc 100644 --- a/iocore/utils/CMakeLists.txt +++ b/iocore/utils/CMakeLists.txt @@ -17,6 +17,9 @@ add_library(inkutils STATIC Machine.cc OneWayMultiTunnel.cc OneWayTunnel.cc) +add_library(ts::inkutils ALIAS inkutils) + + target_include_directories(inkutils PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/dns diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt index eb95e797231..43c2e1ad482 100644 --- a/proxy/CMakeLists.txt +++ b/proxy/CMakeLists.txt @@ -35,6 +35,8 @@ add_library(proxy STATIC StatPages.cc Transform.cc ) +add_library(ts::proxy ALIAS proxy) + if(BUILD_REGRESSION_TESTING) target_sources(proxy PRIVATE RegressionSM.cc) endif() @@ -50,7 +52,7 @@ set(PROXY_INCLUDE_DIRS ) set(PROXY_INCLUDE_DIRS ${PROXY_INCLUDE_DIRS} PARENT_SCOPE) -target_include_directories(proxy PRIVATE +target_include_directories(proxy PUBLIC ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/mgmt @@ -63,3 +65,7 @@ add_subdirectory(shared) add_subdirectory(http) add_subdirectory(http2) add_subdirectory(logging) + +if(TS_USE_QUIC) + add_subdirectory(http3) +endif() diff --git a/proxy/hdrs/CMakeLists.txt b/proxy/hdrs/CMakeLists.txt index 232c27c39f6..65b27578a1a 100644 --- a/proxy/hdrs/CMakeLists.txt +++ b/proxy/hdrs/CMakeLists.txt @@ -29,6 +29,17 @@ add_library(hdrs STATIC HuffmanCodec.cc XPACK.cc ) -target_include_directories(hdrs PRIVATE +add_library(ts::hdrs ALIAS hdrs) + +target_include_directories(hdrs + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" + PRIVATE ${IOCORE_INCLUDE_DIRS} -) \ No newline at end of file +) + +target_link_libraries(hdrs + PUBLIC + libswoc + ts::tscore +) diff --git a/proxy/http/CMakeLists.txt b/proxy/http/CMakeLists.txt index 35d20aed8fb..5c33b55c045 100644 --- a/proxy/http/CMakeLists.txt +++ b/proxy/http/CMakeLists.txt @@ -40,6 +40,8 @@ add_library(http STATIC PreWarmConfig.cc PreWarmManager.cc ) +add_library(ts::http ALIAS http) + if(BUILD_REGRESSION_TESTING) target_sources(http PRIVATE RegressionHttpTransact.cc) endif() @@ -51,4 +53,9 @@ target_include_directories(http PRIVATE ${CMAKE_SOURCE_DIR}/mgmt/utils ${YAMLCPP_INCLUDE_DIR} ) + +if(TS_USE_QUIC) + target_link_libraries(http PRIVATE ts::http3) +endif() + add_subdirectory(remap) diff --git a/proxy/http3/CMakeLists.txt b/proxy/http3/CMakeLists.txt new file mode 100644 index 00000000000..4bd04727cf6 --- /dev/null +++ b/proxy/http3/CMakeLists.txt @@ -0,0 +1,53 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# +####################### + +add_library(http3 STATIC + Http09App.cc + Http3.cc + Http3Config.cc + Http3App.cc + Http3Types.cc + Http3SessionAccept.cc + Http3Session.cc + Http3Transaction.cc + Http3DebugNames.cc + Http3Frame.cc + Http3FrameCollector.cc + Http3FrameDispatcher.cc + Http3HeaderFramer.cc + Http3DataFramer.cc + Http3HeaderVIOAdaptor.cc + Http3StreamDataVIOAdaptor.cc + QPACK.cc +) +add_library(ts::http3 ALIAS http3) + +target_include_directories(http3 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(http3 + PUBLIC + ts::hdrs + ts::http + ts::inknet + ts::inkutils + ts::inkevent + ts::proxy + ts::quic + ts::records_p + ts::tscpputil + ts::tscore +) diff --git a/src/records/CMakeLists.txt b/src/records/CMakeLists.txt index a32811e8d6d..2425082b7c4 100644 --- a/src/records/CMakeLists.txt +++ b/src/records/CMakeLists.txt @@ -30,13 +30,26 @@ add_library(records_p SHARED RecordsConfigUtils.cc RecRawStats.cc ) +add_library(ts::records_p ALIAS records_p) + +target_include_directories(records_p + PUBLIC + "${PROJECT_SOURCE_DIR}/include" + PRIVATE + "${CMAKE_SOURCE_DIR}/mgmt" + "${CMAKE_SOURCE_DIR}/mgmt/api/include" + "${CMAKE_SOURCE_DIR}/mgmt/utils" + "${CMAKE_SOURCE_DIR}/iocore/eventsystem" + "${CMAKE_SOURCE_DIR}/iocore/utils" +) + +target_link_libraries(records_p + PUBLIC + libswoc + #ts::inkevent cyclic dependency; I_RecProcess.h and P_RecProcess.h + ts::tscore + ts::tscpputil + yaml-cpp::yaml-cpp +) -target_include_directories(records_p PRIVATE - ${CMAKE_SOURCE_DIR}/mgmt - ${CMAKE_SOURCE_DIR}/mgmt/api/include - ${CMAKE_SOURCE_DIR}/mgmt/utils - ${CMAKE_SOURCE_DIR}/iocore/eventsystem - ${CMAKE_SOURCE_DIR}/iocore/utils - ) -target_link_libraries(records_p tscore libswoc yaml-cpp::yaml-cpp) install(TARGETS records_p) diff --git a/src/traffic_server/CMakeLists.txt b/src/traffic_server/CMakeLists.txt index c243613a56c..e8d239c7c0a 100644 --- a/src/traffic_server/CMakeLists.txt +++ b/src/traffic_server/CMakeLists.txt @@ -62,6 +62,14 @@ target_link_libraries(traffic_server rpcpublichandlers ) +if(TS_USE_QUIC) + target_link_libraries(traffic_server + PRIVATE + ts::http3 + ts::quic + ) +endif() + if(TS_HAS_PROFILER) target_link_libraries(traffic_server PRIVATE gperftools::profiler) endif() diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt index 8e52bb89daa..f7296a86acb 100644 --- a/src/tscore/CMakeLists.txt +++ b/src/tscore/CMakeLists.txt @@ -101,6 +101,8 @@ add_library(tscore SHARED runroot.cc signals.cc ) +add_library(ts::tscore ALIAS tscore) + add_dependencies(tscore ParseRules tscpputil) target_include_directories(tscore PRIVATE ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/tscpp/util/CMakeLists.txt b/src/tscpp/util/CMakeLists.txt index f38ab42139d..2d02673fd55 100644 --- a/src/tscpp/util/CMakeLists.txt +++ b/src/tscpp/util/CMakeLists.txt @@ -22,7 +22,14 @@ add_library(tscpputil SHARED TextView.cc YamlCfg.cc ts_unit_parser.cc) -target_link_libraries(tscpputil PRIVATE yaml-cpp libswoc) +add_library(ts::tscpputil ALIAS tscpputil) + +target_link_libraries(tscpputil + PUBLIC + libswoc + # ts::tscore cyclic dependency + yaml-cpp::yaml-cpp +) add_executable(test_tscpputil unit_tests/test_IntrusiveDList.cc