diff --git a/bazel/external/quiche.BUILD b/bazel/external/quiche.BUILD index 69cae5ea7c61f..d3b82aad1b915 100644 --- a/bazel/external/quiche.BUILD +++ b/bazel/external/quiche.BUILD @@ -169,6 +169,7 @@ cc_library( "quiche/quic/platform/api/quic_ptr_util.h", "quiche/quic/platform/api/quic_reference_counted.h", "quiche/quic/platform/api/quic_server_stats.h", + "quiche/quic/platform/api/quic_stream_buffer_allocator.h", "quiche/quic/platform/api/quic_string_piece.h", "quiche/quic/platform/api/quic_test_output.h", "quiche/quic/platform/api/quic_uint128.h", @@ -223,6 +224,20 @@ cc_library( deps = [":quic_platform"], ) +cc_library( + name = "quic_buffer_allocator_lib", + srcs = [ + "quiche/quic/core/quic_buffer_allocator.cc", + "quiche/quic/core/quic_simple_buffer_allocator.cc", + ], + hdrs = [ + "quiche/quic/core/quic_buffer_allocator.h", + "quiche/quic/core/quic_simple_buffer_allocator.h", + ], + visibility = ["//visibility:public"], + deps = [":quic_platform_export"], +) + envoy_cc_test( name = "http2_platform_test", srcs = envoy_select_quiche( diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index b363f4f4bfc83..f2f8671998833 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -236,8 +236,8 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/google/subpar/archive/1.3.0.tar.gz"], ), com_googlesource_quiche = dict( - # Static snapshot of https://quiche.googlesource.com/quiche/+archive/4fbea5de9afdf30611b27afd54c45a596944f9c2.tar.gz - sha256 = "2cf9f5ea62a03ca0d8773fe4f56949b72c28ac5b1bcf43d850a571f4e32add2a", - urls = ["https://storage.googleapis.com/quiche-envoy-integration/4fbea5de9afdf30611b27afd54c45a596944f9c2.tar.gz"], + # Static snapshot of https://quiche.googlesource.com/quiche/+archive/ba6354aa1b39f3d9788ead909ad3e678ac863938.tar.gz + sha256 = "4598537810c3d343c32333c5367fcb652638018118f7f4e844e080405d9e73bb", + urls = ["https://storage.googleapis.com/quiche-envoy-integration/ba6354aa1b39f3d9788ead909ad3e678ac863938.tar.gz"], ), ) diff --git a/source/extensions/quic_listeners/quiche/platform/BUILD b/source/extensions/quic_listeners/quiche/platform/BUILD index 4244e69f7c91b..0cfc9373b4e9c 100644 --- a/source/extensions/quic_listeners/quiche/platform/BUILD +++ b/source/extensions/quic_listeners/quiche/platform/BUILD @@ -102,6 +102,7 @@ envoy_cc_library( "quic_ptr_util_impl.h", "quic_server_stats_impl.h", "quic_string_piece_impl.h", + "quic_stream_buffer_allocator_impl.h", "quic_uint128_impl.h", ] + envoy_select_quiche([ "quic_expect_bug_impl.h", @@ -121,7 +122,10 @@ envoy_cc_library( "googletest", ], visibility = ["//visibility:public"], - deps = ["@com_googlesource_quiche//:quic_platform_export"] + envoy_select_quiche([ + deps = [ + "@com_googlesource_quiche//:quic_platform_export", + "@com_googlesource_quiche//:quic_buffer_allocator_lib", + ] + envoy_select_quiche([ ":quic_platform_logging_impl_lib", "//include/envoy/thread:thread_interface", "//source/common/common:assert_lib", diff --git a/source/extensions/quic_listeners/quiche/platform/quic_stream_buffer_allocator_impl.h b/source/extensions/quic_listeners/quiche/platform/quic_stream_buffer_allocator_impl.h new file mode 100644 index 0000000000000..c2a40a0e7427a --- /dev/null +++ b/source/extensions/quic_listeners/quiche/platform/quic_stream_buffer_allocator_impl.h @@ -0,0 +1,18 @@ +#pragma once + +// NOLINT(namespace-envoy) + +// This file is part of the QUICHE platform implementation, and is not to be +// consumed or referenced directly by other Envoy code. It serves purely as a +// porting layer for QUICHE. + +#include "quiche/quic/core/quic_simple_buffer_allocator.h" + +namespace quic { + +// Implements the interface required by +// https://quiche.googlesource.com/quiche/+/refs/heads/master/quic/platform/api/quic_stream_buffer_allocator.h +// with the default implementation provided by QUICHE. +using QuicStreamBufferAllocatorImpl = SimpleBufferAllocator; + +} // namespace quic diff --git a/test/extensions/quic_listeners/quiche/platform/BUILD b/test/extensions/quic_listeners/quiche/platform/BUILD index 1518271bc8d2a..d2ec6aa11f9b1 100644 --- a/test/extensions/quic_listeners/quiche/platform/BUILD +++ b/test/extensions/quic_listeners/quiche/platform/BUILD @@ -31,6 +31,8 @@ envoy_cc_test( ], external_deps = ["quiche_quic_platform"], deps = [ + "//source/common/memory:stats_lib", + "//test/common/stats:stat_test_utility_lib", "//test/extensions/transport_sockets/tls:ssl_test_utils", "//test/mocks/api:api_mocks", "//test/test_common:logging_lib", diff --git a/test/extensions/quic_listeners/quiche/platform/quic_platform_test.cc b/test/extensions/quic_listeners/quiche/platform/quic_platform_test.cc index 294e58e708ba0..df87edca85dd4 100644 --- a/test/extensions/quic_listeners/quiche/platform/quic_platform_test.cc +++ b/test/extensions/quic_listeners/quiche/platform/quic_platform_test.cc @@ -9,8 +9,10 @@ #include #include +#include "common/memory/stats.h" #include "common/network/utility.h" +#include "test/common/stats/stat_test_utility.h" #include "test/extensions/transport_sockets/tls/ssl_test_utility.h" #include "test/mocks/api/mocks.h" #include "test/test_common/environment.h" @@ -42,20 +44,20 @@ #include "quiche/quic/platform/api/quic_server_stats.h" #include "quiche/quic/platform/api/quic_sleep.h" #include "quiche/quic/platform/api/quic_stack_trace.h" +#include "quiche/quic/platform/api/quic_stream_buffer_allocator.h" #include "quiche/quic/platform/api/quic_string_piece.h" #include "quiche/quic/platform/api/quic_test_output.h" #include "quiche/quic/platform/api/quic_thread.h" #include "quiche/quic/platform/api/quic_uint128.h" -using testing::_; -using testing::HasSubstr; - // Basic tests to validate functioning of the QUICHE quic platform // implementation. For platform APIs in which the implementation is a simple // typedef/passthrough to a std:: or absl:: construct, the tests are kept // minimal, and serve primarily to verify the APIs compile and link without // issue. +using testing::_; +using testing::HasSubstr; using testing::Return; namespace quic { @@ -572,5 +574,21 @@ TEST_F(QuicPlatformTest, FailToPickUnsedPort) { EXPECT_DEATH_LOG_TO_STDERR(QuicPickUnusedPortOrDie(), "Failed to pick a port for test."); } +TEST_F(QuicPlatformTest, TestEnvoyQuicBufferAllocator) { + bool deterministic_stats = Envoy::Stats::TestUtil::hasDeterministicMallocStats(); + const size_t start_mem = Envoy::Memory::Stats::totalCurrentlyAllocated(); + QuicStreamBufferAllocator allocator; + char* p = allocator.New(1024); + if (deterministic_stats) { + EXPECT_LT(start_mem, Envoy::Memory::Stats::totalCurrentlyAllocated()); + } + EXPECT_NE(nullptr, p); + memset(p, 'a', 1024); + allocator.Delete(p); + if (deterministic_stats) { + EXPECT_EQ(start_mem, Envoy::Memory::Stats::totalCurrentlyAllocated()); + } +} + } // namespace } // namespace quic