Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ option(ENABLE_POSIX_CAP
)
option(ENABLE_PROFILER "Use gperftools profiler (default OFF)")
option(ENABLE_TCMALLOC "Use TCMalloc (default OFF)")
set(ENABLE_TPROXY
"AUTO"
CACHE
STRING
"Use TPROXY to enable connection transparency. (default AUTO)
'AUTO' for local system default,
'NO', to disable,
'FORCE' to use built in default,
'X' where X is a number to use as the IP_TRANSPARENT sockopt,
anything else to enable."
)
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)")
Expand All @@ -67,7 +78,6 @@ set(TS_VERSION_NUMBER TS_VERSION_N)

set(TS_HAS_WCCP ${ENABLE_WCCP})


# Check include files
include(CheckIncludeFile)
include(CheckIncludeFiles)
Expand Down Expand Up @@ -166,6 +176,7 @@ endif()
find_package(ZLIB REQUIRED)

include(Check128BitCas)
include(ConfigureTransparentProxy)

# Find ccache
include(find_ccache)
Expand Down
76 changes: 76 additions & 0 deletions cmake/ConfigureTransparentProxy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#######################
#
# 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.
#
#######################

# ConfigureTransparentProxy.cmake
#
# The following variables should be set
#
# ENABLE_TPROXY to one of AUTO, NO, or a number
# TS_USE_POSIX_CAP to a boolean value
#
# This will define the following variables
#
# TS_USE_TPROXY
# TS_IP_TRANSPARENT
#

set(TS_IP_TRANSPARENT 0)

if(ENABLE_TPROXY STREQUAL "NO")
set(TS_USE_TPROXY FALSE)
return()
endif()

if(NOT TS_USE_POSIX_CAP)
if(ENABLE_TPROXY STREQUAL "AUTO")
set(TS_USE_TPROXY FALSE)
else()
message(FATAL_ERROR "ENABLE_TPROXY requires POSIX capabilities.")
endif()
return()
endif()

if(ENABLE_TPROXY STREQUAL "FORCE")
set(TS_USE_TPROXY TRUE)
set(TS_IP_TRANSPARENT 19)
return()
endif()

if(ENABLE_TPROXY MATCHES "([0-9]+)")
set(TS_USE_TPROXY TRUE)
set(TS_IP_TRANSPARENT ${CMAKE_MATCH_1})
return()
endif()

# If the read fails, it will print out a confusing error. This
# is to make it clear why the error is happening in that case.
message("ENABLE_TPROXY enabled, looking for value in /usr/include/linux/in.h")
file(READ "/usr/include/linux/in.h" HEADER_CONTENTS)
if(HEADER_CONTENTS MATCHES "#define[ \t]+IP_TRANSPARENT[ \t]+([0-9]+)")
set(TS_USE_TPROXY TRUE)
set(TS_IP_TRANSPARENT ${CMAKE_MATCH_1})
else()
if(ENABLE_TPROXY STREQUAL "AUTO")
set(TS_USE_TPROXY FALSE)
else()
message(FATAL_ERROR
"ENABLE_TPROXY on but IP_TRANSPARENT symbol not found"
)
endif()
endif()

unset(HEADER_CONTENTS)
2 changes: 2 additions & 0 deletions include/tscore/ink_config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

/* Build definitions */
const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@;
#define TS_IP_TRANSPARENT @TS_IP_TRANSPARENT@
#define TS_MAX_HOST_NAME_LEN @TS_MAX_HOST_NAME_LEN@

/* Feature Flags */
Expand All @@ -132,6 +133,7 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@;
#cmakedefine01 TS_USE_REMOTE_UNWINDING
#cmakedefine01 TS_USE_SET_RBIO
#cmakedefine01 TS_USE_TLS13
#cmakedefine01 TS_USE_TPROXY

#define TS_BUILD_CANONICAL_HOST "@CMAKE_HOST@"

Expand Down