From fe02e366b3d3b7eb2dced9941f32a39031872b5c Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sat, 12 Jun 2021 13:18:58 +0000 Subject: [PATCH 01/14] Reset the file event before initialize new one Signed-off-by: He Jie Xu --- .../common/network/io_socket_handle_impl.cc | 7 +- source/server/active_tcp_listener.cc | 5 -- .../listener_filter_integration_test.cc | 84 ++++++++++++++----- 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/source/common/network/io_socket_handle_impl.cc b/source/common/network/io_socket_handle_impl.cc index 7e2f3a5b789db..877c07a37c8a7 100644 --- a/source/common/network/io_socket_handle_impl.cc +++ b/source/common/network/io_socket_handle_impl.cc @@ -635,8 +635,11 @@ Address::InstanceConstSharedPtr IoSocketHandleImpl::peerAddress() { void IoSocketHandleImpl::initializeFileEvent(Event::Dispatcher& dispatcher, Event::FileReadyCb cb, Event::FileTriggerType trigger, uint32_t events) { - ASSERT(file_event_ == nullptr, "Attempting to initialize two `file_event_` for the same " - "file descriptor. This is not allowed."); + // Reset the file_event_ for the case of initialize two `file_event_` for + // the same file descriptor. This is not allowed. + if (file_event_ != nullptr) { + file_event_.reset(); + } file_event_ = dispatcher.createFileEvent(fd_, cb, trigger, events); } diff --git a/source/server/active_tcp_listener.cc b/source/server/active_tcp_listener.cc index 880f234c8a7ba..e312d29e4ab9a 100644 --- a/source/server/active_tcp_listener.cc +++ b/source/server/active_tcp_listener.cc @@ -199,11 +199,6 @@ void ActiveTcpSocket::newConnection() { if (socket_->detectedTransportProtocol().empty()) { socket_->setDetectedTransportProtocol("raw_buffer"); } - // TODO(lambdai): add integration test - // TODO: Address issues in wider scope. See https://github.com/envoyproxy/envoy/issues/8925 - // Erase accept filter states because accept filters may not get the opportunity to clean up. - // Particularly the assigned events need to reset before assigning new events in the follow up. - accept_filters_.clear(); // Create a new connection on this listener. listener_.newConnection(std::move(socket_), std::move(stream_info_)); } diff --git a/test/integration/listener_filter_integration_test.cc b/test/integration/listener_filter_integration_test.cc index 558109f8fde34..ee5107e4efc37 100644 --- a/test/integration/listener_filter_integration_test.cc +++ b/test/integration/listener_filter_integration_test.cc @@ -48,20 +48,35 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam listener_filter_disabled = absl::nullopt) { + void initializeWithListenerFilter(bool ssl_client, + absl::optional listener_filter_disabled = absl::nullopt) { config_helper_.renameListener("echo"); std::string tls_inspector_config = ConfigHelper::tlsInspectorFilter(); if (listener_filter_disabled.has_value()) { tls_inspector_config = appendMatcher(tls_inspector_config, listener_filter_disabled.value()); } config_helper_.addListenerFilter(tls_inspector_config); - config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { - auto* filter_chain = - bootstrap.mutable_static_resources()->mutable_listeners(0)->mutable_filter_chains(0); - auto* alpn = filter_chain->mutable_filter_chain_match()->add_application_protocols(); - *alpn = "envoyalpn"; + + config_helper_.addConfigModifier([ssl_client]( + envoy::config::bootstrap::v3::Bootstrap& bootstrap) { + if (ssl_client) { + auto* filter_chain = + bootstrap.mutable_static_resources()->mutable_listeners(0)->mutable_filter_chains(0); + auto* alpn = filter_chain->mutable_filter_chain_match()->add_application_protocols(); + *alpn = "envoyalpn"; + } + auto* timeout = bootstrap.mutable_static_resources() + ->mutable_listeners(0) + ->mutable_listener_filters_timeout(); + timeout->MergeFrom(ProtobufUtil::TimeUtil::MillisecondsToDuration(1000)); + bootstrap.mutable_static_resources() + ->mutable_listeners(0) + ->set_continue_on_listener_filters_timeout(true); }); - config_helper_.addSslConfig(); + if (ssl_client) { + config_helper_.addSslConfig(); + } + useListenerAccessLog("%RESPONSE_CODE_DETAILS%"); BaseIntegrationTest::initialize(); @@ -69,23 +84,28 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam(timeSystem()); } - void setupConnections(bool listener_filter_disabled, bool expect_connection_open) { - initializeWithListenerFilter(listener_filter_disabled); + void setupConnections(bool listener_filter_disabled, bool expect_connection_open, + bool ssl_client) { + initializeWithListenerFilter(ssl_client, listener_filter_disabled); // Set up the SSL client. Network::Address::InstanceConstSharedPtr address = Ssl::getSslAddress(version_, lookupPort("echo")); context_ = Ssl::createClientSslTransportSocketFactory({}, *context_manager_, *api_); - ssl_client_ = dispatcher_->createClientConnection( - address, Network::Address::InstanceConstSharedPtr(), - context_->createTransportSocket( - // nullptr - std::make_shared( - absl::string_view(""), std::vector(), - std::vector{"envoyalpn"})), - nullptr); - ssl_client_->addConnectionCallbacks(connect_callbacks_); - ssl_client_->connect(); + Network::TransportSocketPtr transport_socket; + if (ssl_client) { + transport_socket = + context_->createTransportSocket(std::make_shared( + absl::string_view(""), std::vector(), + std::vector{"envoyalpn"})); + } else { + auto transport_socket_factory = std::make_unique(); + transport_socket = transport_socket_factory->createTransportSocket(nullptr); + } + client_ = dispatcher_->createClientConnection( + address, Network::Address::InstanceConstSharedPtr(), std::move(transport_socket), nullptr); + client_->addConnectionCallbacks(connect_callbacks_); + client_->connect(); while (!connect_callbacks_.connected() && !connect_callbacks_.closed()) { dispatcher_->run(Event::Dispatcher::RunType::NonBlock); } @@ -98,27 +118,45 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam context_manager_; Network::TransportSocketFactoryPtr context_; ConnectionStatusCallbacks connect_callbacks_; testing::NiceMock secret_manager_; - Network::ClientConnectionPtr ssl_client_; + Network::ClientConnectionPtr client_; }; // Each listener filter is enabled by default. TEST_P(ListenerFilterIntegrationTest, AllListenerFiltersAreEnabledByDefault) { - setupConnections(/*listener_filter_disabled=*/false, /*expect_connection_open=*/true); - ssl_client_->close(Network::ConnectionCloseType::NoFlush); + setupConnections(/*listener_filter_disabled=*/false, /*expect_connection_open=*/true, + /*ssl_client=*/true); + client_->close(Network::ConnectionCloseType::NoFlush); EXPECT_THAT(waitForAccessLog(listener_access_log_name_), testing::Eq("-")); } // The tls_inspector is disabled. The ALPN won't be sniffed out and no filter chain is matched. TEST_P(ListenerFilterIntegrationTest, DisabledTlsInspectorFailsFilterChainFind) { - setupConnections(/*listener_filter_disabled=*/true, /*expect_connection_open=*/false); + setupConnections(/*listener_filter_disabled=*/true, /*expect_connection_open=*/false, + /*ssl_client=*/true); EXPECT_THAT(waitForAccessLog(listener_access_log_name_), testing::Eq(StreamInfo::ResponseCodeDetails::get().FilterChainNotFound)); } +// trigger the tls inspect filter timeout, and continue create new connection after timeout +TEST_P(ListenerFilterIntegrationTest, ContinueOnListenerTimeout) { + setupConnections(/*listener_filter_disabled=*/false, /*expect_connection_open=*/true, + /*ssl_client=*/false); + // The length of tls hello message is defined as `TLS_MAX_CLIENT_HELLO = 64 * 1024` + // if tls inspect filter doesn't read the max length of hello message data, it + // will continue wait. Then the listener filter timeout timer will be triggered. + Buffer::OwnedImpl buffer("fake data"); + client_->write(buffer, false); + // the timeout is set as one seconds, sleep 5 to trigger the timeout. + absl::SleepFor(absl::Seconds(5)); + client_->close(Network::ConnectionCloseType::NoFlush); + EXPECT_THAT(waitForAccessLog(listener_access_log_name_), testing::Eq("-")); +} + INSTANTIATE_TEST_SUITE_P(IpVersions, ListenerFilterIntegrationTest, testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), TestUtility::ipTestParamsToString); From ba48b32e939d09f21d5093f32f760d7164821d79 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sun, 13 Jun 2021 00:47:14 +0000 Subject: [PATCH 02/14] fix test Signed-off-by: He Jie Xu --- test/server/connection_handler_test.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index b97a3d140c614..4ea93d659f75f 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -924,11 +924,10 @@ TEST_F(ConnectionHandlerTest, ContinueOnListenerFilterTimeout) { Stats::Gauge& downstream_pre_cx_active = stats_store_.gauge("downstream_pre_cx_active", Stats::Gauge::ImportMode::Accumulate); EXPECT_EQ(1UL, downstream_pre_cx_active.value()); - EXPECT_CALL(*test_filter, destroy_()); - // Barrier: test_filter must be destructed before findFilterChain EXPECT_CALL(manager_, findFilterChain(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*access_log_, log(_, _, _, _)); EXPECT_CALL(*timeout, disableTimer()); + EXPECT_CALL(*test_filter, destroy_()); timeout->invokeCallback(); dispatcher_.clearDeferredDeleteList(); EXPECT_EQ(0UL, downstream_pre_cx_active.value()); @@ -970,10 +969,10 @@ TEST_F(ConnectionHandlerTest, ListenerFilterTimeoutResetOnSuccess) { Event::MockTimer* timeout = new Event::MockTimer(&dispatcher_); EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000), _)); listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket}); - EXPECT_CALL(*test_filter, destroy_()); EXPECT_CALL(manager_, findFilterChain(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*access_log_, log(_, _, _, _)); EXPECT_CALL(*timeout, disableTimer()); + EXPECT_CALL(*test_filter, destroy_()); listener_filter_cb->continueFilterChain(true); EXPECT_CALL(*listener, onDestroy()); From 07404c86ebf64c66bf16f5b9ab72bff70e1a9118 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 16 Jun 2021 06:12:50 +0000 Subject: [PATCH 03/14] Revert the change Signed-off-by: He Jie Xu --- source/common/network/io_socket_handle_impl.cc | 7 ++----- source/server/active_tcp_listener.cc | 5 +++++ test/server/connection_handler_test.cc | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/common/network/io_socket_handle_impl.cc b/source/common/network/io_socket_handle_impl.cc index 877c07a37c8a7..7e2f3a5b789db 100644 --- a/source/common/network/io_socket_handle_impl.cc +++ b/source/common/network/io_socket_handle_impl.cc @@ -635,11 +635,8 @@ Address::InstanceConstSharedPtr IoSocketHandleImpl::peerAddress() { void IoSocketHandleImpl::initializeFileEvent(Event::Dispatcher& dispatcher, Event::FileReadyCb cb, Event::FileTriggerType trigger, uint32_t events) { - // Reset the file_event_ for the case of initialize two `file_event_` for - // the same file descriptor. This is not allowed. - if (file_event_ != nullptr) { - file_event_.reset(); - } + ASSERT(file_event_ == nullptr, "Attempting to initialize two `file_event_` for the same " + "file descriptor. This is not allowed."); file_event_ = dispatcher.createFileEvent(fd_, cb, trigger, events); } diff --git a/source/server/active_tcp_listener.cc b/source/server/active_tcp_listener.cc index e312d29e4ab9a..880f234c8a7ba 100644 --- a/source/server/active_tcp_listener.cc +++ b/source/server/active_tcp_listener.cc @@ -199,6 +199,11 @@ void ActiveTcpSocket::newConnection() { if (socket_->detectedTransportProtocol().empty()) { socket_->setDetectedTransportProtocol("raw_buffer"); } + // TODO(lambdai): add integration test + // TODO: Address issues in wider scope. See https://github.com/envoyproxy/envoy/issues/8925 + // Erase accept filter states because accept filters may not get the opportunity to clean up. + // Particularly the assigned events need to reset before assigning new events in the follow up. + accept_filters_.clear(); // Create a new connection on this listener. listener_.newConnection(std::move(socket_), std::move(stream_info_)); } diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 4ea93d659f75f..b97a3d140c614 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -924,10 +924,11 @@ TEST_F(ConnectionHandlerTest, ContinueOnListenerFilterTimeout) { Stats::Gauge& downstream_pre_cx_active = stats_store_.gauge("downstream_pre_cx_active", Stats::Gauge::ImportMode::Accumulate); EXPECT_EQ(1UL, downstream_pre_cx_active.value()); + EXPECT_CALL(*test_filter, destroy_()); + // Barrier: test_filter must be destructed before findFilterChain EXPECT_CALL(manager_, findFilterChain(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*access_log_, log(_, _, _, _)); EXPECT_CALL(*timeout, disableTimer()); - EXPECT_CALL(*test_filter, destroy_()); timeout->invokeCallback(); dispatcher_.clearDeferredDeleteList(); EXPECT_EQ(0UL, downstream_pre_cx_active.value()); @@ -969,10 +970,10 @@ TEST_F(ConnectionHandlerTest, ListenerFilterTimeoutResetOnSuccess) { Event::MockTimer* timeout = new Event::MockTimer(&dispatcher_); EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000), _)); listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket}); + EXPECT_CALL(*test_filter, destroy_()); EXPECT_CALL(manager_, findFilterChain(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*access_log_, log(_, _, _, _)); EXPECT_CALL(*timeout, disableTimer()); - EXPECT_CALL(*test_filter, destroy_()); listener_filter_cb->continueFilterChain(true); EXPECT_CALL(*listener, onDestroy()); From 6887a0ea491d258685e699cf08b370a90bd6a4af Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 16 Jun 2021 07:00:59 +0000 Subject: [PATCH 04/14] Reset file event in destructor of listener filter Signed-off-by: He Jie Xu --- .../filters/listener/http_inspector/http_inspector.h | 5 +++++ .../filters/listener/proxy_protocol/proxy_protocol.h | 8 ++++++-- .../filters/listener/tls_inspector/tls_inspector.h | 7 ++++++- source/server/active_tcp_listener.cc | 4 ---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/extensions/filters/listener/http_inspector/http_inspector.h b/source/extensions/filters/listener/http_inspector/http_inspector.h index b43422f9e66ed..425c9bf146a43 100644 --- a/source/extensions/filters/listener/http_inspector/http_inspector.h +++ b/source/extensions/filters/listener/http_inspector/http_inspector.h @@ -66,6 +66,11 @@ using ConfigSharedPtr = std::shared_ptr; class Filter : public Network::ListenerFilter, Logger::Loggable { public: Filter(const ConfigSharedPtr config); + ~Filter() override { + if(cb_) { + cb_->socket().ioHandle().resetFileEvents(); + } + } // Network::ListenerFilter Network::FilterStatus onAccept(Network::ListenerFilterCallbacks& cb) override; diff --git a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h index 469c838f9b83f..1f1821deee8e2 100644 --- a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h +++ b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h @@ -83,7 +83,11 @@ enum class ReadOrParseState { Done, TryAgainLater, Error }; class Filter : public Network::ListenerFilter, Logger::Loggable { public: Filter(const ConfigSharedPtr& config) : config_(config) {} - + ~Filter() override { + if (cb_) { + cb_->socket().ioHandle().resetFileEvents(); + } + } // Network::ListenerFilter Network::FilterStatus onAccept(Network::ListenerFilterCallbacks& cb) override; @@ -118,7 +122,7 @@ class Filter : public Network::ListenerFilter, Logger::Loggable lenV2Address(char* buf); - Network::ListenerFilterCallbacks* cb_{}; + Network::ListenerFilterCallbacks* cb_{nullptr}; // The offset in buf_ that has been fully read size_t buf_off_{}; diff --git a/source/extensions/filters/listener/tls_inspector/tls_inspector.h b/source/extensions/filters/listener/tls_inspector/tls_inspector.h index a31e814ffc0e4..34a48ef27e373 100644 --- a/source/extensions/filters/listener/tls_inspector/tls_inspector.h +++ b/source/extensions/filters/listener/tls_inspector/tls_inspector.h @@ -73,6 +73,11 @@ using ConfigSharedPtr = std::shared_ptr; class Filter : public Network::ListenerFilter, Logger::Loggable { public: Filter(const ConfigSharedPtr config); + ~Filter() override { + if (cb_) { + cb_->socket().ioHandle().resetFileEvents(); + } + } // Network::ListenerFilter Network::FilterStatus onAccept(Network::ListenerFilterCallbacks& cb) override; @@ -85,7 +90,7 @@ class Filter : public Network::ListenerFilter, Logger::Loggable ssl_; uint64_t read_{0}; diff --git a/source/server/active_tcp_listener.cc b/source/server/active_tcp_listener.cc index 880f234c8a7ba..82d5804f9cc64 100644 --- a/source/server/active_tcp_listener.cc +++ b/source/server/active_tcp_listener.cc @@ -199,10 +199,6 @@ void ActiveTcpSocket::newConnection() { if (socket_->detectedTransportProtocol().empty()) { socket_->setDetectedTransportProtocol("raw_buffer"); } - // TODO(lambdai): add integration test - // TODO: Address issues in wider scope. See https://github.com/envoyproxy/envoy/issues/8925 - // Erase accept filter states because accept filters may not get the opportunity to clean up. - // Particularly the assigned events need to reset before assigning new events in the follow up. accept_filters_.clear(); // Create a new connection on this listener. listener_.newConnection(std::move(socket_), std::move(stream_info_)); From d88a4519ebf9c7f1af29d7bad8e9d295f0eb794b Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 18 Jun 2021 14:37:31 +0000 Subject: [PATCH 05/14] Reset file event in listener destructor Signed-off-by: He Jie Xu --- envoy/network/io_handle.h | 6 ++++++ source/common/network/io_socket_handle_impl.h | 4 +++- source/common/quic/quic_io_handle_wrapper.h | 4 ++++ .../io_socket/user_space/io_handle_impl.h | 4 ++++ .../http_inspector/http_inspector_test.cc | 6 +++++- .../proxy_protocol/proxy_protocol_test.cc | 21 +++++++++++++++++-- .../tls_inspector/tls_inspector_test.cc | 6 +++++- test/mocks/network/io_handle.h | 1 + 8 files changed, 47 insertions(+), 5 deletions(-) diff --git a/envoy/network/io_handle.h b/envoy/network/io_handle.h index 990c5cb5cd209..0fbff949d9bc0 100644 --- a/envoy/network/io_handle.h +++ b/envoy/network/io_handle.h @@ -299,6 +299,12 @@ class IoHandle { virtual void initializeFileEvent(Event::Dispatcher& dispatcher, Event::FileReadyCb cb, Event::FileTriggerType trigger, uint32_t events) PURE; + /** + * Check whether the file event is initialized or not. + * @return return true if the file event is initialize, otherwise return false. + */ + virtual bool isFileEventInitialized() PURE; + /** * Activates file events for the current underlying fd. * @param events events that will be activated. diff --git a/source/common/network/io_socket_handle_impl.h b/source/common/network/io_socket_handle_impl.h index 398ab1f554f5f..2ab2e8e2756e8 100644 --- a/source/common/network/io_socket_handle_impl.h +++ b/source/common/network/io_socket_handle_impl.h @@ -70,7 +70,9 @@ class IoSocketHandleImpl : public IoHandle, protected Logger::Loggable(store_)), io_handle_(std::make_unique(42)) {} - ~HttpInspectorTest() override { io_handle_->close(); } + ~HttpInspectorTest() override { + io_handle_->close(); + filter_.reset(); + EXPECT_EQ(false, io_handle_->isFileEventInitialized()); + } void init(bool include_inline_recv = true) { filter_ = std::make_unique(cfg_); diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index d85d973b94de7..53daf93029bfc 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -79,8 +79,8 @@ class ProxyProtocolTest : public testing::TestWithParamrun(Event::Dispatcher::RunType::NonBlock); + if (GetParam() == Envoy::Network::Address::IpVersion::v4) { + EXPECT_EQ(server_connection_->addressProvider().remoteAddress()->ip()->addressAsString(), + "127.0.0.1"); + } else { + EXPECT_EQ(server_connection_->addressProvider().remoteAddress()->ip()->addressAsString(), + "::1"); + } + + disconnect(); +} + TEST_P(ProxyProtocolTest, V1Basic) { connect(); write("PROXY TCP4 1.2.3.4 253.253.253.253 65535 1234\r\nmore data"); diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc index 6e119c87dcd92..7b98002e6cca2 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc @@ -32,7 +32,11 @@ class TlsInspectorTest : public testing::TestWithParam(store_)), io_handle_(std::make_unique(42)) {} - ~TlsInspectorTest() override { io_handle_->close(); } + ~TlsInspectorTest() override { + io_handle_->close(); + filter_.reset(); + EXPECT_EQ(false, io_handle_->isFileEventInitialized()); + } void init() { filter_ = std::make_unique(cfg_); diff --git a/test/mocks/network/io_handle.h b/test/mocks/network/io_handle.h index 3c661d836b05f..4f5856f2c2e69 100644 --- a/test/mocks/network/io_handle.h +++ b/test/mocks/network/io_handle.h @@ -63,6 +63,7 @@ class MockIoHandle : public IoHandle { MOCK_METHOD(absl::optional, lastRoundTripTime, ()); MOCK_METHOD(Api::SysCallIntResult, ioctl, (unsigned long, void*, unsigned long, void*, unsigned long, unsigned long*)); + MOCK_METHOD(bool, isFileEventInitialized, ()); }; } // namespace Network From a1f66537feb7d13b398c4c57d3a0d610240baaf0 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 18 Jun 2021 14:42:27 +0000 Subject: [PATCH 06/14] add comment Signed-off-by: He Jie Xu --- source/server/active_tcp_listener.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/server/active_tcp_listener.cc b/source/server/active_tcp_listener.cc index 82d5804f9cc64..462ee18e4dbf8 100644 --- a/source/server/active_tcp_listener.cc +++ b/source/server/active_tcp_listener.cc @@ -199,6 +199,8 @@ void ActiveTcpSocket::newConnection() { if (socket_->detectedTransportProtocol().empty()) { socket_->setDetectedTransportProtocol("raw_buffer"); } + // Clear the listener filter to ensure the file event registered by + // listener filter to be removed. reference PR #8922. accept_filters_.clear(); // Create a new connection on this listener. listener_.newConnection(std::move(socket_), std::move(stream_info_)); From a0c2f8867f7478343131b74e905d05cfca53eb14 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Fri, 18 Jun 2021 14:43:29 +0000 Subject: [PATCH 07/14] fix format Signed-off-by: He Jie Xu --- source/common/network/io_socket_handle_impl.h | 4 +--- source/common/quic/quic_io_handle_wrapper.h | 4 +--- .../filters/listener/http_inspector/http_inspector.h | 2 +- source/extensions/io_socket/user_space/io_handle_impl.h | 4 +--- .../filters/listener/proxy_protocol/proxy_protocol_test.cc | 4 +++- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/source/common/network/io_socket_handle_impl.h b/source/common/network/io_socket_handle_impl.h index 2ab2e8e2756e8..8ce54cdeae339 100644 --- a/source/common/network/io_socket_handle_impl.h +++ b/source/common/network/io_socket_handle_impl.h @@ -70,9 +70,7 @@ class IoSocketHandleImpl : public IoHandle, protected Logger::Loggablesocket().ioHandle().resetFileEvents(); } } diff --git a/source/extensions/io_socket/user_space/io_handle_impl.h b/source/extensions/io_socket/user_space/io_handle_impl.h index 56880431a75fd..7995ecdc36b99 100644 --- a/source/extensions/io_socket/user_space/io_handle_impl.h +++ b/source/extensions/io_socket/user_space/io_handle_impl.h @@ -81,9 +81,7 @@ class IoHandleImpl final : public Network::IoHandle, void initializeFileEvent(Event::Dispatcher& dispatcher, Event::FileReadyCb cb, Event::FileTriggerType trigger, uint32_t events) override; - bool isFileEventInitialized() override { - return user_file_event_ != nullptr; - } + bool isFileEventInitialized() override { return user_file_event_ != nullptr; } Network::IoHandlePtr duplicate() override; void activateFileEvents(uint32_t events) override; diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index 53daf93029bfc..75b4155cac8aa 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -79,7 +79,9 @@ class ProxyProtocolTest : public testing::TestWithParam Date: Sun, 20 Jun 2021 05:46:55 +0000 Subject: [PATCH 08/14] address comment Signed-off-by: He Jie Xu --- envoy/network/io_handle.h | 6 ------ source/common/network/io_socket_handle_impl.h | 2 +- source/common/quic/platform/quic_logging_impl.h | 2 +- source/common/quic/quic_io_handle_wrapper.h | 2 -- .../extensions/io_socket/user_space/io_handle_impl.h | 2 -- .../listener/http_inspector/http_inspector_test.cc | 10 ++++++++-- .../listener/tls_inspector/tls_inspector_test.cc | 10 ++++++++-- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/envoy/network/io_handle.h b/envoy/network/io_handle.h index 0fbff949d9bc0..990c5cb5cd209 100644 --- a/envoy/network/io_handle.h +++ b/envoy/network/io_handle.h @@ -299,12 +299,6 @@ class IoHandle { virtual void initializeFileEvent(Event::Dispatcher& dispatcher, Event::FileReadyCb cb, Event::FileTriggerType trigger, uint32_t events) PURE; - /** - * Check whether the file event is initialized or not. - * @return return true if the file event is initialize, otherwise return false. - */ - virtual bool isFileEventInitialized() PURE; - /** * Activates file events for the current underlying fd. * @param events events that will be activated. diff --git a/source/common/network/io_socket_handle_impl.h b/source/common/network/io_socket_handle_impl.h index 8ce54cdeae339..398ab1f554f5f 100644 --- a/source/common/network/io_socket_handle_impl.h +++ b/source/common/network/io_socket_handle_impl.h @@ -70,7 +70,7 @@ class IoSocketHandleImpl : public IoHandle, protected Logger::Loggable(store_)), io_handle_(std::make_unique(42)) {} ~HttpInspectorTest() override { - io_handle_->close(); filter_.reset(); - EXPECT_EQ(false, io_handle_->isFileEventInitialized()); + EXPECT_CALL(dispatcher_, + createFileEvent_(_, _, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed)).WillOnce(ReturnNew>()); + // This is used to test the FileEvent was reset by the listener filters. + // Otherwise the assertion inside `initializeFileEvent` will be trigger. + io_handle_->initializeFileEvent(dispatcher_, [](uint32_t) -> void { }, Event::PlatformDefaultTriggerType, Event::FileReadyType::Read | Event::FileReadyType::Closed); + io_handle_->resetFileEvents(); + io_handle_->close(); } void init(bool include_inline_recv = true) { diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc index 7b98002e6cca2..4295a65f1a42f 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc @@ -33,9 +33,15 @@ class TlsInspectorTest : public testing::TestWithParam(store_)), io_handle_(std::make_unique(42)) {} ~TlsInspectorTest() override { - io_handle_->close(); filter_.reset(); - EXPECT_EQ(false, io_handle_->isFileEventInitialized()); + EXPECT_CALL(dispatcher_, + createFileEvent_(_, _, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed)).WillOnce(ReturnNew>()); + // This is used to test the FileEvent was reset by the listener filters. + // Otherwise the assertion inside `initializeFileEvent` will be trigger. + io_handle_->initializeFileEvent(dispatcher_, [](uint32_t) -> void { }, Event::PlatformDefaultTriggerType, Event::FileReadyType::Read | Event::FileReadyType::Closed); + io_handle_->resetFileEvents(); + io_handle_->close(); } void init() { From 5b9676256300d2601827d850b55e6c013d1f63b6 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sun, 20 Jun 2021 05:51:47 +0000 Subject: [PATCH 09/14] revert unrelated change Signed-off-by: He Jie Xu --- source/common/quic/platform/quic_logging_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/quic/platform/quic_logging_impl.h b/source/common/quic/platform/quic_logging_impl.h index 5ce05e08c7a49..f5dc65dd7c431 100644 --- a/source/common/quic/platform/quic_logging_impl.h +++ b/source/common/quic/platform/quic_logging_impl.h @@ -147,7 +147,7 @@ enum { // DFATAL is FATAL in debug mode, ERROR in release mode. #ifdef NDEBUG LogLevelDFATAL = LogLevelERROR, -#else // NDEBUG +#else // NDEBUG LogLevelDFATAL = LogLevelFATAL, #endif // NDEBUG }; From 155b8cd95de617536c28ab4af76db1a25d6a61c1 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sun, 20 Jun 2021 05:53:45 +0000 Subject: [PATCH 10/14] fix format Signed-off-by: He Jie Xu --- .../listener/http_inspector/http_inspector_test.cc | 9 ++++++--- .../filters/listener/tls_inspector/tls_inspector_test.cc | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc index 4bbcdb8ac2f3a..1104855f41060 100644 --- a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc +++ b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc @@ -34,11 +34,14 @@ class HttpInspectorTest : public testing::Test { ~HttpInspectorTest() override { filter_.reset(); EXPECT_CALL(dispatcher_, - createFileEvent_(_, _, Event::PlatformDefaultTriggerType, - Event::FileReadyType::Read | Event::FileReadyType::Closed)).WillOnce(ReturnNew>()); + createFileEvent_(_, _, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed)) + .WillOnce(ReturnNew>()); // This is used to test the FileEvent was reset by the listener filters. // Otherwise the assertion inside `initializeFileEvent` will be trigger. - io_handle_->initializeFileEvent(dispatcher_, [](uint32_t) -> void { }, Event::PlatformDefaultTriggerType, Event::FileReadyType::Read | Event::FileReadyType::Closed); + io_handle_->initializeFileEvent( + dispatcher_, [](uint32_t) -> void {}, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed); io_handle_->resetFileEvents(); io_handle_->close(); } diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc index 4295a65f1a42f..bb152489a569b 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc @@ -35,11 +35,14 @@ class TlsInspectorTest : public testing::TestWithParam>()); + createFileEvent_(_, _, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed)) + .WillOnce(ReturnNew>()); // This is used to test the FileEvent was reset by the listener filters. // Otherwise the assertion inside `initializeFileEvent` will be trigger. - io_handle_->initializeFileEvent(dispatcher_, [](uint32_t) -> void { }, Event::PlatformDefaultTriggerType, Event::FileReadyType::Read | Event::FileReadyType::Closed); + io_handle_->initializeFileEvent( + dispatcher_, [](uint32_t) -> void {}, Event::PlatformDefaultTriggerType, + Event::FileReadyType::Read | Event::FileReadyType::Closed); io_handle_->resetFileEvents(); io_handle_->close(); } From 1efba1fc6518525a8875f829b811f06395cb4ee4 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Sun, 20 Jun 2021 07:19:09 +0000 Subject: [PATCH 11/14] revert Signed-off-by: He Jie Xu --- source/common/quic/platform/quic_logging_impl.h | 2 +- test/mocks/network/io_handle.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/common/quic/platform/quic_logging_impl.h b/source/common/quic/platform/quic_logging_impl.h index f5dc65dd7c431..5ce05e08c7a49 100644 --- a/source/common/quic/platform/quic_logging_impl.h +++ b/source/common/quic/platform/quic_logging_impl.h @@ -147,7 +147,7 @@ enum { // DFATAL is FATAL in debug mode, ERROR in release mode. #ifdef NDEBUG LogLevelDFATAL = LogLevelERROR, -#else // NDEBUG +#else // NDEBUG LogLevelDFATAL = LogLevelFATAL, #endif // NDEBUG }; diff --git a/test/mocks/network/io_handle.h b/test/mocks/network/io_handle.h index 4f5856f2c2e69..3c661d836b05f 100644 --- a/test/mocks/network/io_handle.h +++ b/test/mocks/network/io_handle.h @@ -63,7 +63,6 @@ class MockIoHandle : public IoHandle { MOCK_METHOD(absl::optional, lastRoundTripTime, ()); MOCK_METHOD(Api::SysCallIntResult, ioctl, (unsigned long, void*, unsigned long, void*, unsigned long, unsigned long*)); - MOCK_METHOD(bool, isFileEventInitialized, ()); }; } // namespace Network From 770097a11bab1fecb0acbccd7537b57e011c97b5 Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Mon, 21 Jun 2021 09:16:44 +0000 Subject: [PATCH 12/14] fix fuzz test Signed-off-by: He Jie Xu --- .../filters/listener/common/fuzz/listener_filter_fuzzer.cc | 4 ++-- .../filters/listener/common/fuzz/listener_filter_fuzzer.h | 2 +- .../listener/http_inspector/http_inspector_fuzz_test.cc | 2 +- .../filters/listener/original_dst/original_dst_fuzz_test.cc | 2 +- .../filters/listener/original_src/original_src_fuzz_test.cc | 2 +- .../listener/proxy_protocol/proxy_protocol_fuzz_test.cc | 2 +- .../filters/listener/tls_inspector/tls_inspector_fuzz_test.cc | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.cc b/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.cc index 89db1e5e51401..62fc696512081 100644 --- a/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.cc +++ b/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.cc @@ -5,7 +5,7 @@ namespace Extensions { namespace ListenerFilters { void ListenerFilterFuzzer::fuzz( - Network::ListenerFilter& filter, + Network::ListenerFilterPtr filter, const test::extensions::filters::listener::FilterFuzzTestCase& input) { try { socket_.addressProvider().setLocalAddress( @@ -32,7 +32,7 @@ void ListenerFilterFuzzer::fuzz( testing::ReturnNew>())); } - filter.onAccept(cb_); + filter->onAccept(cb_); if (file_event_callback_ == nullptr) { // If filter does not call createFileEvent (i.e. original_dst and original_src) diff --git a/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.h b/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.h index fa98a6c552672..7caab46d77883 100644 --- a/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.h +++ b/test/extensions/filters/listener/common/fuzz/listener_filter_fuzzer.h @@ -23,7 +23,7 @@ class ListenerFilterFuzzer { ON_CALL(Const(cb_), dynamicMetadata()).WillByDefault(testing::ReturnRef(metadata_)); } - void fuzz(Network::ListenerFilter& filter, + void fuzz(Network::ListenerFilterPtr filter, const test::extensions::filters::listener::FilterFuzzTestCase& input); private: diff --git a/test/extensions/filters/listener/http_inspector/http_inspector_fuzz_test.cc b/test/extensions/filters/listener/http_inspector/http_inspector_fuzz_test.cc index 624475651551d..d8ea3d2b2b4d8 100644 --- a/test/extensions/filters/listener/http_inspector/http_inspector_fuzz_test.cc +++ b/test/extensions/filters/listener/http_inspector/http_inspector_fuzz_test.cc @@ -22,7 +22,7 @@ DEFINE_PROTO_FUZZER(const test::extensions::filters::listener::FilterFuzzTestCas auto filter = std::make_unique(cfg); ListenerFilterFuzzer fuzzer; - fuzzer.fuzz(*filter, input); + fuzzer.fuzz(std::move(filter), input); } } // namespace HttpInspector diff --git a/test/extensions/filters/listener/original_dst/original_dst_fuzz_test.cc b/test/extensions/filters/listener/original_dst/original_dst_fuzz_test.cc index 49ccc85a71e3a..f8d4368b79813 100644 --- a/test/extensions/filters/listener/original_dst/original_dst_fuzz_test.cc +++ b/test/extensions/filters/listener/original_dst/original_dst_fuzz_test.cc @@ -20,7 +20,7 @@ DEFINE_PROTO_FUZZER(const test::extensions::filters::listener::FilterFuzzTestCas auto filter = std::make_unique(envoy::config::core::v3::TrafficDirection::UNSPECIFIED); ListenerFilterFuzzer fuzzer; - fuzzer.fuzz(*filter, input); + fuzzer.fuzz(std::move(filter), input); } } // namespace OriginalDst diff --git a/test/extensions/filters/listener/original_src/original_src_fuzz_test.cc b/test/extensions/filters/listener/original_src/original_src_fuzz_test.cc index 2e3c8dc5a646a..2b2f70ee016a5 100644 --- a/test/extensions/filters/listener/original_src/original_src_fuzz_test.cc +++ b/test/extensions/filters/listener/original_src/original_src_fuzz_test.cc @@ -21,7 +21,7 @@ DEFINE_PROTO_FUZZER( Config config(input.config()); auto filter = std::make_unique(config); ListenerFilterFuzzer fuzzer; - fuzzer.fuzz(*filter, input.fuzzed()); + fuzzer.fuzz(std::move(filter), input.fuzzed()); } } // namespace OriginalSrc diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_fuzz_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_fuzz_test.cc index 4e0cbced1409c..7416e92c8bba4 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_fuzz_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_fuzz_test.cc @@ -23,7 +23,7 @@ DEFINE_PROTO_FUZZER( auto filter = std::make_unique(std::move(cfg)); ListenerFilterFuzzer fuzzer; - fuzzer.fuzz(*filter, input.fuzzed()); + fuzzer.fuzz(std::move(filter), input.fuzzed()); } } // namespace ProxyProtocol diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_fuzz_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_fuzz_test.cc index fc4b4f1ae2620..b722a2c50ec54 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_fuzz_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_fuzz_test.cc @@ -31,7 +31,7 @@ DEFINE_PROTO_FUZZER( auto filter = std::make_unique(std::move(cfg)); ListenerFilterFuzzer fuzzer; - fuzzer.fuzz(*filter, input.fuzzed()); + fuzzer.fuzz(std::move(filter), input.fuzzed()); } } // namespace TlsInspector From 12e4fec3ff8dc5c2859a5923de9e6d887950e7ff Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Mon, 21 Jun 2021 09:18:45 +0000 Subject: [PATCH 13/14] revert unrelated format fix Signed-off-by: He Jie Xu --- source/common/quic/platform/quic_logging_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/quic/platform/quic_logging_impl.h b/source/common/quic/platform/quic_logging_impl.h index 5ce05e08c7a49..f5dc65dd7c431 100644 --- a/source/common/quic/platform/quic_logging_impl.h +++ b/source/common/quic/platform/quic_logging_impl.h @@ -147,7 +147,7 @@ enum { // DFATAL is FATAL in debug mode, ERROR in release mode. #ifdef NDEBUG LogLevelDFATAL = LogLevelERROR, -#else // NDEBUG +#else // NDEBUG LogLevelDFATAL = LogLevelFATAL, #endif // NDEBUG }; From ab10edbc5b382849d63ade4e9c327f7a7097413d Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Tue, 22 Jun 2021 08:55:57 +0000 Subject: [PATCH 14/14] address comments Signed-off-by: He Jie Xu --- .../filters/listener/proxy_protocol/proxy_protocol.h | 2 +- .../filters/listener/tls_inspector/tls_inspector.h | 2 +- source/server/active_tcp_listener.cc | 2 +- .../listener/proxy_protocol/proxy_protocol_test.cc | 9 +++++---- test/integration/listener_filter_integration_test.cc | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h index 1f1821deee8e2..3eeb067466f31 100644 --- a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h +++ b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.h @@ -122,7 +122,7 @@ class Filter : public Network::ListenerFilter, Logger::Loggable lenV2Address(char* buf); - Network::ListenerFilterCallbacks* cb_{nullptr}; + Network::ListenerFilterCallbacks* cb_{}; // The offset in buf_ that has been fully read size_t buf_off_{}; diff --git a/source/extensions/filters/listener/tls_inspector/tls_inspector.h b/source/extensions/filters/listener/tls_inspector/tls_inspector.h index 34a48ef27e373..bd64cd2bd3f54 100644 --- a/source/extensions/filters/listener/tls_inspector/tls_inspector.h +++ b/source/extensions/filters/listener/tls_inspector/tls_inspector.h @@ -90,7 +90,7 @@ class Filter : public Network::ListenerFilter, Logger::Loggable ssl_; uint64_t read_{0}; diff --git a/source/server/active_tcp_listener.cc b/source/server/active_tcp_listener.cc index 462ee18e4dbf8..a8a2120ba2a08 100644 --- a/source/server/active_tcp_listener.cc +++ b/source/server/active_tcp_listener.cc @@ -200,7 +200,7 @@ void ActiveTcpSocket::newConnection() { socket_->setDetectedTransportProtocol("raw_buffer"); } // Clear the listener filter to ensure the file event registered by - // listener filter to be removed. reference PR #8922. + // listener filter to be removed. reference https://github.com/envoyproxy/envoy/issues/8925. accept_filters_.clear(); // Create a new connection on this listener. listener_.newConnection(std::move(socket_), std::move(stream_info_)); diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index 75b4155cac8aa..8c3168d71f67a 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -54,7 +54,7 @@ class ProxyProtocolTest : public testing::TestWithParam { public: ProxyProtocolTest() - : api_(Api::createApiForTest(stats_store_)), + : api_(Api::createApiForTest(stats_store_, time_system_)), dispatcher_(api_->allocateDispatcher("test_thread")), socket_(std::make_shared( Network::Test::getCanonicalLoopbackAddress(GetParam()), nullptr, true)), @@ -186,6 +186,7 @@ class ProxyProtocolTest : public testing::TestWithParamrun(Event::Dispatcher::RunType::NonBlock); + time_system_.advanceTimeAndRun(std::chrono::milliseconds(2000), *dispatcher_, + Event::Dispatcher::RunType::NonBlock); if (GetParam() == Envoy::Network::Address::IpVersion::v4) { EXPECT_EQ(server_connection_->addressProvider().remoteAddress()->ip()->addressAsString(), "127.0.0.1"); @@ -225,7 +226,7 @@ TEST_P(ProxyProtocolTest, Timeout) { EXPECT_EQ(server_connection_->addressProvider().remoteAddress()->ip()->addressAsString(), "::1"); } - + EXPECT_EQ(stats_store_.counter("downstream_cx_total").value(), 1); disconnect(); } diff --git a/test/integration/listener_filter_integration_test.cc b/test/integration/listener_filter_integration_test.cc index ee5107e4efc37..ccd5f360a77ab 100644 --- a/test/integration/listener_filter_integration_test.cc +++ b/test/integration/listener_filter_integration_test.cc @@ -152,7 +152,7 @@ TEST_P(ListenerFilterIntegrationTest, ContinueOnListenerTimeout) { Buffer::OwnedImpl buffer("fake data"); client_->write(buffer, false); // the timeout is set as one seconds, sleep 5 to trigger the timeout. - absl::SleepFor(absl::Seconds(5)); + timeSystem().advanceTimeWaitImpl(std::chrono::milliseconds(2000)); client_->close(Network::ConnectionCloseType::NoFlush); EXPECT_THAT(waitForAccessLog(listener_access_log_name_), testing::Eq("-")); }