From 4025f1ea1fb74e532d9e736b0a2e9844eb11b482 Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Wed, 21 Oct 2020 23:41:49 +0000 Subject: [PATCH 1/8] docs: kick off v1.15.3 Signed-off-by: Christoph Pakulski --- docs/root/version_history/current.rst | 5 ++--- docs/root/version_history/v1.15.2.rst | 6 ++++++ docs/root/version_history/version_history.rst | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 docs/root/version_history/v1.15.2.rst diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index 19150c303646d..caac70356b9ae 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -1,6 +1,5 @@ -1.15.2 (September 29, 2020) -=========================== +1.15.3 (Pending) +================ Changes ------- -* docs: fix docs for v1.15.1. diff --git a/docs/root/version_history/v1.15.2.rst b/docs/root/version_history/v1.15.2.rst new file mode 100644 index 0000000000000..19150c303646d --- /dev/null +++ b/docs/root/version_history/v1.15.2.rst @@ -0,0 +1,6 @@ +1.15.2 (September 29, 2020) +=========================== + +Changes +------- +* docs: fix docs for v1.15.1. diff --git a/docs/root/version_history/version_history.rst b/docs/root/version_history/version_history.rst index d9d9993e500c1..b99c23cf1db1a 100644 --- a/docs/root/version_history/version_history.rst +++ b/docs/root/version_history/version_history.rst @@ -7,6 +7,7 @@ Version history :titlesonly: current + v1.15.2 v1.15.1 v1.15.0 v1.14.3 From 92f70156cd1a8c7f08cfcea055e5ce352f21b37e Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Thu, 22 Oct 2020 00:04:11 +0000 Subject: [PATCH 2/8] Updated VERSION file. Signed-off-by: Christoph Pakulski --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 42cf0675c5668..f2380cc7aefee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.15.2 +1.15.3 From 8d735ba9c2d9e3fa5b287585104debaff2c022a0 Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Thu, 22 Oct 2020 19:14:54 +0000 Subject: [PATCH 3/8] Updated VERSION file. Signed-off-by: Christoph Pakulski --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f2380cc7aefee..749afc16bf359 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.15.3 +1.15.3-dev From 7ba6a0b471de919d336ae50c91797e898858ca1a Mon Sep 17 00:00:00 2001 From: Alex Konradi Date: Tue, 13 Oct 2020 10:58:15 -0400 Subject: [PATCH 4/8] Prevent SEGFAULT when disabling listener (#13515) This prevents the stop_listening overload action from causing segmentation faults that can occur if the action is enabled after the listener has already shut down. Signed-off-by: Alex Konradi Signed-off-by: Christoph Pakulski --- source/server/connection_handler_impl.cc | 12 ++++++++++++ source/server/connection_handler_impl.h | 4 ++-- test/server/connection_handler_test.cc | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/source/server/connection_handler_impl.cc b/source/server/connection_handler_impl.cc index 24b694f826591..0b7a1c8bbb656 100644 --- a/source/server/connection_handler_impl.cc +++ b/source/server/connection_handler_impl.cc @@ -375,6 +375,18 @@ void emitLogs(Network::ListenerConfig& config, StreamInfo::StreamInfo& stream_in } } // namespace +void ConnectionHandlerImpl::ActiveTcpListener::pauseListening() { + if (listener_ != nullptr) { + listener_->disable(); + } +} + +void ConnectionHandlerImpl::ActiveTcpListener::resumeListening() { + if (listener_ != nullptr) { + listener_->enable(); + } +} + void ConnectionHandlerImpl::ActiveTcpListener::newConnection( Network::ConnectionSocketPtr&& socket, const envoy::config::core::v3::Metadata& dynamic_metadata) { diff --git a/source/server/connection_handler_impl.h b/source/server/connection_handler_impl.h index df6fa758bd5b2..7c5e7581e2654 100644 --- a/source/server/connection_handler_impl.h +++ b/source/server/connection_handler_impl.h @@ -134,8 +134,8 @@ class ConnectionHandlerImpl : public Network::ConnectionHandler, // ActiveListenerImplBase Network::Listener* listener() override { return listener_.get(); } - void pauseListening() override { listener_->disable(); } - void resumeListening() override { listener_->enable(); } + void pauseListening() override; + void resumeListening() override; void shutdownListener() override { listener_.reset(); } // Network::BalancedConnectionHandler diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index a7f942f95d42f..9bd6546d94ebe 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -380,6 +380,22 @@ TEST_F(ConnectionHandlerTest, AddDisabledListener) { handler_->addListener(absl::nullopt, *test_listener); } +TEST_F(ConnectionHandlerTest, DisableListenerAfterStop) { + InSequence s; + + Network::TcpListenerCallbacks* listener_callbacks; + auto listener = new NiceMock(); + TestListener* test_listener = + addListener(1, false, false, "test_listener", listener, &listener_callbacks); + EXPECT_CALL(*socket_factory_, localAddress()).WillOnce(ReturnRef(local_address_)); + handler_->addListener(absl::nullopt, *test_listener); + + EXPECT_CALL(*listener, onDestroy()); + + handler_->stopListeners(); + handler_->disableListeners(); +} + TEST_F(ConnectionHandlerTest, DestroyCloseConnections) { InSequence s; From ef56a2b66c536ed2d426868c6113d77351eb7d9b Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Wed, 4 Nov 2020 19:58:33 +0000 Subject: [PATCH 5/8] Fixed compilation error (method's signature changed between releases). Added release note. Signed-off-by: Christoph Pakulski --- docs/root/version_history/current.rst | 5 +++++ test/server/connection_handler_test.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index caac70356b9ae..ea902bcab7281 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -3,3 +3,8 @@ Changes ------- +* overload: prevent segfault when disabling listener. + + This prevents the stop_listening overload action from causing + segmentation faults that can occur if the action is enabled after the + listener has already shut down. diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 9bd6546d94ebe..e8257798b934d 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -383,7 +383,7 @@ TEST_F(ConnectionHandlerTest, AddDisabledListener) { TEST_F(ConnectionHandlerTest, DisableListenerAfterStop) { InSequence s; - Network::TcpListenerCallbacks* listener_callbacks; + Network::ListenerCallbacks* listener_callbacks; auto listener = new NiceMock(); TestListener* test_listener = addListener(1, false, false, "test_listener", listener, &listener_callbacks); From ae6bde9d349db7de0fa89ec98e2d0a7c0ebb76ed Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Thu, 5 Nov 2020 15:29:56 +0000 Subject: [PATCH 6/8] Corrected release note. Signed-off-by: Christoph Pakulski --- docs/root/version_history/current.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index ea902bcab7281..bfee20b0dfe2c 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -3,8 +3,4 @@ Changes ------- -* overload: prevent segfault when disabling listener. - - This prevents the stop_listening overload action from causing - segmentation faults that can occur if the action is enabled after the - listener has already shut down. +* listener: fix crash when disabling or re-enabling listeners due to overload while processing LDS updates. From 88247cff390eb05f6851f6ced5685e57523a9465 Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Thu, 5 Nov 2020 18:05:32 +0000 Subject: [PATCH 7/8] Fix for macos build. Signed-off-by: Christoph Pakulski --- source/common/common/utility.cc | 2 +- source/common/http/utility.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/common/common/utility.cc b/source/common/common/utility.cc index eb7ba3619a396..fce6f4e385aea 100644 --- a/source/common/common/utility.cc +++ b/source/common/common/utility.cc @@ -306,7 +306,7 @@ bool StringUtil::findToken(absl::string_view source, absl::string_view delimiter absl::string_view key_token, bool trim_whitespace) { const auto tokens = splitToken(source, delimiters, trim_whitespace); if (trim_whitespace) { - for (const auto token : tokens) { + for (const auto& token : tokens) { if (key_token == trim(token)) { return true; } diff --git a/source/common/http/utility.cc b/source/common/http/utility.cc index a48bea5d08ae5..204743ff52f62 100644 --- a/source/common/http/utility.cc +++ b/source/common/http/utility.cc @@ -329,7 +329,7 @@ std::string Utility::parseCookieValue(const HeaderMap& headers, const std::strin if (header.key() == Http::Headers::get().Cookie.get()) { // Split the cookie header into individual cookies. - for (const auto s : StringUtil::splitToken(header.value().getStringView(), ";")) { + for (const auto& s : StringUtil::splitToken(header.value().getStringView(), ";")) { // Find the key part of the cookie (i.e. the name of the cookie). size_t first_non_space = s.find_first_not_of(" "); size_t equals_index = s.find('='); From ca810b88d550b04706d71d20828ea367a4efc365 Mon Sep 17 00:00:00 2001 From: Christoph Pakulski Date: Thu, 5 Nov 2020 20:37:26 +0000 Subject: [PATCH 8/8] More code fixes for macos build. Signed-off-by: Christoph Pakulski --- source/common/router/retry_state_impl.cc | 8 ++++---- source/common/runtime/runtime_impl.cc | 2 +- .../filters/http/common/compressor/compressor.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/common/router/retry_state_impl.cc b/source/common/router/retry_state_impl.cc index 09d3b10168047..7180d4d92d902 100644 --- a/source/common/router/retry_state_impl.cc +++ b/source/common/router/retry_state_impl.cc @@ -113,7 +113,7 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, } if (request_headers.EnvoyRetriableStatusCodes()) { - for (const auto code : + for (const auto& code : StringUtil::splitToken(request_headers.getEnvoyRetriableStatusCodesValue(), ",")) { unsigned int out; if (absl::SimpleAtoi(code, &out)) { @@ -128,7 +128,7 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, // to provide HeaderMatcher serialized into a string. To avoid this extra // complexity we only support name-only header matchers via request // header. Anything more sophisticated needs to be provided via config. - for (const auto header_name : StringUtil::splitToken( + for (const auto& header_name : StringUtil::splitToken( request_headers.EnvoyRetriableHeaderNames()->value().getStringView(), ",")) { envoy::config::route::v3::HeaderMatcher header_matcher; header_matcher.set_name(std::string(absl::StripAsciiWhitespace(header_name))); @@ -152,7 +152,7 @@ void RetryStateImpl::enableBackoffTimer() { std::pair RetryStateImpl::parseRetryOn(absl::string_view config) { uint32_t ret = 0; bool all_fields_valid = true; - for (const auto retry_on : StringUtil::splitToken(config, ",", false, true)) { + for (const auto& retry_on : StringUtil::splitToken(config, ",", false, true)) { if (retry_on == Http::Headers::get().EnvoyRetryOnValues._5xx) { ret |= RetryPolicy::RETRY_ON_5XX; } else if (retry_on == Http::Headers::get().EnvoyRetryOnValues.GatewayError) { @@ -180,7 +180,7 @@ std::pair RetryStateImpl::parseRetryOn(absl::string_view config) std::pair RetryStateImpl::parseRetryGrpcOn(absl::string_view retry_grpc_on_header) { uint32_t ret = 0; bool all_fields_valid = true; - for (const auto retry_on : StringUtil::splitToken(retry_grpc_on_header, ",", false, true)) { + for (const auto& retry_on : StringUtil::splitToken(retry_grpc_on_header, ",", false, true)) { if (retry_on == Http::Headers::get().EnvoyRetryOnGrpcValues.Cancelled) { ret |= RetryPolicy::RETRY_ON_GRPC_CANCELLED; } else if (retry_on == Http::Headers::get().EnvoyRetryOnGrpcValues.DeadlineExceeded) { diff --git a/source/common/runtime/runtime_impl.cc b/source/common/runtime/runtime_impl.cc index 6eb490d2015ba..21f2440ebf44f 100644 --- a/source/common/runtime/runtime_impl.cc +++ b/source/common/runtime/runtime_impl.cc @@ -411,7 +411,7 @@ void DiskLayer::walkDirectory(const std::string& path, const std::string& prefix // Comments are useful for placeholder files with no value. const std::string text_file{api.fileSystem().fileReadToEnd(full_path)}; const auto lines = StringUtil::splitToken(text_file, "\n"); - for (const auto line : lines) { + for (const auto& line : lines) { if (!line.empty() && line.front() == '#') { continue; } diff --git a/source/extensions/filters/http/common/compressor/compressor.cc b/source/extensions/filters/http/common/compressor/compressor.cc index 482abaf348dd8..3ed87b4b34aa6 100644 --- a/source/extensions/filters/http/common/compressor/compressor.cc +++ b/source/extensions/filters/http/common/compressor/compressor.cc @@ -214,7 +214,7 @@ CompressorFilter::chooseEncoding(const Http::ResponseHeaderMap& headers) const { } // Find all encodings accepted by the user agent and adjust the list of allowed compressors. - for (const auto token : StringUtil::splitToken(*accept_encoding_, ",", false /* keep_empty */)) { + for (const auto& token : StringUtil::splitToken(*accept_encoding_, ",", false /* keep_empty */)) { EncPair pair = std::make_pair(StringUtil::trim(StringUtil::cropRight(token, ";")), static_cast(1)); const auto params = StringUtil::cropLeft(token, ";");