From a2f19bdd5a8e930cf052a029fa4b82649ad63dbe Mon Sep 17 00:00:00 2001 From: Mike Schore Date: Wed, 15 Jul 2020 10:49:51 +0800 Subject: [PATCH] envoy: update upstream for multiple fixes (#923) Description: Pulls in multiple fixes committed to upstream Envoy. - Update for resolution to TLSContext crash: https://github.com/envoyproxy/envoy/issues/10030 - Fixes for 32 bit archs: https://github.com/envoyproxy/envoy/pull/11726 - Fix for missing posix call on Android: https://github.com/envoyproxy/envoy/pull/12081 - Additional zlib stats: https://github.com/envoyproxy/envoy/pull/11782 Signed-off-by: Mike Schore Signed-off-by: JP Simard --- mobile/envoy | 2 +- mobile/envoy_build_config/BUILD | 1 + .../envoy_build_config/extension_registry.cc | 1 + .../envoy_build_config/extension_registry.h | 1 + .../extensions_build_config.bzl | 13 ++++++----- mobile/library/common/BUILD | 1 + .../common/envoy_mobile_main_common.cc | 3 ++- mobile/library/common/http/dispatcher.h | 2 ++ mobile/library/common/http/header_utility.cc | 4 ++-- mobile/test/common/http/dispatcher_test.cc | 2 +- .../test/common/http/header_utility_test.cc | 22 +++++++++---------- .../dispatcher_integration_test.cc | 4 ++-- 12 files changed, 32 insertions(+), 24 deletions(-) diff --git a/mobile/envoy b/mobile/envoy index ff40a02a838d..d8b573851f09 160000 --- a/mobile/envoy +++ b/mobile/envoy @@ -1 +1 @@ -Subproject commit ff40a02a838d123f4bf018858c61c983e1c5cce9 +Subproject commit d8b573851f0927d7f63563a7df1f0bce2b7d9931 diff --git a/mobile/envoy_build_config/BUILD b/mobile/envoy_build_config/BUILD index 7f661540a8f1..124c19724e15 100644 --- a/mobile/envoy_build_config/BUILD +++ b/mobile/envoy_build_config/BUILD @@ -22,5 +22,6 @@ envoy_cc_library( "@envoy//source/extensions/filters/network/http_connection_manager:config", "@envoy//source/extensions/stat_sinks/metrics_service:config", "@envoy//source/extensions/transport_sockets/tls:config", + "@envoy//source/extensions/upstreams/http/generic:config", ], ) diff --git a/mobile/envoy_build_config/extension_registry.cc b/mobile/envoy_build_config/extension_registry.cc index 686ae8e54580..522ddddfa309 100644 --- a/mobile/envoy_build_config/extension_registry.cc +++ b/mobile/envoy_build_config/extension_registry.cc @@ -15,6 +15,7 @@ void ExtensionRegistry::registerFactories() { forceRegisterHttpConnectionManagerFilterConfigFactory(); Envoy::Extensions::StatSinks::MetricsService::forceRegisterMetricsServiceSinkFactory(); Envoy::Extensions::TransportSockets::Tls::forceRegisterUpstreamSslSocketFactory(); + Envoy::Extensions::Upstreams::Http::Generic::forceRegisterGenericGenericConnPoolFactory(); Envoy::Upstream::forceRegisterLogicalDnsClusterFactory(); // TODO: add a "force initialize" function to the upstream code, or clean up the upstream code diff --git a/mobile/envoy_build_config/extension_registry.h b/mobile/envoy_build_config/extension_registry.h index a6bd42ecaab8..9397bee1fd65 100644 --- a/mobile/envoy_build_config/extension_registry.h +++ b/mobile/envoy_build_config/extension_registry.h @@ -10,6 +10,7 @@ #include "extensions/filters/network/http_connection_manager/config.h" #include "extensions/stat_sinks/metrics_service/config.h" #include "extensions/transport_sockets/tls/config.h" +#include "extensions/upstreams/http/generic/config.h" namespace Envoy { class ExtensionRegistry { diff --git a/mobile/envoy_build_config/extensions_build_config.bzl b/mobile/envoy_build_config/extensions_build_config.bzl index 064759939f61..95e6f5938890 100644 --- a/mobile/envoy_build_config/extensions_build_config.bzl +++ b/mobile/envoy_build_config/extensions_build_config.bzl @@ -1,9 +1,10 @@ EXTENSIONS = { - "envoy.clusters.dynamic_forward_proxy": "//source/extensions/clusters/dynamic_forward_proxy:cluster", - "envoy.filters.http.dynamic_forward_proxy": "//source/extensions/filters/http/dynamic_forward_proxy:config", - "envoy.filters.http.router": "//source/extensions/filters/http/router:config", - "envoy.filters.network.http_connection_manager": "//source/extensions/filters/network/http_connection_manager:config", - "envoy.stat_sinks.metrics_service": "//source/extensions/stat_sinks/metrics_service:config", - "envoy.transport_sockets.tls": "//source/extensions/transport_sockets/tls:config", + "envoy.clusters.dynamic_forward_proxy": "//source/extensions/clusters/dynamic_forward_proxy:cluster", + "envoy.filters.connection_pools.http.generic": "//source/extensions/upstreams/http/generic:config", + "envoy.filters.http.dynamic_forward_proxy": "//source/extensions/filters/http/dynamic_forward_proxy:config", + "envoy.filters.http.router": "//source/extensions/filters/http/router:config", + "envoy.filters.network.http_connection_manager": "//source/extensions/filters/network/http_connection_manager:config", + "envoy.stat_sinks.metrics_service": "//source/extensions/stat_sinks/metrics_service:config", + "envoy.transport_sockets.tls": "//source/extensions/transport_sockets/tls:config", } WINDOWS_EXTENSIONS = {} diff --git a/mobile/library/common/BUILD b/mobile/library/common/BUILD index 0b8c39347fa9..5a6efe378b88 100644 --- a/mobile/library/common/BUILD +++ b/mobile/library/common/BUILD @@ -33,6 +33,7 @@ envoy_cc_library( hdrs = ["envoy_mobile_main_common.h"], repository = "@envoy", deps = [ + "@envoy//source/common/common:random_generator_lib", "@envoy//source/common/runtime:runtime_lib", "@envoy//source/exe:envoy_common_lib", "@envoy//source/exe:envoy_main_common_lib", diff --git a/mobile/library/common/envoy_mobile_main_common.cc b/mobile/library/common/envoy_mobile_main_common.cc index 55b8233de2f1..2cc552066571 100644 --- a/mobile/library/common/envoy_mobile_main_common.cc +++ b/mobile/library/common/envoy_mobile_main_common.cc @@ -1,5 +1,6 @@ #include "library/common/envoy_mobile_main_common.h" +#include "common/common/random_generator.h" #include "common/runtime/runtime_impl.h" namespace Envoy { @@ -7,7 +8,7 @@ namespace Envoy { MobileMainCommon::MobileMainCommon(int argc, const char* const* argv) : options_(argc, argv, &MainCommon::hotRestartVersion, spdlog::level::info), base_(options_, real_time_system_, default_listener_hooks_, prod_component_factory_, - std::make_unique(), platform_impl_.threadFactory(), + std::make_unique(), platform_impl_.threadFactory(), platform_impl_.fileSystem(), nullptr) { // Disabling signal handling in the options makes it so that the server's event dispatcher _does // not_ listen for termination signals such as SIGTERM, SIGINT, etc diff --git a/mobile/library/common/http/dispatcher.h b/mobile/library/common/http/dispatcher.h index 31aba23116cb..cb9c758e0bfe 100644 --- a/mobile/library/common/http/dispatcher.h +++ b/mobile/library/common/http/dispatcher.h @@ -168,6 +168,8 @@ class Dispatcher : public Logger::Loggable { // TODO: https://github.com/lyft/envoy-mobile/issues/825 void readDisable(bool /*disable*/) override {} uint32_t bufferLimit() override { return 65000; } + // Not applicable + void setFlushTimeout(std::chrono::milliseconds) override {} void closeLocal(bool end_stream); diff --git a/mobile/library/common/http/header_utility.cc b/mobile/library/common/http/header_utility.cc index 262c18c73927..32e284876ed7 100644 --- a/mobile/library/common/http/header_utility.cc +++ b/mobile/library/common/http/header_utility.cc @@ -11,7 +11,7 @@ std::string convertToString(envoy_data s) { } RequestHeaderMapPtr toRequestHeaders(envoy_headers headers) { - RequestHeaderMapPtr transformed_headers = std::make_unique(); + RequestHeaderMapPtr transformed_headers = RequestHeaderMapImpl::create(); for (envoy_header_size_t i = 0; i < headers.length; i++) { transformed_headers->addCopy(LowerCaseString(convertToString(headers.headers[i].key)), convertToString(headers.headers[i].value)); @@ -22,7 +22,7 @@ RequestHeaderMapPtr toRequestHeaders(envoy_headers headers) { } RequestTrailerMapPtr toRequestTrailers(envoy_headers trailers) { - RequestTrailerMapPtr transformed_trailers = std::make_unique(); + RequestTrailerMapPtr transformed_trailers = RequestTrailerMapImpl::create(); for (envoy_header_size_t i = 0; i < trailers.length; i++) { transformed_trailers->addCopy(LowerCaseString(convertToString(trailers.headers[i].key)), convertToString(trailers.headers[i].value)); diff --git a/mobile/test/common/http/dispatcher_test.cc b/mobile/test/common/http/dispatcher_test.cc index 4eb93ed9b728..af988c3291b9 100644 --- a/mobile/test/common/http/dispatcher_test.cc +++ b/mobile/test/common/http/dispatcher_test.cc @@ -31,7 +31,7 @@ namespace Http { // Based on Http::Utility::toRequestHeaders() but only used for these tests. ResponseHeaderMapPtr toResponseHeaders(envoy_headers headers) { - ResponseHeaderMapPtr transformed_headers = std::make_unique(); + ResponseHeaderMapPtr transformed_headers = ResponseHeaderMapImpl::create(); for (envoy_header_size_t i = 0; i < headers.length; i++) { transformed_headers->addCopy(LowerCaseString(Utility::convertToString(headers.headers[i].key)), Utility::convertToString(headers.headers[i].value)); diff --git a/mobile/test/common/http/header_utility_test.cc b/mobile/test/common/http/header_utility_test.cc index 91f028265f3a..bf1ee07fc564 100644 --- a/mobile/test/common/http/header_utility_test.cc +++ b/mobile/test/common/http/header_utility_test.cc @@ -117,31 +117,31 @@ TEST(RequestTrailerDataConstructorTest, FromCToCpp) { } TEST(HeaderDataConstructorTest, FromCppToCEmpty) { - HeaderMapImpl empty_headers; - envoy_headers c_headers = Utility::toBridgeHeaders(std::move(empty_headers)); + RequestHeaderMapPtr empty_headers = RequestHeaderMapImpl::create(); + envoy_headers c_headers = Utility::toBridgeHeaders(*empty_headers); ASSERT_EQ(0, c_headers.length); release_envoy_headers(c_headers); } TEST(HeaderDataConstructorTest, FromCppToC) { - HeaderMapImpl cpp_headers; - cpp_headers.addCopy(LowerCaseString(std::string(":method")), std::string("GET")); - cpp_headers.addCopy(LowerCaseString(std::string(":scheme")), std::string("https")); - cpp_headers.addCopy(LowerCaseString(std::string(":authority")), std::string("api.lyft.com")); - cpp_headers.addCopy(LowerCaseString(std::string(":path")), std::string("/ping")); + RequestHeaderMapPtr cpp_headers = RequestHeaderMapImpl::create(); + cpp_headers->addCopy(LowerCaseString(std::string(":method")), std::string("GET")); + cpp_headers->addCopy(LowerCaseString(std::string(":scheme")), std::string("https")); + cpp_headers->addCopy(LowerCaseString(std::string(":authority")), std::string("api.lyft.com")); + cpp_headers->addCopy(LowerCaseString(std::string(":path")), std::string("/ping")); - envoy_headers c_headers = Utility::toBridgeHeaders(std::move(cpp_headers)); + envoy_headers c_headers = Utility::toBridgeHeaders(*cpp_headers); - ASSERT_EQ(c_headers.length, static_cast(cpp_headers.size())); + ASSERT_EQ(c_headers.length, static_cast(cpp_headers->size())); for (envoy_header_size_t i = 0; i < c_headers.length; i++) { auto actual_key = LowerCaseString(Utility::convertToString(c_headers.headers[i].key)); auto actual_value = Utility::convertToString(c_headers.headers[i].value); // Key is present. - EXPECT_NE(cpp_headers.get(actual_key), nullptr); + EXPECT_NE(cpp_headers->get(actual_key), nullptr); // Value for the key is the same. - EXPECT_EQ(actual_value, cpp_headers.get(actual_key)->value().getStringView()); + EXPECT_EQ(actual_value, cpp_headers->get(actual_key)->value().getStringView()); } release_envoy_headers(c_headers); diff --git a/mobile/test/integration/dispatcher_integration_test.cc b/mobile/test/integration/dispatcher_integration_test.cc index e055980e570c..53dc1133e00e 100644 --- a/mobile/test/integration/dispatcher_integration_test.cc +++ b/mobile/test/integration/dispatcher_integration_test.cc @@ -19,7 +19,7 @@ namespace { // Based on Http::Utility::toRequestHeaders() but only used for these tests. Http::ResponseHeaderMapPtr toResponseHeaders(envoy_headers headers) { - Http::ResponseHeaderMapPtr transformed_headers = std::make_unique(); + Http::ResponseHeaderMapPtr transformed_headers = Http::ResponseHeaderMapImpl::create(); for (envoy_header_size_t i = 0; i < headers.length; i++) { transformed_headers->addCopy( Http::LowerCaseString(Http::Utility::convertToString(headers.headers[i].key)), @@ -195,7 +195,7 @@ TEST_P(DispatcherIntegrationTest, BasicNon2xx) { // Set response header status to be non-2xx to test that the correct stats get charged. reinterpret_cast(fake_upstreams_.front().get()) ->setResponseHeaders(std::make_unique( - Http::TestHeaderMapImpl({{":status", "503"}, {"content-length", "0"}}))); + Http::TestResponseHeaderMapImpl({{":status", "503"}, {"content-length", "0"}}))); envoy_stream_t stream = 1; // Setup bridge_callbacks to handle the response.