diff --git a/bazel/external/quiche.BUILD b/bazel/external/quiche.BUILD new file mode 100644 index 0000000000000..6170b413f1680 --- /dev/null +++ b/bazel/external/quiche.BUILD @@ -0,0 +1,41 @@ +# Transformations to QUICHE tarball: +# - Move subtree under quiche/ base dir, for clarity in #include statements. +# - Rewrite include directives for platform/impl files. + +src_files = glob(["**/*.h", "**/*.cc"]) + +genrule( + name = "quiche_files", + srcs = src_files, + outs = ["quiche/" + f for f in src_files], + cmd = "\n".join( + ["sed -e '/^#include/ s|net/http2/platform/impl/|extensions/filters/datagram/quiche/platform/|' $(location %s) > $(location :%s)" % (f, "quiche/" + f) for f in src_files], + ), + visibility = ["//visibility:private"], +) + +cc_library( + name = "http2_platform", + hdrs = [ + "quiche/http2/platform/api/http2_arraysize.h", + "quiche/http2/platform/api/http2_bug_tracker.h", + "quiche/http2/platform/api/http2_containers.h", + "quiche/http2/platform/api/http2_estimate_memory_usage.h", + "quiche/http2/platform/api/http2_export.h", + "quiche/http2/platform/api/http2_flags.h", + "quiche/http2/platform/api/http2_flag_utils.h", + "quiche/http2/platform/api/http2_macros.h", + "quiche/http2/platform/api/http2_mock_log.h", + "quiche/http2/platform/api/http2_optional.h", + "quiche/http2/platform/api/http2_ptr_util.h", + "quiche/http2/platform/api/http2_reconstruct_object.h", + "quiche/http2/platform/api/http2_string.h", + "quiche/http2/platform/api/http2_string_piece.h", + "quiche/http2/platform/api/http2_string_utils.h", + "quiche/http2/platform/api/http2_test_helpers.h", + ], + visibility = ["//visibility:public"], + deps = [ + "@envoy//source/extensions/filters/datagram/quiche/platform:http2_platform_impl_lib", + ], +) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 7e4e63b092e36..3c9a20321414b 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -41,7 +41,9 @@ def _repository_impl(name, **kwargs): http_archive( name = name, urls = location["urls"], - sha256 = location["sha256"], + # Hack: make checksum optional, to accomodate QUICHE. + # DO NOT SUBMIT, this is just for prototyping. + sha256 = location.get("sha256", None), strip_prefix = location.get("strip_prefix", ""), **kwargs ) @@ -297,6 +299,7 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): _com_github_tencent_rapidjson() _com_google_googletest() _com_google_protobuf() + _com_google_quiche() # Used for bundling gcovr into a relocatable .par file. _repository_impl("subpar") @@ -539,6 +542,16 @@ def _com_google_protobuf(): actual = "@com_google_protobuf//util/python:python_headers", ) +def _com_google_quiche(): + _repository_impl( + name = "com_google_quiche", + build_file = "@envoy//bazel/external:quiche.BUILD", + ) + native.bind( + name = "quiche_http2_platform", + actual = "@com_google_quiche//:http2_platform", + ) + def _com_github_grpc_grpc(): _repository_impl("com_github_grpc_grpc") diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index efceb2ae23fa1..5784421faef2d 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -195,4 +195,9 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "subpar-1.3.0", urls = ["https://github.com/google/subpar/archive/1.3.0.tar.gz"], ), + com_google_quiche = dict( + # TODO: add sha256 sum + # Version from 2018-12-20 + urls = ["https://quiche.googlesource.com/quiche/+archive/15fb5630803634b1988b77d876212fad71f7a2c3.tar.gz"], + ), ) diff --git a/source/extensions/filters/datagram/quiche/BUILD b/source/extensions/filters/datagram/quiche/BUILD new file mode 100644 index 0000000000000..3a3b592647f73 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/BUILD @@ -0,0 +1,16 @@ +licenses(["notice"]) # Apache 2 + +load( + "//bazel:envoy_build_system.bzl", + "envoy_cc_library", + "envoy_package", +) + +envoy_package() + +envoy_cc_library( + name = "dummy_lib", + srcs = ["dummy.cc"], + hdrs = ["dummy.h"], + external_deps = ["quiche_http2_platform"], +) diff --git a/source/extensions/filters/datagram/quiche/dummy.cc b/source/extensions/filters/datagram/quiche/dummy.cc new file mode 100644 index 0000000000000..c181e387e6dbe --- /dev/null +++ b/source/extensions/filters/datagram/quiche/dummy.cc @@ -0,0 +1,17 @@ +#include "extensions/filters/datagram/quiche/dummy.h" + +using http2::Http2String; + +namespace Envoy { +namespace Extensions { +namespace DatagramFilters { +namespace Quiche { + +Http2String moreCowbell(const Http2String& s) { + return s + " cowbell"; +} + +} // namespace Quiche +} // namespace DatagramFilters +} // namespace Extensions +} // namespace Envoy diff --git a/source/extensions/filters/datagram/quiche/dummy.h b/source/extensions/filters/datagram/quiche/dummy.h new file mode 100644 index 0000000000000..30008c8e0a3ee --- /dev/null +++ b/source/extensions/filters/datagram/quiche/dummy.h @@ -0,0 +1,15 @@ +#pragma once + +#include "quiche/http2/platform/api/http2_string.h" + +namespace Envoy { +namespace Extensions { +namespace DatagramFilters { +namespace Quiche { + +http2::Http2String moreCowbell(const http2::Http2String& s); + +} // namespace Quiche +} // namespace DatagramFilters +} // namespace Extensions +} // namespace Envoy diff --git a/source/extensions/filters/datagram/quiche/platform/BUILD b/source/extensions/filters/datagram/quiche/platform/BUILD new file mode 100644 index 0000000000000..6d158e366fa3c --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/BUILD @@ -0,0 +1,32 @@ +licenses(["notice"]) # Apache 2 + +load( + "//bazel:envoy_build_system.bzl", + "envoy_cc_library", + "envoy_package", +) + +envoy_package() + +envoy_cc_library( + name = "http2_platform_impl_lib", + hdrs = [ + "http2_arraysize_impl.h", + "http2_bug_tracker_impl.h", + "http2_containers_impl.h", + "http2_estimate_memory_usage_impl.h", + "http2_export_impl.h", + "http2_flag_utils_impl.h", + "http2_flags_impl.h", + "http2_macros_impl.h", + "http2_mock_log_impl.h", + "http2_optional_impl.h", + "http2_ptr_util_impl.h", + "http2_reconstruct_object_impl.h", + "http2_string_impl.h", + "http2_string_piece_impl.h", + "http2_string_utils_impl.h", + "http2_test_helpers_impl.h", + ], + visibility = ["//visibility:public"], +) diff --git a/source/extensions/filters/datagram/quiche/platform/http2_arraysize_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_arraysize_impl.h new file mode 100644 index 0000000000000..2e12c5f9bd3f0 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_arraysize_impl.h @@ -0,0 +1,3 @@ +#pragma once + +#define HTTP2_ARRAYSIZE_IMPL(x) 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_bug_tracker_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_bug_tracker_impl.h new file mode 100644 index 0000000000000..930f2f8039cfb --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_bug_tracker_impl.h @@ -0,0 +1,5 @@ +#pragma once + +#define HTTP2_BUG_IMPL 0 +#define HTTP2_BUG_IF_IMPL 0 +#define FLAGS_http2_always_log_bugs_for_tests_IMPL 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_containers_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_containers_impl.h new file mode 100644 index 0000000000000..3c4a105bf4271 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_containers_impl.h @@ -0,0 +1,8 @@ +#pragma once + +namespace http2 { + +template +class Http2DequeImpl {}; + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_estimate_memory_usage_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_estimate_memory_usage_impl.h new file mode 100644 index 0000000000000..b75121087763c --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_estimate_memory_usage_impl.h @@ -0,0 +1,10 @@ +#pragma once + +namespace http2 { + +template +size_t Http2EstimateMemoryUsageImpl(const T& object) { + return 0; +} + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_export_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_export_impl.h new file mode 100644 index 0000000000000..04aae9ac87a80 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_export_impl.h @@ -0,0 +1,4 @@ +#pragma once + +#define HTTP2_EXPORT +#define HTTP2_EXPORT_PRIVATE diff --git a/source/extensions/filters/datagram/quiche/platform/http2_flag_utils_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_flag_utils_impl.h new file mode 100644 index 0000000000000..ecae5d8fadb97 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_flag_utils_impl.h @@ -0,0 +1,3 @@ +#pragma once + +#define HTTP2_RELOADABLE_FLAG_COUNT_IMPL(flag) 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_flags_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_flags_impl.h new file mode 100644 index 0000000000000..25dd62cce4b98 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_flags_impl.h @@ -0,0 +1,4 @@ +#pragma once + +#define GetHttp2ReloadableFlagImpl(flag) 0 +#define SetHttp2ReloadableFlagImpl(flag, value) 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_macros_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_macros_impl.h new file mode 100644 index 0000000000000..160da9445629b --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_macros_impl.h @@ -0,0 +1,5 @@ +#pragma once + +#define HTTP2_FALLTHROUGH_IMPL 0 +#define HTTP2_UNREACHABLE_IMPL() 0 +#define HTTP2_DIE_IF_NULL_IMPL(ptr) 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_mock_log_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_mock_log_impl.h new file mode 100644 index 0000000000000..6e8d5257b22c4 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_mock_log_impl.h @@ -0,0 +1,5 @@ +#pragma once + +#define CREATE_HTTP2_MOCK_LOG_IMPL(log) 0 +#define EXPECT_HTTP2_LOG_CALL_IMPL(log) 0 +#define EXPECT_HTTP2_LOG_CALL_CONTAINS_IMPL(log, level, content) 0 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_optional_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_optional_impl.h new file mode 100644 index 0000000000000..0809d60c6134c --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_optional_impl.h @@ -0,0 +1,8 @@ +#pragma once + +namespace http2 { + +template +class Http2OptionalImpl {}; + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_ptr_util_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_ptr_util_impl.h new file mode 100644 index 0000000000000..eb746cb12afd4 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_ptr_util_impl.h @@ -0,0 +1,10 @@ +#pragma once + +namespace http2 { + +template +std::unique_ptr Http2MakeUniqueImpl(Args&&... args) { + return nullptr; +} + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_reconstruct_object_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_reconstruct_object_impl.h new file mode 100644 index 0000000000000..69f2c5cd035b0 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_reconstruct_object_impl.h @@ -0,0 +1,25 @@ +#pragma once + +namespace http2 { +namespace test { + +void MarkMemoryUninitialized(void* ptr, size_t num_bytes) {} +void MarkMemoryUninitialized(void* ptr, size_t num_bytes, Http2Random* rng) {} + +template +void MarkObjectUninitialized(T* ptr) {} +template +void MarkObjectUninitialized(T* ptr, Http2Random* rng) {} + +template +void MarkArrayUninitialized(T (&array)[N]) {} +template +void MarkArrayUninitialized(T (&array)[N], Http2Random* rng) {} + +template +void Http2ReconstructObjectImpl(T* ptr, Http2Random* rng, Args&&... args) {} +template +void Http2DefaultReconstructObjectImpl(T* ptr, Http2Random* rng) {} + +} // namespace test +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_string_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_string_impl.h new file mode 100644 index 0000000000000..b6fc203e2b302 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_string_impl.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace http2 { + +using Http2StringImpl = std::string; + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_string_piece_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_string_piece_impl.h new file mode 100644 index 0000000000000..6e26f8a4c9fb7 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_string_piece_impl.h @@ -0,0 +1,7 @@ +#pragma once + +namespace http2 { + +class Http2StringPieceImpl {}; + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_string_utils_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_string_utils_impl.h new file mode 100644 index 0000000000000..8ee16abaea650 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_string_utils_impl.h @@ -0,0 +1,39 @@ +#pragma once + +namespace http2 { + +template +inline Http2String Http2StrCatImpl(const Args&... args) { + return Http2String(); +} + +template +inline void Http2StrAppendImpl(Http2String* output, const Args&... args) {} + +template +inline Http2String Http2StringPrintfImpl(const Args&... args) { + return Http2String(); +} + +inline Http2String Http2HexEncodeImpl(const void* bytes, size_t size) { + return Http2String(); +} + +inline Http2String Http2HexDecodeImpl(Http2StringPiece data) { + return Http2String(); +} + +inline Http2String Http2HexDumpImpl(Http2StringPiece data) { + return Http2String(); +} + +inline Http2String Http2HexEscapeImpl(Http2StringPiece data) { + return Http2String(); +} + +template +inline Http2String Http2HexImpl(Number number) { + return Http2String(); +} + +} // namespace http2 diff --git a/source/extensions/filters/datagram/quiche/platform/http2_test_helpers_impl.h b/source/extensions/filters/datagram/quiche/platform/http2_test_helpers_impl.h new file mode 100644 index 0000000000000..6f70f09beec22 --- /dev/null +++ b/source/extensions/filters/datagram/quiche/platform/http2_test_helpers_impl.h @@ -0,0 +1 @@ +#pragma once diff --git a/test/extensions/filters/datagram/quiche/BUILD b/test/extensions/filters/datagram/quiche/BUILD new file mode 100644 index 0000000000000..8ef984195f4dc --- /dev/null +++ b/test/extensions/filters/datagram/quiche/BUILD @@ -0,0 +1,23 @@ +licenses(["notice"]) # Apache 2 + +load( + "//bazel:envoy_build_system.bzl", + "envoy_cc_fuzz_test", + "envoy_cc_test", + "envoy_cc_test_binary", + "envoy_cc_test_library", + "envoy_package", + "envoy_proto_library", +) + +envoy_package() + +envoy_cc_test( + name = "dummy_test", + srcs = ["dummy_test.cc"], + external_deps = ["quiche_http2_platform"], + deps = [ + "//source/extensions/filters/datagram/quiche:dummy_lib", + "//test/test_common:utility_lib", + ], +) diff --git a/test/extensions/filters/datagram/quiche/dummy_test.cc b/test/extensions/filters/datagram/quiche/dummy_test.cc new file mode 100644 index 0000000000000..d934cbee5d3fd --- /dev/null +++ b/test/extensions/filters/datagram/quiche/dummy_test.cc @@ -0,0 +1,19 @@ +#include "extensions/filters/datagram/quiche/dummy.h" + +#include "gtest/gtest.h" +#include "quiche/http2/platform/api/http2_string.h" + +namespace Envoy { +namespace Extensions { +namespace DatagramFilters { +namespace Quiche { + +TEST(DummyTest, Dummy) { + http2::Http2String foo = "bar"; + EXPECT_EQ("bar cowbell", moreCowbell(foo)); +} + +} // namespace Quiche +} // namespace DatagramFilters +} // namespace Extensions +} // namespace Envoy