From d5ba81cbae0268dd19ed9a8efd53871384f3f712 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Thu, 10 Oct 2019 14:51:33 -0400 Subject: [PATCH 01/12] Correct stdc++ language and size issues for MSVC This patch makes consistent the type for ssize_t as used on Windows. We will favor describing it as a ptrdiff_t, which is standard C. Patches to tclap and nghttp2 are needed for this exercise. Linux is a 64ILP architecture, so there's no difference between int and [s]size_t and pointer widths. Windows is a 64P architecture, where only long long maps to the width of the size_t and C99 standard ptrdiff_t types. This leads to a number of places where the Envoy API has presented an explicit int or int32_t which is smaller than the ptrdiff_t on Windows. In some places we must cast to or from the API defined width. Several other misassumptions on the width of int are also addressed. Windows does not support alternately-named __VA_ARGS__ which is not a standard C++ language feature in our baseline c++ 17 expectation. Other minor adjustments reflect other quirks of the MSVC compilier (some more correct and some simply buggy behavior). Windows MSVC needs various guards on unrecognized #pragmas, and will not support any preprocessor operations within the arguments to a macro; this is not stdc or stdc++. This patch largely ignores changes which are required for windows, and do not impact the linux/os-x compilation path. This patch is also missing the IoHandle abstraction of 'fd' arguments, storage and return codes, win32 error handling and win32 specific #include's handling. Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- bazel/envoy_internal.bzl | 12 ++++++++--- bazel/foreign_cc/nghttp2.patch | 2 +- bazel/repositories.bzl | 2 ++ bazel/tclap-win64-ull-sizet.patch | 16 +++++++++++++++ include/envoy/common/platform.h | 6 +----- source/common/common/utility.cc | 4 ++-- source/common/common/version.cc | 14 ++++++------- source/common/http/http2/nghttp2.cc | 5 +++++ source/common/protobuf/protobuf.h | 8 ++++++++ source/common/router/header_parser.h | 8 ++++++++ source/common/router/retry_state_impl.cc | 4 ++-- .../common/singleton/threadsafe_singleton.h | 1 + source/common/tracing/http_tracer_impl.h | 7 +++++++ source/common/upstream/edf_scheduler.h | 4 ++-- source/common/upstream/load_balancer_impl.cc | 4 ++-- source/common/upstream/upstream_impl.h | 2 +- .../extensions/common/tap/tap_config_base.cc | 4 +++- .../filters/http/grpc_web/grpc_web_filter.cc | 2 ++ .../network/http_connection_manager/config.cc | 11 ++++++---- .../redis_proxy/command_splitter_impl.cc | 8 ++++---- .../network/redis_proxy/conn_pool_impl.cc | 4 ++-- .../quiche/platform/quic_aligned_impl.h | 4 ++++ .../transport_sockets/alts/grpc_tsi.h | 4 ++++ .../common/access_log/access_log_impl_test.cc | 3 ++- test/common/http/header_utility_test.cc | 2 +- test/common/http/http2/codec_impl_test.cc | 4 ++-- test/common/http/http2/frame_replay_test.cc | 4 ++-- .../http2/metadata_encoder_decoder_test.cc | 4 +++- test/common/runtime/runtime_impl_test.cc | 2 +- test/common/stream_info/test_util.h | 6 +++++- .../http/tap/tap_filter_integration_test.cc | 2 +- .../quiche/crypto_test_utils_for_envoy.cc | 4 ++++ .../tls/context_impl_test.cc | 11 ++++++---- .../tls/integration/ssl_integration_test.cc | 4 ++-- test/integration/echo_integration_test.cc | 14 +++++++------ test/integration/uds_integration_test.cc | 20 +++++++++++-------- test/mocks/http/mocks.h | 2 +- 37 files changed, 151 insertions(+), 67 deletions(-) create mode 100644 bazel/tclap-win64-ull-sizet.patch diff --git a/bazel/envoy_internal.bzl b/bazel/envoy_internal.bzl index 06ab0d4787d1..8a8a88ad2d0b 100644 --- a/bazel/envoy_internal.bzl +++ b/bazel/envoy_internal.bzl @@ -15,16 +15,22 @@ def envoy_copts(repository, test = False): "-std=c++14", ] + # Windows options for cleanest service compilation; + # General MSVC C++ options + # Streamline windows.h behavior for Win8+ API (for ntohll, see; + # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx ) + # Minimize Win32 API, dropping GUI-oriented features msvc_options = [ "-WX", "-Zc:__cplusplus", "-std:c++14", "-DWIN32", - "-DWIN32_LEAN_AND_MEAN", - # need win8 for ntohll - # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx "-D_WIN32_WINNT=0x0602", "-DNTDDI_VERSION=0x06020000", + "-DWIN32_LEAN_AND_MEAN", + "-DNOUSER", + "-DNOMCX", + "-DNOIME", ] return select({ diff --git a/bazel/foreign_cc/nghttp2.patch b/bazel/foreign_cc/nghttp2.patch index e7b001673a56..55768dca2003 100644 --- a/bazel/foreign_cc/nghttp2.patch +++ b/bazel/foreign_cc/nghttp2.patch @@ -8,7 +8,7 @@ index 35c77d1d..47bd63f5 100644 # Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools). - set(ssize_t int) + if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) -+ set(ssize_t int64_t) ++ set(ssize_t ptrdiff_t) + else() + set(ssize_t int) + endif() diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 9a09f62af556..d647e03c4a40 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -241,6 +241,8 @@ def _com_github_eile_tclap(): _repository_impl( name = "com_github_eile_tclap", build_file = "@envoy//bazel/external:tclap.BUILD", + patch_args = ["-p1"], + patches = ["@envoy//bazel:tclap-win64-ull-sizet.patch"], ) native.bind( name = "tclap", diff --git a/bazel/tclap-win64-ull-sizet.patch b/bazel/tclap-win64-ull-sizet.patch new file mode 100644 index 000000000000..b393d8572813 --- /dev/null +++ b/bazel/tclap-win64-ull-sizet.patch @@ -0,0 +1,16 @@ +diff --git a/include/tclap/StandardTraits.h b/include/tclap/StandardTraits.h +index 46d7f6f..117057b 100644 +--- a/include/tclap/StandardTraits.h ++++ b/include/tclap/StandardTraits.h +@@ -123,8 +123,9 @@ struct ArgTraits { + typedef ValueLike ValueCategory; + }; + +-// Microsoft implements size_t awkwardly. +-#if defined(_MSC_VER) && defined(_M_X64) ++// Microsoft implements size_t awkwardly. ++// Studio 2005 introduces unsigned long long, which conflicts with the size_t template ++#if defined(_MSC_VER) && (_MSC_VER < 1400) && defined(_M_X64) + /** + * size_ts have value-like semantics. + */ diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 12e8f4bca33c..b83a7f71c222 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -8,11 +8,7 @@ __pragma(pack(push, 1)) definition, ##__VA_ARGS__; \ __pragma(pack(pop)) -#ifdef _M_X64 -using ssize_t = int64_t; -#else -#error Envoy is not supported on 32-bit Windows -#endif +using ssize_t = ptrdiff_t; #else #define PACKED_STRUCT(definition, ...) definition, ##__VA_ARGS__ __attribute__((packed)) diff --git a/source/common/common/utility.cc b/source/common/common/utility.cc index d5d262bc06d8..c3775d3b0afd 100644 --- a/source/common/common/utility.cc +++ b/source/common/common/utility.cc @@ -168,7 +168,7 @@ DateFormatter::fromTimeAndPrepareSpecifierOffsets(time_t time, SpecifierOffsets& const std::string& seconds_str) const { std::string formatted_time; - size_t previous = 0; + int32_t previous = 0; specifier_offsets.reserve(specifiers_.size()); for (const auto& specifier : specifiers_) { std::string current_format = @@ -353,7 +353,7 @@ uint32_t StringUtil::itoa(char* out, size_t buffer_size, uint64_t i) { } *current = 0; - return current - out; + return static_cast(current - out); } size_t StringUtil::strlcpy(char* dst, const char* src, size_t size) { diff --git a/source/common/common/version.cc b/source/common/common/version.cc index d7c2f2075a19..6fe70c9331e0 100644 --- a/source/common/common/version.cc +++ b/source/common/common/version.cc @@ -19,18 +19,18 @@ const std::string& VersionInfo::revisionStatus() { } const std::string& VersionInfo::version() { - CONSTRUCT_ON_FIRST_USE(std::string, fmt::format("{}/{}/{}/{}/{}", revision(), - BUILD_VERSION_NUMBER, revisionStatus(), #ifdef NDEBUG - "RELEASE", + const std::string release_type = "RELEASE"; #else - "DEBUG", + const std::string release_type = "DEBUG"; #endif #ifdef ENVOY_SSL_VERSION - ENVOY_SSL_VERSION + const std::string ssl_version = ENVOY_SSL_VERSION; #else - "no-ssl" + const std::string ssl_version = "no-ssl"; #endif - )); + CONSTRUCT_ON_FIRST_USE(std::string, + fmt::format("{}/{}/{}/{}/{}", revision(), BUILD_VERSION_NUMBER, + revisionStatus(), release_type, ssl_version)); } } // namespace Envoy diff --git a/source/common/http/http2/nghttp2.cc b/source/common/http/http2/nghttp2.cc index 5781cfa262ad..448ea9bb2404 100644 --- a/source/common/http/http2/nghttp2.cc +++ b/source/common/http/http2/nghttp2.cc @@ -2,6 +2,11 @@ #include "common/common/logger.h" +// nghttp2 fails to convey the POSIX ssize_t declaration +// that Microsoft declines to implement. Pick up a valid +// ssize_t declaration for win32 in our platform.h +#include "envoy/common/platform.h" + #include "nghttp2/nghttp2.h" namespace Envoy { diff --git a/source/common/protobuf/protobuf.h b/source/common/protobuf/protobuf.h index aa3b78ce4902..d0b2a5e1229d 100644 --- a/source/common/protobuf/protobuf.h +++ b/source/common/protobuf/protobuf.h @@ -27,6 +27,14 @@ #include "google/protobuf/util/type_resolver_util.h" #include "google/protobuf/wrappers.pb.h" +#ifdef WIN32 +// one of the above headers includes , so undef some interfering symbols +#undef TRUE +#undef DELETE +#undef ERROR +#undef GetMessage +#endif + namespace Envoy { // All references to google::protobuf in Envoy need to be made via the diff --git a/source/common/router/header_parser.h b/source/common/router/header_parser.h index 725f78a5e97c..0f9859efa703 100644 --- a/source/common/router/header_parser.h +++ b/source/common/router/header_parser.h @@ -1,3 +1,11 @@ +// grpcpp/grpcpp.h includes , so undef some interfering symbols +#ifdef WIN32 +#undef TRUE +#undef DELETE +#undef ERROR +#undef GetMessage +#endif + #pragma once #include diff --git a/source/common/router/retry_state_impl.cc b/source/common/router/retry_state_impl.cc index 0f3c7060765a..5b03df19e3c4 100644 --- a/source/common/router/retry_state_impl.cc +++ b/source/common/router/retry_state_impl.cc @@ -92,7 +92,7 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, Http::HeaderMap& if (!retriable_request_headers_.empty()) { // If this route limits retries by request headers, make sure there is a match. - bool request_header_match = false; + uint32_t request_header_match = false; for (const auto& retriable_header : retriable_request_headers_) { if (retriable_header->matchesHeaders(request_headers)) { request_header_match = true; @@ -112,7 +112,7 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, Http::HeaderMap& if (request_headers.EnvoyRetriableStatusCodes()) { for (const auto code : StringUtil::splitToken( request_headers.EnvoyRetriableStatusCodes()->value().getStringView(), ",")) { - uint64_t out; + unsigned int out; if (absl::SimpleAtoi(code, &out)) { retriable_status_codes_.emplace_back(out); } diff --git a/source/common/singleton/threadsafe_singleton.h b/source/common/singleton/threadsafe_singleton.h index 39f3df7fd7fe..5b55dc0af517 100644 --- a/source/common/singleton/threadsafe_singleton.h +++ b/source/common/singleton/threadsafe_singleton.h @@ -25,6 +25,7 @@ namespace Envoy { * where state "leaks" across tests. * * */ +template class TestThreadsafeSingletonInjector; template class ThreadSafeSingleton { public: static T& get() { diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index bb99d7934e77..8906fe4e6a0d 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -11,6 +11,13 @@ #include "common/http/header_map_impl.h" #include "common/json/json_loader.h" +#ifdef WIN32 +// defines macros for ERROR and TRUE, so we need to undef them in +// case it's been included above +#undef ERROR +#undef TRUE +#endif + namespace Envoy { namespace Tracing { diff --git a/source/common/upstream/edf_scheduler.h b/source/common/upstream/edf_scheduler.h index 192eb7d39161..fc135dfc1490 100644 --- a/source/common/upstream/edf_scheduler.h +++ b/source/common/upstream/edf_scheduler.h @@ -13,9 +13,9 @@ namespace Upstream { #define EDF_DEBUG 0 #if EDF_DEBUG -#define EDF_TRACE(fmt...) ENVOY_LOG_MISC(trace, fmt) +#define EDF_TRACE(...) ENVOY_LOG_MISC(trace, __VA_ARGS__) #else -#define EDF_TRACE(fmt...) +#define EDF_TRACE(...) #endif // Earliest Deadline First (EDF) scheduler diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index b3172d9c9a27..742978bf4f2f 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -79,7 +79,7 @@ LoadBalancerBase::choosePriority(uint64_t hash, const HealthyLoad& healthy_per_p for (size_t priority = 0; priority < healthy_per_priority_load.get().size(); ++priority) { aggregate_percentage_load += healthy_per_priority_load.get()[priority]; if (hash <= aggregate_percentage_load) { - return {priority, HostAvailability::Healthy}; + return {static_cast(priority), HostAvailability::Healthy}; } } @@ -88,7 +88,7 @@ LoadBalancerBase::choosePriority(uint64_t hash, const HealthyLoad& healthy_per_p for (size_t priority = 0; priority < degraded_per_priority_load.get().size(); ++priority) { aggregate_percentage_load += degraded_per_priority_load.get()[priority]; if (hash <= aggregate_percentage_load) { - return {priority, HostAvailability::Degraded}; + return {static_cast(priority), HostAvailability::Degraded}; } } diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 14451297ef05..2ceecded0ca8 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -243,7 +243,7 @@ class HostImpl : public HostDescriptionImpl, private: void setEdsHealthFlag(envoy::api::v2::core::HealthStatus health_status); - std::atomic health_flags_{}; + std::atomic health_flags_{}; ActiveHealthFailureType active_health_failure_type_{}; std::atomic weight_; std::atomic used_; diff --git a/source/extensions/common/tap/tap_config_base.cc b/source/extensions/common/tap/tap_config_base.cc index 5db293de3a84..f99dc4f6009a 100644 --- a/source/extensions/common/tap/tap_config_base.cc +++ b/source/extensions/common/tap/tap_config_base.cc @@ -167,7 +167,9 @@ void FilePerTapSink::FilePerTapSinkHandle::submitTrace( } ENVOY_LOG_MISC(debug, "Opening tap file for [id={}] to {}", trace_id_, path); - output_file_.open(path); + // When reading and writing binary files, we need to be sure std::ios_base::binary + // is set, otherwise we will not get the expected results on Windows + output_file_.open(path, std::ios_base::binary); } ENVOY_LOG_MISC(trace, "Tap for [id={}]: {}", trace_id_, trace->DebugString()); diff --git a/source/extensions/filters/http/grpc_web/grpc_web_filter.cc b/source/extensions/filters/http/grpc_web/grpc_web_filter.cc index 67113d6d73b5..718ae11bffbc 100644 --- a/source/extensions/filters/http/grpc_web/grpc_web_filter.cc +++ b/source/extensions/filters/http/grpc_web/grpc_web_filter.cc @@ -1,6 +1,8 @@ #include "extensions/filters/http/grpc_web/grpc_web_filter.h" +#ifndef WIN32 #include +#endif #include "common/common/assert.h" #include "common/common/base64.h" diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index aa47daf32a27..33423d037863 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -170,16 +170,19 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( context_.listenerScope())), proxy_100_continue_(config.proxy_100_continue()), delayed_close_timeout_(PROTOBUF_GET_MS_OR_DEFAULT(config, delayed_close_timeout, 1000)), +#ifdef ENVOY_NORMALIZE_PATH_BY_DEFAULT normalize_path_(PROTOBUF_GET_WRAPPED_OR_DEFAULT( config, normalize_path, // TODO(htuch): we should have a boolean variant of featureEnabled() here. context.runtime().snapshot().featureEnabled("http_connection_manager.normalize_path", -#ifdef ENVOY_NORMALIZE_PATH_BY_DEFAULT - 100 + 100))), #else - 0 + normalize_path_(PROTOBUF_GET_WRAPPED_OR_DEFAULT( + config, normalize_path, + // TODO(htuch): we should have a boolean variant of featureEnabled() here. + context.runtime().snapshot().featureEnabled("http_connection_manager.normalize_path", + 0))), #endif - ))), merge_slashes_(config.merge_slashes()) { // If idle_timeout_ was not configured in common_http_protocol_options, use value in deprecated // idle_timeout field. diff --git a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc index c148825a7909..c4e44bd12434 100644 --- a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc +++ b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc @@ -253,7 +253,7 @@ SplitRequestPtr MGETRequest::create(Router& router, Common::Redis::RespValuePtr& single_mget.type(Common::Redis::RespType::Array); single_mget.asArray().swap(values); - for (uint64_t i = 1; i < incoming_request->asArray().size(); i++) { + for (unsigned int i = 1; i < incoming_request->asArray().size(); i++) { request_ptr->pending_requests_.emplace_back(*request_ptr, i - 1); PendingRequest& pending_request = request_ptr->pending_requests_.back(); @@ -382,8 +382,8 @@ SplitRequestPtr MSETRequest::create(Router& router, Common::Redis::RespValuePtr& single_mset.type(Common::Redis::RespType::Array); single_mset.asArray().swap(values); - uint64_t fragment_index = 0; - for (uint64_t i = 1; i < incoming_request->asArray().size(); i += 2) { + unsigned fragment_index = 0; + for (unsigned i = 1; i < incoming_request->asArray().size(); i += 2) { request_ptr->pending_requests_.emplace_back(*request_ptr, fragment_index++); PendingRequest& pending_request = request_ptr->pending_requests_.back(); @@ -478,7 +478,7 @@ SplitRequestPtr SplitKeysSumResultRequest::create(Router& router, single_fragment.type(Common::Redis::RespType::Array); single_fragment.asArray().swap(values); - for (uint64_t i = 1; i < incoming_request->asArray().size(); i++) { + for (unsigned i = 1; i < incoming_request->asArray().size(); i++) { request_ptr->pending_requests_.emplace_back(*request_ptr, i - 1); PendingRequest& pending_request = request_ptr->pending_requests_.back(); diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc index 24c8caf7a2ab..eaeab0accea6 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc @@ -245,7 +245,7 @@ InstanceImpl::ThreadLocalPool::makeRequestToHost(const std::string& host_address host_address_map_key = host_address; } else { const auto ip_port = absl::string_view(host_address).substr(colon_pos + 1); - uint64_t ip_port_number; + uint32_t ip_port_number; if (!absl::SimpleAtoi(ip_port, &ip_port_number) || (ip_port_number > 65535)) { return nullptr; } @@ -268,7 +268,7 @@ InstanceImpl::ThreadLocalPool::makeRequestToHost(const std::string& host_address if (!ipv6) { // Only create an IPv4 address instance if we need a new Upstream::HostImpl. const auto ip_port = absl::string_view(host_address).substr(colon_pos + 1); - uint64_t ip_port_number; + uint32_t ip_port_number; if (!absl::SimpleAtoi(ip_port, &ip_port_number) || (ip_port_number > 65535)) { return nullptr; } diff --git a/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h b/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h index 73659ace0e63..3f595380b720 100644 --- a/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h @@ -9,6 +9,10 @@ // porting layer for QUICHE. #define QUIC_ALIGN_OF_IMPL alignof +#ifdef _MSC_VER +#define QUIC_ALIGNED_IMPL(X) __declspec(align(X)) +#else #define QUIC_ALIGNED_IMPL(X) __attribute__((aligned(X))) +#endif #define QUIC_CACHELINE_ALIGNED_IMPL ABSL_CACHELINE_ALIGNED #define QUIC_CACHELINE_SIZE_IMPL ABSL_CACHELINE_SIZE diff --git a/source/extensions/transport_sockets/alts/grpc_tsi.h b/source/extensions/transport_sockets/alts/grpc_tsi.h index 825f3d495d93..d3aa0a0b1592 100644 --- a/source/extensions/transport_sockets/alts/grpc_tsi.h +++ b/source/extensions/transport_sockets/alts/grpc_tsi.h @@ -4,16 +4,20 @@ // compile with -Werror, ignoring those compiler warning since we don't have // control on those source codes. This works with GCC and Clang. +#ifndef _MSC_VER #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "grpc/grpc_security.h" #include "src/core/tsi/alts/handshaker/alts_shared_resource.h" #include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h" #include "src/core/tsi/transport_security_interface.h" +#ifndef _MSC_VER #pragma GCC diagnostic pop +#endif #include "common/common/c_smart_ptr.h" diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index 6fa5671299d1..03a9dcaf95b6 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1266,7 +1266,8 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); const Json::ObjectSharedPtr filter_config = MessageUtil::getJsonObjectFromMessage(*factory_config); - return std::make_unique(filter_config->getInteger("rate")); + return std::make_unique( + static_cast(filter_config->getInteger("rate"))); } ProtobufTypes::MessagePtr createEmptyConfigProto() override { diff --git a/test/common/http/header_utility_test.cc b/test/common/http/header_utility_test.cc index c61443feec2f..92f66f0e4116 100644 --- a/test/common/http/header_utility_test.cc +++ b/test/common/http/header_utility_test.cc @@ -461,7 +461,7 @@ TEST(HeaderIsValidTest, InvalidHeaderValuesAreRejected) { // values 9, 10, and 13 which are a horizontal tab, line feed, and carriage // return, respectively), and are not valid in an HTTP header, per // RFC 7230, section 3.2 - for (uint i = 0; i < 32; i++) { + for (int i = 0; i < 32; i++) { if (i == 9) { continue; } diff --git a/test/common/http/http2/codec_impl_test.cc b/test/common/http/http2/codec_impl_test.cc index 81707a9a2a48..ea9d5c480956 100644 --- a/test/common/http/http2/codec_impl_test.cc +++ b/test/common/http/http2/codec_impl_test.cc @@ -396,7 +396,7 @@ TEST_P(Http2CodecImplTest, Invalid204WithContentLength) { // maximum frame size is 16K. We will add 3,000 headers that will take us above this size and // not easily compress with HPACK. (I confirmed this generates 26,468 bytes of header data // which should contain a continuation.) - for (uint i = 1; i < 3000; i++) { + for (unsigned i = 1; i < 3000; i++) { response_headers.addCopy(std::to_string(i), std::to_string(i)); } @@ -426,7 +426,7 @@ TEST_P(Http2CodecImplTest, Invalid204WithContentLengthAllowed) { // maximum frame size is 16K. We will add 3,000 headers that will take us above this size and // not easily compress with HPACK. (I confirmed this generates 26,468 bytes of header data // which should contain a continuation.) - for (uint i = 1; i < 3000; i++) { + for (int i = 1; i < 3000; i++) { response_headers.addCopy(std::to_string(i), std::to_string(i)); } diff --git a/test/common/http/http2/frame_replay_test.cc b/test/common/http/http2/frame_replay_test.cc index de886feaacb9..82f2366ec318 100644 --- a/test/common/http/http2/frame_replay_test.cc +++ b/test/common/http/http2/frame_replay_test.cc @@ -5,9 +5,9 @@ #include "gtest/gtest.h" -#define EXPECT_NEXT_BYTES(istream, bs...) \ +#define EXPECT_NEXT_BYTES(istream, ...) \ do { \ - std::vector expected_bytes{bs}; \ + std::vector expected_bytes{__VA_ARGS__}; \ std::vector actual_bytes(expected_bytes.size()); \ istream->read(reinterpret_cast(actual_bytes.data()), expected_bytes.size()); \ EXPECT_EQ(actual_bytes, expected_bytes); \ diff --git a/test/common/http/http2/metadata_encoder_decoder_test.cc b/test/common/http/http2/metadata_encoder_decoder_test.cc index ede02d769a13..c294c7bb138e 100644 --- a/test/common/http/http2/metadata_encoder_decoder_test.cc +++ b/test/common/http/http2/metadata_encoder_decoder_test.cc @@ -10,7 +10,9 @@ // A global variable in nghttp2 to disable preface and initial settings for tests. // TODO(soya3129): Remove after issue https://github.com/nghttp2/nghttp2/issues/1246 is fixed. +extern "C" { extern int nghttp2_enable_strict_preface; +} namespace Envoy { namespace Http { @@ -202,7 +204,7 @@ TEST_F(MetadataEncoderDecoderTest, VerifyEncoderDecoderMultipleMetadataReachSize MetadataCallback cb = [](std::unique_ptr) -> void {}; initialize(cb); - int result = 0; + ssize_t result = 0; for (int i = 0; i < 100; i++) { // Cleans up the output buffer. diff --git a/test/common/runtime/runtime_impl_test.cc b/test/common/runtime/runtime_impl_test.cc index 0a9350e47971..830f375feab4 100644 --- a/test/common/runtime/runtime_impl_test.cc +++ b/test/common/runtime/runtime_impl_test.cc @@ -375,7 +375,7 @@ TEST_F(DiskLoaderImplTest, PercentHandling) { // NOTE: high_value has to have the property that the lowest 32 bits % 100 // is less than 100. If it's greater than 100 the test will pass whether or // not the uint32 conversion is handled properly. - uint64_t high_value = 1UL << 60; + uint64_t high_value = 1ULL << 60; std::string high_value_str = std::to_string(high_value); loader_->mergeValues({{"foo", high_value_str}}); EXPECT_TRUE(loader_->snapshot().featureEnabled("foo", default_value, 0)); diff --git a/test/common/stream_info/test_util.h b/test/common/stream_info/test_util.h index 83627789c3dc..467e3701ec15 100644 --- a/test/common/stream_info/test_util.h +++ b/test/common/stream_info/test_util.h @@ -16,7 +16,11 @@ class TestStreamInfo : public StreamInfo::StreamInfo { memset(&fake_time, 0, sizeof(fake_time)); fake_time.tm_year = 99; // tm < 1901-12-13 20:45:52 is not valid on macOS fake_time.tm_mday = 1; - start_time_ = std::chrono::system_clock::from_time_t(timegm(&fake_time)); +#if !defined(WIN32) + start_time_ = std::chrono::system_clock::from_time_t(::timegm(&fake_time)); +#else + start_time_ = std::chrono::system_clock::from_time_t(::_mkgmtime(&fake_time)); +#endif MonotonicTime now = timeSystem().monotonicTime(); start_time_monotonic_ = now; diff --git a/test/extensions/filters/http/tap/tap_filter_integration_test.cc b/test/extensions/filters/http/tap/tap_filter_integration_test.cc index 347914fd5319..77a12f058b1f 100644 --- a/test/extensions/filters/http/tap/tap_filter_integration_test.cc +++ b/test/extensions/filters/http/tap/tap_filter_integration_test.cc @@ -108,7 +108,7 @@ class TapIntegrationTest : public testing::TestWithParam traces; - std::ifstream pb_file(*pb_file_name); + std::ifstream pb_file(*pb_file_name, std::ios_base::binary); Protobuf::io::IstreamInputStream stream(&pb_file); Protobuf::io::CodedInputStream coded_stream(&stream); while (true) { diff --git a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc index b3a94737a5e6..22df487392d4 100644 --- a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc +++ b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc @@ -3,6 +3,7 @@ // This file defines platform dependent test utility functions which is declared // in quiche/quic/test_tools/crypto_test_utils.h. +#ifdef __GNUC__ #pragma GCC diagnostic push // QUICHE allows unused parameters. #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -13,6 +14,9 @@ #include "quiche/quic/test_tools/crypto_test_utils.h" #pragma GCC diagnostic pop +#else +#include "quiche/quic/test_tools/crypto_test_utils.h" +#endif #include #include "extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h" diff --git a/test/extensions/transport_sockets/tls/context_impl_test.cc b/test/extensions/transport_sockets/tls/context_impl_test.cc index 6f12bc75cb4b..59bdda441917 100644 --- a/test/extensions/transport_sockets/tls/context_impl_test.cc +++ b/test/extensions/transport_sockets/tls/context_impl_test.cc @@ -612,14 +612,17 @@ TEST_F(ClientContextConfigImplTest, RSA1024Cert) { Event::SimulatedTimeSystem time_system; ContextManagerImpl manager(time_system); Stats::IsolatedStoreImpl store; - EXPECT_THROW_WITH_REGEX( - manager.createSslClientContext(store, client_context_config), EnvoyException, + + std::string error_msg( "Failed to load certificate chain from .*selfsigned_rsa_1024_cert.pem, only RSA certificates " #ifdef BORINGSSL_FIPS - "with 2048-bit or 3072-bit keys are supported in FIPS mode"); + "with 2048-bit or 3072-bit keys are supported in FIPS mode" #else - "with 2048-bit or larger keys are supported"); + "with 2048-bit or larger keys are supported" #endif + ); + EXPECT_THROW_WITH_REGEX(manager.createSslClientContext(store, client_context_config), + EnvoyException, error_msg); } // Validate that 3072-bit RSA certificates load successfully. diff --git a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc index ae3205fa75c3..f85b61b6f63b 100644 --- a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc +++ b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc @@ -148,8 +148,8 @@ TEST_P(SslIntegrationTest, RouterDownstreamDisconnectBeforeRequestComplete) { } TEST_P(SslIntegrationTest, RouterDownstreamDisconnectBeforeResponseComplete) { -#ifdef __APPLE__ - // Skip this test on macOS: we can't detect the early close on macOS, and we +#if defined(__APPLE__) || defined(WIN32) + // Skip this test on OS X + Windows: we can't detect the early close on non-Linux, and we // won't clean up the upstream connection until it times out. See #4294. if (downstream_protocol_ == Http::CodecClient::Type::HTTP1) { return; diff --git a/test/integration/echo_integration_test.cc b/test/integration/echo_integration_test.cc index c60cf8452b03..be26d89db31e 100644 --- a/test/integration/echo_integration_test.cc +++ b/test/integration/echo_integration_test.cc @@ -49,15 +49,16 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, EchoIntegrationTest, TEST_P(EchoIntegrationTest, Hello) { Buffer::OwnedImpl buffer("hello"); std::string response; - RawConnectionDriver connection( + std::unique_ptr connection; + connection = std::make_unique( lookupPort("listener_0"), buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(data.toString()); - connection.close(); + connection->close(); }, version_); - connection.run(); + connection->run(); EXPECT_EQ("hello", response); } @@ -99,14 +100,15 @@ name: new_listener Buffer::OwnedImpl buffer("hello"); std::string response; - RawConnectionDriver connection( + std::unique_ptr connection; + connection = std::make_unique( new_listener_port, buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(data.toString()); - connection.close(); + connection->close(); }, version_); - connection.run(); + connection->run(); EXPECT_EQ("hello", response); // Remove the listener. diff --git a/test/integration/uds_integration_test.cc b/test/integration/uds_integration_test.cc index e12d6d2a6c04..f1633a693b9f 100644 --- a/test/integration/uds_integration_test.cc +++ b/test/integration/uds_integration_test.cc @@ -9,15 +9,17 @@ namespace Envoy { +#if defined(__linux__) INSTANTIATE_TEST_SUITE_P( TestParameters, UdsUpstreamIntegrationTest, testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), -#if defined(__linux__) - testing::Values(false, true) + testing::Values(false, true))); #else - testing::Values(false) +INSTANTIATE_TEST_SUITE_P( + TestParameters, UdsUpstreamIntegrationTest, + testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), + testing::Values(false))); #endif - )); TEST_P(UdsUpstreamIntegrationTest, RouterRequestAndResponseWithBodyNoBuffer) { testRouterRequestAndResponseWithBody(1024, 512, false); @@ -39,15 +41,17 @@ TEST_P(UdsUpstreamIntegrationTest, RouterDownstreamDisconnectBeforeResponseCompl testRouterDownstreamDisconnectBeforeResponseComplete(); } +#if defined(__linux__) INSTANTIATE_TEST_SUITE_P( TestParameters, UdsListenerIntegrationTest, testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), -#if defined(__linux__) - testing::Values(false, true) + testing::Values(false, true))); #else - testing::Values(false) +INSTANTIATE_TEST_SUITE_P( + TestParameters, UdsListenerIntegrationTest, + testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), + testing::Values(false))); #endif - )); void UdsListenerIntegrationTest::initialize() { config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { diff --git a/test/mocks/http/mocks.h b/test/mocks/http/mocks.h index 2398873d21a8..8c3995f1f189 100644 --- a/test/mocks/http/mocks.h +++ b/test/mocks/http/mocks.h @@ -465,7 +465,7 @@ class HeaderValueOfMatcher { // Test that a HeaderMap argument contains exactly one header with the given // key, whose value satisfies the given expectation. The expectation can be a // matcher, or a string that the value should equal. -template HeaderValueOfMatcher HeaderValueOf(K key, T matcher) { +template HeaderValueOfMatcher HeaderValueOf(K key, const T& matcher) { return HeaderValueOfMatcher(LowerCaseString(key), testing::SafeMatcherCast(matcher)); } From 7ea352289142db6cc9e2c0c9298423600bc8ced6 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Wed, 23 Oct 2019 10:21:02 -0400 Subject: [PATCH 02/12] This cleanup was misplaced; relocating to platform.h Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- source/common/router/header_parser.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/source/common/router/header_parser.h b/source/common/router/header_parser.h index 0f9859efa703..725f78a5e97c 100644 --- a/source/common/router/header_parser.h +++ b/source/common/router/header_parser.h @@ -1,11 +1,3 @@ -// grpcpp/grpcpp.h includes , so undef some interfering symbols -#ifdef WIN32 -#undef TRUE -#undef DELETE -#undef ERROR -#undef GetMessage -#endif - #pragma once #include From 3505e9901ca4b9d4b65407d4c44f238a2aa05215 Mon Sep 17 00:00:00 2001 From: Yechiel Kalmenson Date: Wed, 23 Oct 2019 10:34:37 -0400 Subject: [PATCH 03/12] Note open ticket for format exception Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- test/common/stream_info/test_util.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/common/stream_info/test_util.h b/test/common/stream_info/test_util.h index 467e3701ec15..6fbcb8120978 100644 --- a/test/common/stream_info/test_util.h +++ b/test/common/stream_info/test_util.h @@ -12,14 +12,16 @@ namespace Envoy { class TestStreamInfo : public StreamInfo::StreamInfo { public: TestStreamInfo() { + // TODO: Refactor out std::chrono for absl::Time, see + // https://github.com/envoyproxy/envoy/issues/8717 tm fake_time; memset(&fake_time, 0, sizeof(fake_time)); fake_time.tm_year = 99; // tm < 1901-12-13 20:45:52 is not valid on macOS fake_time.tm_mday = 1; #if !defined(WIN32) - start_time_ = std::chrono::system_clock::from_time_t(::timegm(&fake_time)); + start_time_ = std::chrono::system_clock::from_time_t(timegm(&fake_time)); #else - start_time_ = std::chrono::system_clock::from_time_t(::_mkgmtime(&fake_time)); + start_time_ = std::chrono::system_clock::from_time_t(_mkgmtime(&fake_time)); #endif MonotonicTime now = timeSystem().monotonicTime(); From 81724788290b79d88a01965c39f69f9ea8daf47e Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Wed, 23 Oct 2019 11:08:39 -0400 Subject: [PATCH 04/12] Ensure one-time variables per lizan's review Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- source/common/common/version.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/common/common/version.cc b/source/common/common/version.cc index 6fe70c9331e0..82c016c02dab 100644 --- a/source/common/common/version.cc +++ b/source/common/common/version.cc @@ -6,6 +6,8 @@ #include "common/common/macros.h" #include "common/common/version_linkstamp.h" +#include "absl/strings/string_view.h" + extern const char build_scm_revision[]; extern const char build_scm_status[]; @@ -20,14 +22,14 @@ const std::string& VersionInfo::revisionStatus() { const std::string& VersionInfo::version() { #ifdef NDEBUG - const std::string release_type = "RELEASE"; + const absl::string_view release_type = "RELEASE"; #else - const std::string release_type = "DEBUG"; + const absl::string_view release_type = "DEBUG"; #endif #ifdef ENVOY_SSL_VERSION - const std::string ssl_version = ENVOY_SSL_VERSION; + const absl::string_view ssl_version = ENVOY_SSL_VERSION; #else - const std::string ssl_version = "no-ssl"; + const absl::string_view ssl_version = "no-ssl"; #endif CONSTRUCT_ON_FIRST_USE(std::string, fmt::format("{}/{}/{}/{}/{}", revision(), BUILD_VERSION_NUMBER, From 55a7360e8a0e81e1e8df70ea7c0cf2ec51e3b67a Mon Sep 17 00:00:00 2001 From: Yechiel Kalmenson Date: Tue, 29 Oct 2019 11:01:17 -0400 Subject: [PATCH 05/12] Refactor platform-specific includes into platform.h The purpose of platform.h is to localize the inclusion of POSIX-specific, or Windows-specific common #include's from the C api. This is included when such networking or other constructs are needed -or- when 3rd party dependencies are including these definitions. This patch begins removing posix-specific headers into envoy/common/platform.h, which becomes the only origin of including windows.h API header files in the envoy build schema. This allows us to fix up issues where the Windows API is not a good C++ citizen (`#define interface` for many common keywords, etc.) Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- include/envoy/api/os_sys_calls.h | 9 +--- include/envoy/api/os_sys_calls_common.h | 2 + include/envoy/buffer/buffer.h | 1 + include/envoy/common/platform.h | 50 ++++++++++++++++++- include/envoy/network/address.h | 2 +- include/envoy/network/io_handle.h | 1 + source/common/common/byte_order.h | 5 +- source/common/common/fmt.h | 2 + source/common/common/perf_annotation.cc | 4 +- source/common/common/win32/thread_impl.h | 7 +-- .../win32/directory_iterator_impl.h | 10 ---- .../filesystem/win32/filesystem_impl.cc | 14 +----- source/common/grpc/common.cc | 2 - source/common/grpc/common.h | 1 + source/common/grpc/google_async_client_impl.h | 1 + source/common/grpc/google_grpc_creds_impl.h | 1 + source/common/grpc/google_grpc_utils.h | 1 + .../addr_family_aware_socket_option_impl.cc | 1 + .../addr_family_aware_socket_option_impl.h | 4 +- source/common/network/address_impl.cc | 6 +-- source/common/network/address_impl.h | 4 +- source/common/network/base_listener_impl.cc | 2 - source/common/network/cidr_range.cc | 2 + source/common/network/connection_impl.cc | 6 +-- source/common/network/dns_impl.cc | 6 +-- source/common/network/dns_impl.h | 3 +- source/common/network/io_socket_handle_impl.h | 1 + source/common/network/lc_trie.h | 3 +- source/common/network/listen_socket_impl.cc | 2 +- source/common/network/listen_socket_impl.h | 3 +- source/common/network/listener_impl.cc | 3 +- source/common/network/socket_option_factory.h | 4 +- source/common/network/socket_option_impl.h | 5 +- source/common/network/udp_listener_impl.cc | 3 +- source/common/network/utility.cc | 23 ++------- source/common/network/utility.h | 1 + source/common/protobuf/protobuf.h | 10 +--- source/common/tracing/http_tracer_impl.h | 8 +-- source/exe/win32/platform_impl.cc | 4 -- .../listener/proxy_protocol/proxy_protocol.cc | 3 -- .../listener/tls_inspector/tls_inspector.cc | 3 +- .../network/common/redis/codec_impl.cc | 2 + .../network/mysql_proxy/mysql_decoder.cc | 2 - .../network/mysql_proxy/mysql_utils.cc | 2 - .../quiche/envoy_quic_packet_writer.cc | 13 ----- .../quic_listeners/quiche/envoy_quic_utils.cc | 2 - .../quic_listeners/quiche/envoy_quic_utils.h | 12 +++++ .../platform/spdy_endianness_util_impl.h | 4 +- .../quiche/platform/string_utils.cc | 2 +- .../stat_sinks/common/statsd/statsd.cc | 2 + .../stat_sinks/common/statsd/statsd.h | 1 + .../transport_sockets/tls/context_impl.cc | 3 +- test/common/buffer/buffer_fuzz.cc | 3 +- test/common/grpc/common_test.cc | 2 +- test/common/grpc/context_impl_test.cc | 2 +- test/common/grpc/google_grpc_utils_test.cc | 2 +- test/common/http/http2/http2_frame.cc | 4 +- ...dr_family_aware_socket_option_impl_test.cc | 2 +- .../common/network/address_impl_speed_test.cc | 4 -- test/common/network/address_impl_test.cc | 8 +-- test/common/network/cidr_range_test.cc | 3 +- test/common/network/connection_impl_test.cc | 2 + test/config_test/config_test.cc | 4 +- test/exe/main_common_test.cc | 2 +- test/test_common/environment.cc | 4 +- test/test_common/network_utility.cc | 5 +- test/test_common/utility.cc | 18 ++----- 67 files changed, 136 insertions(+), 197 deletions(-) diff --git a/include/envoy/api/os_sys_calls.h b/include/envoy/api/os_sys_calls.h index e2213a0db0a1..e14fa20e90b9 100644 --- a/include/envoy/api/os_sys_calls.h +++ b/include/envoy/api/os_sys_calls.h @@ -1,20 +1,13 @@ #pragma once -#ifndef WIN32 -#include -#include // for mode_t -#include // for sockaddr #include -#include // for iovec - -#endif #include #include #include "envoy/api/os_sys_calls_common.h" -#include "envoy/common/pure.h" #include "envoy/common/platform.h" +#include "envoy/common/pure.h" namespace Envoy { namespace Api { diff --git a/include/envoy/api/os_sys_calls_common.h b/include/envoy/api/os_sys_calls_common.h index d85aed3407b2..4689e298977f 100644 --- a/include/envoy/api/os_sys_calls_common.h +++ b/include/envoy/api/os_sys_calls_common.h @@ -3,6 +3,8 @@ #include #include +#include "envoy/common/platform.h" + namespace Envoy { namespace Api { /** diff --git a/include/envoy/buffer/buffer.h b/include/envoy/buffer/buffer.h index 1e29bf5cd953..937d0a30faea 100644 --- a/include/envoy/buffer/buffer.h +++ b/include/envoy/buffer/buffer.h @@ -7,6 +7,7 @@ #include "envoy/api/os_sys_calls.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" #include "envoy/network/io_handle.h" diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index b83a7f71c222..8af72f891398 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -1,7 +1,29 @@ #pragma once - // NOLINT(namespace-envoy) + +// This common "platform.h" header exists to simplify the most common references +// to non-ANSI C/C++ headers, required on windows, posix, linux, bsd etc, +// and to provide substitute definitions when absolutely required. +// +// The goal is to eventually not require this file of envoy header declarations, +// but limit the use of these architecture-specific types and declarations +// to the corresponding .cc implementation files. + #ifdef _MSC_VER + +#include +#include +#include +#include + +// defines some frequently used symbols, so we need to undef these interfering symbols. +#undef DELETE +#undef ERROR +#undef GetMessage +#undef interface +#undef TRUE + +#include #include #define PACKED_STRUCT(definition, ...) \ @@ -10,7 +32,31 @@ using ssize_t = ptrdiff_t; -#else +typedef unsigned int sa_family_t; + +#else // POSIX + +#include +#include +#include +#include +#include +#include +#include // for mode_t +#include +#include // for iovec +#include +#include + +#if defined(__linux__) +#include +#endif + #define PACKED_STRUCT(definition, ...) definition, ##__VA_ARGS__ __attribute__((packed)) +#ifndef IP6T_SO_ORIGINAL_DST +// From linux/netfilter_ipv6/ip6_tables.h +#define IP6T_SO_ORIGINAL_DST 80 +#endif + #endif diff --git a/include/envoy/network/address.h b/include/envoy/network/address.h index 86d32eca2452..2e1e228ff328 100644 --- a/include/envoy/network/address.h +++ b/include/envoy/network/address.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -9,6 +8,7 @@ #include #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" #include "envoy/network/io_handle.h" diff --git a/include/envoy/network/io_handle.h b/include/envoy/network/io_handle.h index 5062fae0c317..1260fb411d12 100644 --- a/include/envoy/network/io_handle.h +++ b/include/envoy/network/io_handle.h @@ -1,6 +1,7 @@ #pragma once #include "envoy/api/io_error.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" namespace Envoy { diff --git a/source/common/common/byte_order.h b/source/common/common/byte_order.h index 2728220e7393..1ca0286399b6 100644 --- a/source/common/common/byte_order.h +++ b/source/common/common/byte_order.h @@ -25,10 +25,7 @@ #elif WIN32 -#include -// includes , so undef some interfering symbols -#undef DELETE -#undef GetMessage +#include "envoy/common/platform.h" #define htole16(x) (x) #define htole32(x) (x) diff --git a/source/common/common/fmt.h b/source/common/common/fmt.h index ba019fabe46a..1c37d0cf32b6 100644 --- a/source/common/common/fmt.h +++ b/source/common/common/fmt.h @@ -1,5 +1,7 @@ #pragma once +#include "envoy/common/platform.h" // Avert format.h including windows.h + #include "absl/strings/string_view.h" #include "fmt/format.h" #include "fmt/ostream.h" diff --git a/source/common/common/perf_annotation.cc b/source/common/common/perf_annotation.cc index b31eb76a5548..f2c8afeb3ff2 100644 --- a/source/common/common/perf_annotation.cc +++ b/source/common/common/perf_annotation.cc @@ -4,12 +4,12 @@ #include "common/common/perf_annotation.h" -#include - #include #include #include +#include "envoy/common/platform.h" + #include "common/common/lock_guard.h" #include "common/common/utility.h" diff --git a/source/common/common/win32/thread_impl.h b/source/common/common/win32/thread_impl.h index a8c74eb5d21a..76d61a459943 100644 --- a/source/common/common/win32/thread_impl.h +++ b/source/common/common/win32/thread_impl.h @@ -1,13 +1,8 @@ #pragma once -#include - -// defines some macros that interfere with our code, so undef them -#undef DELETE -#undef GetMessage - #include +#include "envoy/common/platform.h" #include "envoy/thread/thread.h" namespace Envoy { diff --git a/source/common/filesystem/win32/directory_iterator_impl.h b/source/common/filesystem/win32/directory_iterator_impl.h index 6a9713f87b51..bfeed6dde6cc 100644 --- a/source/common/filesystem/win32/directory_iterator_impl.h +++ b/source/common/filesystem/win32/directory_iterator_impl.h @@ -1,15 +1,5 @@ #pragma once -#include - -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage - #include "envoy/filesystem/filesystem.h" namespace Envoy { diff --git a/source/common/filesystem/win32/filesystem_impl.cc b/source/common/filesystem/win32/filesystem_impl.cc index cc08abbc924c..e25fef1d708e 100644 --- a/source/common/filesystem/win32/filesystem_impl.cc +++ b/source/common/filesystem/win32/filesystem_impl.cc @@ -1,18 +1,6 @@ #include #include #include -#include - -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage - -#include "common/common/assert.h" -#include "common/filesystem/filesystem_impl.h" #include #include @@ -21,7 +9,9 @@ #include "envoy/common/exception.h" +#include "common/common/assert.h" #include "common/common/fmt.h" +#include "common/filesystem/filesystem_impl.h" namespace Envoy { namespace Filesystem { diff --git a/source/common/grpc/common.cc b/source/common/grpc/common.cc index 4299fddd6f3e..54c4b3b9639c 100644 --- a/source/common/grpc/common.cc +++ b/source/common/grpc/common.cc @@ -1,7 +1,5 @@ #include "common/grpc/common.h" -#include - #include #include #include diff --git a/source/common/grpc/common.h b/source/common/grpc/common.h index 32f4fd02ee36..e5939eaee45f 100644 --- a/source/common/grpc/common.h +++ b/source/common/grpc/common.h @@ -4,6 +4,7 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/grpc/status.h" #include "envoy/http/filter.h" #include "envoy/http/header_map.h" diff --git a/source/common/grpc/google_async_client_impl.h b/source/common/grpc/google_async_client_impl.h index 09ef09b951bc..edc633a08d4d 100644 --- a/source/common/grpc/google_async_client_impl.h +++ b/source/common/grpc/google_async_client_impl.h @@ -3,6 +3,7 @@ #include #include "envoy/api/api.h" +#include "envoy/common/platform.h" #include "envoy/grpc/async_client.h" #include "envoy/stats/scope.h" #include "envoy/thread/thread.h" diff --git a/source/common/grpc/google_grpc_creds_impl.h b/source/common/grpc/google_grpc_creds_impl.h index c7104f6a32d0..485a6ba75ad8 100644 --- a/source/common/grpc/google_grpc_creds_impl.h +++ b/source/common/grpc/google_grpc_creds_impl.h @@ -2,6 +2,7 @@ #include "envoy/api/api.h" #include "envoy/api/v2/core/grpc_service.pb.h" +#include "envoy/common/platform.h" #include "grpcpp/grpcpp.h" diff --git a/source/common/grpc/google_grpc_utils.h b/source/common/grpc/google_grpc_utils.h index 9500ce0589b3..476aeaa3ee22 100644 --- a/source/common/grpc/google_grpc_utils.h +++ b/source/common/grpc/google_grpc_utils.h @@ -4,6 +4,7 @@ #include #include "envoy/buffer/buffer.h" +#include "envoy/common/platform.h" #include "grpcpp/grpcpp.h" diff --git a/source/common/network/addr_family_aware_socket_option_impl.cc b/source/common/network/addr_family_aware_socket_option_impl.cc index 2e06974f5aa3..ffa31a96f565 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.cc +++ b/source/common/network/addr_family_aware_socket_option_impl.cc @@ -1,6 +1,7 @@ #include "common/network/addr_family_aware_socket_option_impl.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/addr_family_aware_socket_option_impl.h b/source/common/network/addr_family_aware_socket_option_impl.h index b54eb244f187..1e8b463dbd4a 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.h +++ b/source/common/network/addr_family_aware_socket_option_impl.h @@ -1,8 +1,6 @@ #pragma once -#include -#include - +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/logger.h" diff --git a/source/common/network/address_impl.cc b/source/common/network/address_impl.cc index ab5244844c0d..5152a64cfecc 100644 --- a/source/common/network/address_impl.cc +++ b/source/common/network/address_impl.cc @@ -1,15 +1,11 @@ #include "common/network/address_impl.h" -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/address_impl.h b/source/common/network/address_impl.h index 63e0566ffaaa..d35ca44842a8 100644 --- a/source/common/network/address_impl.h +++ b/source/common/network/address_impl.h @@ -1,14 +1,12 @@ #pragma once -#include -#include #include -#include #include #include #include +#include "envoy/common/platform.h" #include "envoy/network/address.h" #include "envoy/network/io_handle.h" diff --git a/source/common/network/base_listener_impl.cc b/source/common/network/base_listener_impl.cc index 7340dd693bc5..2377c48b4595 100644 --- a/source/common/network/base_listener_impl.cc +++ b/source/common/network/base_listener_impl.cc @@ -1,7 +1,5 @@ #include "common/network/base_listener_impl.h" -#include - #include "envoy/common/exception.h" #include "common/common/assert.h" diff --git a/source/common/network/cidr_range.cc b/source/common/network/cidr_range.cc index 50b33dccbd64..a9c6f508d571 100644 --- a/source/common/network/cidr_range.cc +++ b/source/common/network/cidr_range.cc @@ -1,8 +1,10 @@ #include "common/network/cidr_range.h" +#ifndef WIN32 #include #include #include +#endif #include #include diff --git a/source/common/network/connection_impl.cc b/source/common/network/connection_impl.cc index 44b073083c1c..933d2940b440 100644 --- a/source/common/network/connection_impl.cc +++ b/source/common/network/connection_impl.cc @@ -1,15 +1,11 @@ #include "common/network/connection_impl.h" -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/timer.h" #include "envoy/network/filter.h" diff --git a/source/common/network/dns_impl.cc b/source/common/network/dns_impl.cc index c4409d473b6b..97265959314f 100644 --- a/source/common/network/dns_impl.cc +++ b/source/common/network/dns_impl.cc @@ -1,15 +1,13 @@ #include "common/network/dns_impl.h" -#include -#include -#include - #include #include #include #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/source/common/network/dns_impl.h b/source/common/network/dns_impl.h index 096c2c71178f..8f73c8922504 100644 --- a/source/common/network/dns_impl.h +++ b/source/common/network/dns_impl.h @@ -1,11 +1,10 @@ #pragma once -#include - #include #include #include +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/event/file_event.h" #include "envoy/network/dns.h" diff --git a/source/common/network/io_socket_handle_impl.h b/source/common/network/io_socket_handle_impl.h index 78e6211d35da..cce287eab60b 100644 --- a/source/common/network/io_socket_handle_impl.h +++ b/source/common/network/io_socket_handle_impl.h @@ -2,6 +2,7 @@ #include "envoy/api/io_error.h" #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/network/io_handle.h" #include "common/common/logger.h" diff --git a/source/common/network/lc_trie.h b/source/common/network/lc_trie.h index cf6dfdb0d65a..7039642b17ab 100644 --- a/source/common/network/lc_trie.h +++ b/source/common/network/lc_trie.h @@ -1,12 +1,11 @@ #pragma once -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/network/address.h" #include "common/common/assert.h" diff --git a/source/common/network/listen_socket_impl.cc b/source/common/network/listen_socket_impl.cc index dc9e8991805c..aac2196dc98d 100644 --- a/source/common/network/listen_socket_impl.cc +++ b/source/common/network/listen_socket_impl.cc @@ -1,11 +1,11 @@ #include "common/network/listen_socket_impl.h" -#include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/listen_socket_impl.h b/source/common/network/listen_socket_impl.h index c737afddb466..0acd6aa83bc2 100644 --- a/source/common/network/listen_socket_impl.h +++ b/source/common/network/listen_socket_impl.h @@ -1,11 +1,10 @@ #pragma once -#include - #include #include #include +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "envoy/network/listen_socket.h" diff --git a/source/common/network/listener_impl.cc b/source/common/network/listener_impl.cc index bd0679464cc3..f31795ca7271 100644 --- a/source/common/network/listener_impl.cc +++ b/source/common/network/listener_impl.cc @@ -1,7 +1,6 @@ #include "common/network/listener_impl.h" -#include - +#include "envoy/common/platform.h" #include "envoy/common/exception.h" #include "common/common/assert.h" diff --git a/source/common/network/socket_option_factory.h b/source/common/network/socket_option_factory.h index 6fb2f2f5abad..73a9b9ade1cb 100644 --- a/source/common/network/socket_option_factory.h +++ b/source/common/network/socket_option_factory.h @@ -1,8 +1,6 @@ #pragma once -#include -#include - +#include "envoy/common/platform.h" #include "envoy/api/v2/core/address.pb.h" #include "envoy/network/listen_socket.h" diff --git a/source/common/network/socket_option_impl.h b/source/common/network/socket_option_impl.h index 1a13a67010cb..577608f1a778 100644 --- a/source/common/network/socket_option_impl.h +++ b/source/common/network/socket_option_impl.h @@ -1,10 +1,7 @@ #pragma once -#include -#include -#include - #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/assert.h" diff --git a/source/common/network/udp_listener_impl.cc b/source/common/network/udp_listener_impl.cc index a3c5237e60f1..a89bc20f5930 100644 --- a/source/common/network/udp_listener_impl.cc +++ b/source/common/network/udp_listener_impl.cc @@ -1,13 +1,12 @@ #include "common/network/udp_listener_impl.h" -#include - #include #include #include #include "envoy/buffer/buffer.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/utility.cc b/source/common/network/utility.cc index 667d0ccc997f..4c9034cbfb0c 100644 --- a/source/common/network/utility.cc +++ b/source/common/network/utility.cc @@ -1,20 +1,5 @@ #include "common/network/utility.h" -#include -#include - -#if defined(__linux__) -#include -#endif - -#ifndef IP6T_SO_ORIGINAL_DST -// From linux/netfilter_ipv6/ip6_tables.h -#define IP6T_SO_ORIGINAL_DST 80 -#endif - -#include -#include - #include #include #include @@ -22,18 +7,18 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "common/api/os_sys_calls_impl.h" +#include "common/buffer/buffer_impl.h" #include "common/common/assert.h" #include "common/common/cleanup.h" +#include "common/common/fmt.h" #include "common/common/utility.h" -#include "common/buffer/buffer_impl.h" #include "common/network/address_impl.h" -#include "common/protobuf/protobuf.h" #include "common/network/io_socket_error_impl.h" - -#include "common/common/fmt.h" +#include "common/protobuf/protobuf.h" #include "absl/strings/match.h" diff --git a/source/common/network/utility.h b/source/common/network/utility.h index 53d3db2c75e6..34443c219f1b 100644 --- a/source/common/network/utility.h +++ b/source/common/network/utility.h @@ -5,6 +5,7 @@ #include #include "envoy/api/v2/core/address.pb.h" +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "absl/strings/string_view.h" diff --git a/source/common/protobuf/protobuf.h b/source/common/protobuf/protobuf.h index d0b2a5e1229d..4cf6fe865fc5 100644 --- a/source/common/protobuf/protobuf.h +++ b/source/common/protobuf/protobuf.h @@ -4,6 +4,8 @@ #include #include +#include "envoy/common/platform.h" + #include "google/protobuf/any.pb.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" @@ -27,14 +29,6 @@ #include "google/protobuf/util/type_resolver_util.h" #include "google/protobuf/wrappers.pb.h" -#ifdef WIN32 -// one of the above headers includes , so undef some interfering symbols -#undef TRUE -#undef DELETE -#undef ERROR -#undef GetMessage -#endif - namespace Envoy { // All references to google::protobuf in Envoy need to be made via the diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index 8906fe4e6a0d..4d0cc4ec05c2 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -2,6 +2,7 @@ #include +#include "envoy/common/platform.h" #include "envoy/local_info/local_info.h" #include "envoy/runtime/runtime.h" #include "envoy/thread_local/thread_local.h" @@ -11,13 +12,6 @@ #include "common/http/header_map_impl.h" #include "common/json/json_loader.h" -#ifdef WIN32 -// defines macros for ERROR and TRUE, so we need to undef them in -// case it's been included above -#undef ERROR -#undef TRUE -#endif - namespace Envoy { namespace Tracing { diff --git a/source/exe/win32/platform_impl.cc b/source/exe/win32/platform_impl.cc index 674ad0db0b1f..5db56c722521 100644 --- a/source/exe/win32/platform_impl.cc +++ b/source/exe/win32/platform_impl.cc @@ -4,10 +4,6 @@ #include "exe/platform_impl.h" -// clang-format off -#include -// clang-format on - namespace Envoy { PlatformImpl::PlatformImpl() diff --git a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc index f4dce6138b9c..ab4acf68d871 100644 --- a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc +++ b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc @@ -1,8 +1,5 @@ #include "extensions/filters/listener/proxy_protocol/proxy_protocol.h" -#include -#include - #include #include #include diff --git a/source/extensions/filters/listener/tls_inspector/tls_inspector.cc b/source/extensions/filters/listener/tls_inspector/tls_inspector.cc index d38ca293f81c..af7f79869bca 100644 --- a/source/extensions/filters/listener/tls_inspector/tls_inspector.cc +++ b/source/extensions/filters/listener/tls_inspector/tls_inspector.cc @@ -1,12 +1,11 @@ #include "extensions/filters/listener/tls_inspector/tls_inspector.h" -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/network/listen_socket.h" #include "envoy/stats/scope.h" diff --git a/source/extensions/filters/network/common/redis/codec_impl.cc b/source/extensions/filters/network/common/redis/codec_impl.cc index 4c80b43ff512..d6a25add3a6b 100644 --- a/source/extensions/filters/network/common/redis/codec_impl.cc +++ b/source/extensions/filters/network/common/redis/codec_impl.cc @@ -5,6 +5,8 @@ #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/common/stack_array.h" diff --git a/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc b/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc index b59a5b4cde23..3d9f821f5b84 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc +++ b/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc @@ -1,7 +1,5 @@ #include "extensions/filters/network/mysql_proxy/mysql_decoder.h" -#include - #include "extensions/filters/network/mysql_proxy/mysql_utils.h" namespace Envoy { diff --git a/source/extensions/filters/network/mysql_proxy/mysql_utils.cc b/source/extensions/filters/network/mysql_proxy/mysql_utils.cc index ed8a86f47c04..9e154fa69167 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_utils.cc +++ b/source/extensions/filters/network/mysql_proxy/mysql_utils.cc @@ -1,7 +1,5 @@ #include "extensions/filters/network/mysql_proxy/mysql_utils.h" -#include - namespace Envoy { namespace Extensions { namespace NetworkFilters { diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc index 02360ae9b66c..516df03728e0 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc @@ -1,18 +1,5 @@ #include "extensions/quic_listeners/quiche/envoy_quic_packet_writer.h" -#include - -#pragma GCC diagnostic push - -// QUICHE allows unused parameters. -#pragma GCC diagnostic ignored "-Wunused-parameter" -// QUICHE uses offsetof(). -#pragma GCC diagnostic ignored "-Winvalid-offsetof" - -#include "quiche/quic/core/quic_types.h" - -#pragma GCC diagnostic pop - #include "extensions/quic_listeners/quiche/envoy_quic_utils.h" #include "common/buffer/buffer_impl.h" #include "common/network/utility.h" diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc b/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc index 33e0c43fc035..6d257d974474 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc @@ -1,7 +1,5 @@ #include "extensions/quic_listeners/quiche/envoy_quic_utils.h" -#include - namespace Envoy { namespace Quic { diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_utils.h b/source/extensions/quic_listeners/quiche/envoy_quic_utils.h index 54b1bf07f603..9870bb8fd8bf 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_utils.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_utils.h @@ -1,9 +1,21 @@ +#include "envoy/common/platform.h" #include "envoy/http/codec.h" #include "common/common/assert.h" #include "common/http/header_map_impl.h" #include "common/network/address_impl.h" +#pragma GCC diagnostic push + +// QUICHE allows unused parameters. +#pragma GCC diagnostic ignored "-Wunused-parameter" +// QUICHE uses offsetof(). +#pragma GCC diagnostic ignored "-Winvalid-offsetof" + +#include "quiche/quic/core/quic_types.h" + +#pragma GCC diagnostic pop + #include "quiche/quic/core/http/quic_header_list.h" #include "quiche/quic/core/quic_error_codes.h" #include "quiche/quic/platform/api/quic_ip_address.h" diff --git a/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h b/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h index f72c476b34f8..737b81ee2914 100644 --- a/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include "envoy/common/platform.h" + // NOLINT(namespace-envoy) // This file is part of the QUICHE platform implementation, and is not to be diff --git a/source/extensions/quic_listeners/quiche/platform/string_utils.cc b/source/extensions/quic_listeners/quiche/platform/string_utils.cc index 2bcbc11c4190..d9999ac9b0ab 100644 --- a/source/extensions/quic_listeners/quiche/platform/string_utils.cc +++ b/source/extensions/quic_listeners/quiche/platform/string_utils.cc @@ -6,10 +6,10 @@ // consumed or referenced directly by other Envoy code. It serves purely as a // porting layer for QUICHE. -#include #include #include +#include "envoy/common/platform.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" diff --git a/source/extensions/stat_sinks/common/statsd/statsd.cc b/source/extensions/stat_sinks/common/statsd/statsd.cc index 028835aa5562..7ff01d2a5577 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.cc +++ b/source/extensions/stat_sinks/common/statsd/statsd.cc @@ -5,10 +5,12 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/stats/scope.h" #include "envoy/upstream/cluster_manager.h" +#include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/common/utility.h" diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index a6eb91a62750..7d1dd18be2ca 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -1,5 +1,6 @@ #pragma once +#include "envoy/common/platform.h" #include "envoy/local_info/local_info.h" #include "envoy/network/connection.h" #include "envoy/stats/histogram.h" diff --git a/source/extensions/transport_sockets/tls/context_impl.cc b/source/extensions/transport_sockets/tls/context_impl.cc index ed8e54c08449..597cc2b1950a 100644 --- a/source/extensions/transport_sockets/tls/context_impl.cc +++ b/source/extensions/transport_sockets/tls/context_impl.cc @@ -1,13 +1,12 @@ #include "extensions/transport_sockets/tls/context_impl.h" -#include - #include #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/stats/scope.h" #include "common/common/assert.h" diff --git a/test/common/buffer/buffer_fuzz.cc b/test/common/buffer/buffer_fuzz.cc index fe2453905ce6..b419da61f8ba 100644 --- a/test/common/buffer/buffer_fuzz.cc +++ b/test/common/buffer/buffer_fuzz.cc @@ -1,7 +1,8 @@ #include "test/common/buffer/buffer_fuzz.h" #include -#include + +#include "envoy/common/platform.h" #include "common/buffer/buffer_impl.h" #include "common/common/assert.h" diff --git a/test/common/grpc/common_test.cc b/test/common/grpc/common_test.cc index 68128c7faf71..ec3f6d7cff91 100644 --- a/test/common/grpc/common_test.cc +++ b/test/common/grpc/common_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/common.h" #include "common/http/headers.h" diff --git a/test/common/grpc/context_impl_test.cc b/test/common/grpc/context_impl_test.cc index 6cd6c47b3b62..e75434e0595d 100644 --- a/test/common/grpc/context_impl_test.cc +++ b/test/common/grpc/context_impl_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/common.h" #include "common/grpc/context_impl.h" diff --git a/test/common/grpc/google_grpc_utils_test.cc b/test/common/grpc/google_grpc_utils_test.cc index 20a9836f6a20..f115d1ab3015 100644 --- a/test/common/grpc/google_grpc_utils_test.cc +++ b/test/common/grpc/google_grpc_utils_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/google_grpc_utils.h" diff --git a/test/common/http/http2/http2_frame.cc b/test/common/http/http2/http2_frame.cc index 8667888eff82..ff1cc19360b0 100644 --- a/test/common/http/http2/http2_frame.cc +++ b/test/common/http/http2/http2_frame.cc @@ -1,9 +1,9 @@ #include "test/common/http/http2/http2_frame.h" -#include - #include +#include "envoy/common/platform.h" + namespace { // Make request stream ID in the network byte order diff --git a/test/common/network/addr_family_aware_socket_option_impl_test.cc b/test/common/network/addr_family_aware_socket_option_impl_test.cc index 379029dc2d24..c6c6d97fbe78 100644 --- a/test/common/network/addr_family_aware_socket_option_impl_test.cc +++ b/test/common/network/addr_family_aware_socket_option_impl_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/network/addr_family_aware_socket_option_impl.h" #include "common/network/io_socket_handle_impl.h" diff --git a/test/common/network/address_impl_speed_test.cc b/test/common/network/address_impl_speed_test.cc index 481bc9a9d9f8..8694b66fb44f 100644 --- a/test/common/network/address_impl_speed_test.cc +++ b/test/common/network/address_impl_speed_test.cc @@ -1,7 +1,3 @@ -#include -#include -#include - #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/test/common/network/address_impl_test.cc b/test/common/network/address_impl_test.cc index fe4b75217a3d..59c7b337ca5f 100644 --- a/test/common/network/address_impl_test.cc +++ b/test/common/network/address_impl_test.cc @@ -1,15 +1,9 @@ -#include -#include -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/fmt.h" #include "common/common/utility.h" diff --git a/test/common/network/cidr_range_test.cc b/test/common/network/cidr_range_test.cc index 5f722cd1395f..51d9efd75435 100644 --- a/test/common/network/cidr_range_test.cc +++ b/test/common/network/cidr_range_test.cc @@ -1,9 +1,8 @@ -#include - #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/fmt.h" #include "common/json/json_loader.h" diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 164bcea2bb6f..0e69c4d2297b 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -2,6 +2,8 @@ #include #include +#include "envoy/common/platform.h" + #include "common/buffer/buffer_impl.h" #include "common/common/empty_string.h" #include "common/common/fmt.h" diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 72c86b235b92..ad9461143346 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -1,9 +1,9 @@ -#include - #include #include #include +#include "envoy/common/platform.h" + #include "common/common/fmt.h" #include "common/protobuf/utility.h" #include "common/runtime/runtime_features.h" diff --git a/test/exe/main_common_test.cc b/test/exe/main_common_test.cc index 801fb8341a95..b34207ccd5b5 100644 --- a/test/exe/main_common_test.cc +++ b/test/exe/main_common_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/common/lock_guard.h" #include "common/common/mutex_tracer_impl.h" diff --git a/test/test_common/environment.cc b/test/test_common/environment.cc index ec27ffbaa93e..e6fe06c0df3e 100644 --- a/test/test_common/environment.cc +++ b/test/test_common/environment.cc @@ -1,8 +1,5 @@ #include "test/test_common/environment.h" -#include -#include - // TODO(asraa): Remove and rely only on when Envoy requires // Clang >= 9. #if defined(_LIBCPP_VERSION) && !defined(__APPLE__) @@ -25,6 +22,7 @@ #include "common/common/logger.h" #include "common/common/macros.h" #include "common/common/utility.h" +#include "envoy/common/platform.h" #include "server/options_impl.h" diff --git a/test/test_common/network_utility.cc b/test/test_common/network_utility.cc index 430614e50327..cc278bf6e4b7 100644 --- a/test/test_common/network_utility.cc +++ b/test/test_common/network_utility.cc @@ -1,11 +1,10 @@ #include "test/test_common/network_utility.h" -#include -#include - #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index 7b2ba59c3cd5..c8a9990984ca 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -1,16 +1,5 @@ #include "utility.h" -#ifdef WIN32 -#include -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage -#endif - #include #include #include @@ -26,6 +15,7 @@ #include "envoy/api/v2/rds.pb.h" #include "envoy/api/v2/route/route.pb.h" #include "envoy/buffer/buffer.h" +#include "envoy/common/platform.h" #include "envoy/http/codec.h" #include "envoy/service/discovery/v2/rtds.pb.h" @@ -37,18 +27,18 @@ #include "common/common/thread_impl.h" #include "common/common/utility.h" #include "common/config/resources.h" +#include "common/filesystem/directory.h" +#include "common/filesystem/filesystem_impl.h" #include "common/json/json_loader.h" #include "common/network/address_impl.h" #include "common/network/utility.h" -#include "common/filesystem/directory.h" -#include "common/filesystem/filesystem_impl.h" +#include "test/mocks/stats/mocks.h" #include "test/test_common/printers.h" #include "test/test_common/test_time.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "test/mocks/stats/mocks.h" #include "gtest/gtest.h" using testing::GTEST_FLAG(random_seed); From bbf2f055336e8cf6e2b7e9000bd0ccedbfad8791 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Tue, 29 Oct 2019 11:32:00 -0400 Subject: [PATCH 06/12] Use '!' expression syntax, rather than 'not' Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- source/server/listener_impl.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index 32661629bd52..bec30d337b54 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -172,11 +172,11 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st (matcher.transport_protocol().empty() && (!matcher.server_names().empty() || !matcher.application_protocols().empty())); }) && - not std::any_of(config.listener_filters().begin(), config.listener_filters().end(), - [](const auto& filter) { - return filter.name() == - Extensions::ListenerFilters::ListenerFilterNames::get().TlsInspector; - }); + !std::any_of(config.listener_filters().begin(), config.listener_filters().end(), + [](const auto& filter) { + return filter.name() == + Extensions::ListenerFilters::ListenerFilterNames::get().TlsInspector; + }); // Automatically inject TLS Inspector if it wasn't configured explicitly and it's needed. if (need_tls_inspector) { const std::string message = @@ -316,4 +316,4 @@ void ListenerImpl::setSocket(const Network::SocketSharedPtr& socket) { } } // namespace Server -} // namespace Envoy \ No newline at end of file +} // namespace Envoy From 586fbbf6c24a04fbfeef26e880c537ff5bed74dd Mon Sep 17 00:00:00 2001 From: Yechiel Kalmenson Date: Tue, 29 Oct 2019 18:16:15 -0400 Subject: [PATCH 07/12] Small corrections for check_format.py Introduced a comment to allow windows/winsock to occur prior to mswsock (in spite of alpha ordering) Still, the pre-existing gmtime alert persists until this ticket is addressed in some future PR; https://github.com/envoyproxy/envoy/issues/8717 Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- include/envoy/common/platform.h | 6 ++++-- source/common/network/listener_impl.cc | 2 +- source/common/network/socket_option_factory.h | 2 +- .../quic_listeners/quiche/envoy_quic_packet_writer.cc | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 8af72f891398..540ef3f7b4d6 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -13,6 +13,8 @@ #include #include + +// These must follow afterwards #include #include @@ -42,9 +44,9 @@ typedef unsigned int sa_family_t; #include #include #include -#include // for mode_t +#include // for mode_t #include -#include // for iovec +#include // for iovec #include #include diff --git a/source/common/network/listener_impl.cc b/source/common/network/listener_impl.cc index f31795ca7271..84498125d511 100644 --- a/source/common/network/listener_impl.cc +++ b/source/common/network/listener_impl.cc @@ -1,7 +1,7 @@ #include "common/network/listener_impl.h" -#include "envoy/common/platform.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/assert.h" #include "common/common/empty_string.h" diff --git a/source/common/network/socket_option_factory.h b/source/common/network/socket_option_factory.h index 73a9b9ade1cb..f9b02f04864e 100644 --- a/source/common/network/socket_option_factory.h +++ b/source/common/network/socket_option_factory.h @@ -1,7 +1,7 @@ #pragma once -#include "envoy/common/platform.h" #include "envoy/api/v2/core/address.pb.h" +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/logger.h" diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc index 516df03728e0..0fca1ea83772 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc @@ -1,9 +1,10 @@ #include "extensions/quic_listeners/quiche/envoy_quic_packet_writer.h" -#include "extensions/quic_listeners/quiche/envoy_quic_utils.h" #include "common/buffer/buffer_impl.h" #include "common/network/utility.h" +#include "extensions/quic_listeners/quiche/envoy_quic_utils.h" + namespace Envoy { namespace Quic { EnvoyQuicPacketWriter::EnvoyQuicPacketWriter(Network::Socket& socket) From e5fb28d485c88ac0cd1c4256c4d6fe2913c4db1c Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Wed, 30 Oct 2019 10:07:08 -0400 Subject: [PATCH 08/12] Add patch comments, set aside specific patch for later per htuch Added comments for tclap and nghttp2 patches which are less likely to be seen at this project in the near-term. (Feel free to simplify.) Withdrew changes to echo_integration_test until we better understand the appropriate fix. The remaining PR is not blocked on this change. https://github.com/envoyproxy/envoy/pull/8572/files/81724788290b79d88a01965c39f69f9ea8daf47e#r338447233 Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- bazel/repositories.bzl | 8 ++++++++ test/integration/echo_integration_test.cc | 14 ++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index b7c525b2a1d7..fd87cdc7dfc7 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -245,6 +245,10 @@ def _com_github_eile_tclap(): name = "com_github_eile_tclap", build_file = "@envoy//bazel/external:tclap.BUILD", patch_args = ["-p1"], + # If and when we pick up tclap 1.4 or later release, + # this entire issue was refactored away 6 years ago; + # https://sourceforge.net/p/tclap/code/ci/5d4ffbf2db794af799b8c5727fb6c65c079195ac/ + # https://github.com/envoyproxy/envoy/pull/8572#discussion_r337554195 patches = ["@envoy//bazel:tclap-win64-ull-sizet.patch"], ) native.bind( @@ -346,6 +350,10 @@ def _com_github_nghttp2_nghttp2(): name = "com_github_nghttp2_nghttp2", build_file_content = BUILD_ALL_CONTENT, patch_args = ["-p1"], + # This patch cannot be picked up due to ABI rules. Better + # solve is likely at the next version-major. Discussion at; + # https://github.com/nghttp2/nghttp2/pull/1395 + # https://github.com/envoyproxy/envoy/pull/8572#discussion_r334067786 patches = ["@envoy//bazel/foreign_cc:nghttp2.patch"], **location ) diff --git a/test/integration/echo_integration_test.cc b/test/integration/echo_integration_test.cc index be26d89db31e..c60cf8452b03 100644 --- a/test/integration/echo_integration_test.cc +++ b/test/integration/echo_integration_test.cc @@ -49,16 +49,15 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, EchoIntegrationTest, TEST_P(EchoIntegrationTest, Hello) { Buffer::OwnedImpl buffer("hello"); std::string response; - std::unique_ptr connection; - connection = std::make_unique( + RawConnectionDriver connection( lookupPort("listener_0"), buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(data.toString()); - connection->close(); + connection.close(); }, version_); - connection->run(); + connection.run(); EXPECT_EQ("hello", response); } @@ -100,15 +99,14 @@ name: new_listener Buffer::OwnedImpl buffer("hello"); std::string response; - std::unique_ptr connection; - connection = std::make_unique( + RawConnectionDriver connection( new_listener_port, buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(data.toString()); - connection->close(); + connection.close(); }, version_); - connection->run(); + connection.run(); EXPECT_EQ("hello", response); // Remove the listener. From 5e98c8305e3458bc798d12fbaf6326e8122a0f7a Mon Sep 17 00:00:00 2001 From: Yechiel Kalmenson Date: Fri, 1 Nov 2019 10:20:56 -0400 Subject: [PATCH 09/12] Minor corrections identified by htuch Catch missing use of platform.h Using int constants for clarity Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- source/common/network/cidr_range.cc | 7 +------ source/common/router/retry_state_impl.cc | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/source/common/network/cidr_range.cc b/source/common/network/cidr_range.cc index a9c6f508d571..f59686389a88 100644 --- a/source/common/network/cidr_range.cc +++ b/source/common/network/cidr_range.cc @@ -1,17 +1,12 @@ #include "common/network/cidr_range.h" -#ifndef WIN32 -#include -#include -#include -#endif - #include #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/assert.h" #include "common/common/fmt.h" diff --git a/source/common/router/retry_state_impl.cc b/source/common/router/retry_state_impl.cc index 5b03df19e3c4..63e879e333e5 100644 --- a/source/common/router/retry_state_impl.cc +++ b/source/common/router/retry_state_impl.cc @@ -92,10 +92,10 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, Http::HeaderMap& if (!retriable_request_headers_.empty()) { // If this route limits retries by request headers, make sure there is a match. - uint32_t request_header_match = false; + uint32_t request_header_match = 0; for (const auto& retriable_header : retriable_request_headers_) { if (retriable_header->matchesHeaders(request_headers)) { - request_header_match = true; + request_header_match = 1; break; } } From ac0ee9ec0cb94a239d85573fcc663779b81459c7 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Fri, 1 Nov 2019 10:26:48 -0400 Subject: [PATCH 10/12] Withdraw patch for a later fix using absl::Time Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- test/common/stream_info/test_util.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/common/stream_info/test_util.h b/test/common/stream_info/test_util.h index 6fbcb8120978..83627789c3dc 100644 --- a/test/common/stream_info/test_util.h +++ b/test/common/stream_info/test_util.h @@ -12,17 +12,11 @@ namespace Envoy { class TestStreamInfo : public StreamInfo::StreamInfo { public: TestStreamInfo() { - // TODO: Refactor out std::chrono for absl::Time, see - // https://github.com/envoyproxy/envoy/issues/8717 tm fake_time; memset(&fake_time, 0, sizeof(fake_time)); fake_time.tm_year = 99; // tm < 1901-12-13 20:45:52 is not valid on macOS fake_time.tm_mday = 1; -#if !defined(WIN32) start_time_ = std::chrono::system_clock::from_time_t(timegm(&fake_time)); -#else - start_time_ = std::chrono::system_clock::from_time_t(_mkgmtime(&fake_time)); -#endif MonotonicTime now = timeSystem().monotonicTime(); start_time_monotonic_ = now; From 94070c55461694592357c1b7b748cf59535b6848 Mon Sep 17 00:00:00 2001 From: Yechiel Kalmenson Date: Fri, 1 Nov 2019 11:10:13 -0400 Subject: [PATCH 11/12] Pedantic spelling fix Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- include/envoy/common/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 540ef3f7b4d6..7656d3feb161 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -2,7 +2,7 @@ // NOLINT(namespace-envoy) // This common "platform.h" header exists to simplify the most common references -// to non-ANSI C/C++ headers, required on windows, posix, linux, bsd etc, +// to non-ANSI C/C++ headers, required on Windows, Posix, Linux, BSD etc, // and to provide substitute definitions when absolutely required. // // The goal is to eventually not require this file of envoy header declarations, From 74cee4050d59ca8fe4059061cf8472d6c753a9c9 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Mon, 4 Nov 2019 09:59:02 -0500 Subject: [PATCH 12/12] static const constants per lizan Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson Signed-off-by: William A Rowe Jr --- source/common/common/version.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/common/common/version.cc b/source/common/common/version.cc index 82c016c02dab..d01cf6d90657 100644 --- a/source/common/common/version.cc +++ b/source/common/common/version.cc @@ -22,14 +22,14 @@ const std::string& VersionInfo::revisionStatus() { const std::string& VersionInfo::version() { #ifdef NDEBUG - const absl::string_view release_type = "RELEASE"; + static const absl::string_view release_type = "RELEASE"; #else - const absl::string_view release_type = "DEBUG"; + static const absl::string_view release_type = "DEBUG"; #endif #ifdef ENVOY_SSL_VERSION - const absl::string_view ssl_version = ENVOY_SSL_VERSION; + static const absl::string_view ssl_version = ENVOY_SSL_VERSION; #else - const absl::string_view ssl_version = "no-ssl"; + static const absl::string_view ssl_version = "no-ssl"; #endif CONSTRUCT_ON_FIRST_USE(std::string, fmt::format("{}/{}/{}/{}/{}", revision(), BUILD_VERSION_NUMBER,