Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions bazel/external/quiche.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ cc_library(
"quiche/http2/platform/api/http2_string.h",
"quiche/http2/platform/api/http2_string_piece.h",
# TODO: uncomment the following files as implementations are added.
# "quiche/http2/platform/api/http2_bug_tracker.h",
# "quiche/http2/platform/api/http2_flags.h",
# "quiche/http2/platform/api/http2_mock_log.h",
# "quiche/http2/platform/api/http2_reconstruct_object.h",
# "quiche/http2/platform/api/http2_test_helpers.h",
] + envoy_select_quiche(
["quiche/http2/platform/api/http2_string_utils.h"],
[
"quiche/http2/platform/api/http2_bug_tracker.h",
"quiche/http2/platform/api/http2_logging.h",
"quiche/http2/platform/api/http2_string_utils.h",
],
"@envoy",
),
visibility = ["//visibility:public"],
Expand All @@ -90,7 +92,11 @@ cc_library(
# TODO: uncomment the following files as implementations are added.
# "quiche/spdy/platform/api/spdy_flags.h",
] + envoy_select_quiche(
["quiche/spdy/platform/api/spdy_string_utils.h"],
[
"quiche/spdy/platform/api/spdy_bug_tracker.h",
"quiche/spdy/platform/api/spdy_logging.h",
"quiche/spdy/platform/api/spdy_string_utils.h",
],
"@envoy",
),
visibility = ["//visibility:public"],
Expand Down Expand Up @@ -130,7 +136,6 @@ cc_library(
hdrs = [
"quiche/quic/platform/api/quic_aligned.h",
"quiche/quic/platform/api/quic_arraysize.h",
"quiche/quic/platform/api/quic_bug_tracker.h",
"quiche/quic/platform/api/quic_client_stats.h",
"quiche/quic/platform/api/quic_containers.h",
"quiche/quic/platform/api/quic_endian.h",
Expand All @@ -139,21 +144,16 @@ cc_library(
"quiche/quic/platform/api/quic_fallthrough.h",
"quiche/quic/platform/api/quic_flag_utils.h",
"quiche/quic/platform/api/quic_iovec.h",
"quiche/quic/platform/api/quic_logging.h",
"quiche/quic/platform/api/quic_map_util.h",
"quiche/quic/platform/api/quic_mock_log.h",
"quiche/quic/platform/api/quic_prefetch.h",
"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_stack_trace.h",
"quiche/quic/platform/api/quic_string_piece.h",
"quiche/quic/platform/api/quic_test_output.h",
"quiche/quic/platform/api/quic_uint128.h",
"quiche/quic/platform/api/quic_thread.h",
# TODO: uncomment the following files as implementations are added.
# "quiche/quic/platform/api/quic_clock.h",
# "quiche/quic/platform/api/quic_expect_bug.h",
# "quiche/quic/platform/api/quic_file_utils.h",
# "quiche/quic/platform/api/quic_flags.h",
# "quiche/quic/platform/api/quic_fuzzed_data_provider.h",
Expand All @@ -166,15 +166,19 @@ cc_library(
# "quiche/quic/platform/api/quic_mem_slice_storage.h",
# "quiche/quic/platform/api/quic_pcc_sender.h",
# "quiche/quic/platform/api/quic_socket_address.h",
# "quiche/quic/platform/api/quic_stack_trace.h",
# "quiche/quic/platform/api/quic_test.h",
# "quiche/quic/platform/api/quic_test_loopback.h",
# "quiche/quic/platform/api/quic_test_mem_slice_vector.h",
] + envoy_select_quiche(
[
"quiche/quic/platform/api/quic_bug_tracker.h",
"quiche/quic/platform/api/quic_expect_bug.h",
"quiche/quic/platform/api/quic_mock_log.h",
"quiche/quic/platform/api/quic_logging.h",
"quiche/quic/platform/api/quic_stack_trace.h",
"quiche/quic/platform/api/quic_string_utils.h",
"quiche/quic/platform/api/quic_test.h",
"quiche/quic/platform/api/quic_text_utils.h",
"quiche/quic/platform/api/quic_thread.h",
],
"@envoy",
),
Expand Down Expand Up @@ -222,12 +226,11 @@ envoy_cc_test(

envoy_cc_test(
name = "quic_platform_test",
srcs = [
"quiche/quic/platform/api/quic_reference_counted_test.cc",
] + envoy_select_quiche(
srcs = envoy_select_quiche(
[
"quiche/quic/platform/api/quic_text_utils_test.cc",
"quiche/quic/platform/api/quic_reference_counted_test.cc",
"quiche/quic/platform/api/quic_string_utils_test.cc",
"quiche/quic/platform/api/quic_text_utils_test.cc",
],
"@envoy",
),
Expand Down
33 changes: 28 additions & 5 deletions source/extensions/quic_listeners/quiche/platform/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,21 @@ envoy_cc_library(
"http2_ptr_util_impl.h",
"http2_string_impl.h",
"http2_string_piece_impl.h",
] + envoy_select_quiche(["http2_string_utils_impl.h"]),
] + envoy_select_quiche([
"http2_bug_tracker_impl.h",
"http2_logging_impl.h",
"http2_string_utils_impl.h",
]),
external_deps = [
"abseil_base",
"abseil_optional",
"abseil_str_format",
],
visibility = ["//visibility:public"],
deps = envoy_select_quiche([":string_utils_lib"]),
deps = envoy_select_quiche([
":quic_platform_logging_impl_lib",
":string_utils_lib",
]),
)

envoy_cc_library(
Expand All @@ -58,9 +65,19 @@ envoy_cc_library(
visibility = ["//visibility:public"],
)

envoy_cc_library(
name = "quic_platform_logging_impl_lib",
srcs = ["quic_logging_impl.cc"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be wrapped in envoy_select_quiche?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, libraries depend on this is using envoy_select_quiche.

hdrs = [
"quic_bug_tracker_impl.h",
"quic_logging_impl.h",
],
visibility = ["//visibility:public"],
deps = ["//source/common/common:assert_lib"],
)

envoy_cc_library(
name = "quic_platform_base_impl_lib",
srcs = envoy_select_quiche(["quic_logging_impl.cc"]),
hdrs = [
"quic_aligned_impl.h",
"quic_arraysize_impl.h",
Expand All @@ -79,6 +96,7 @@ envoy_cc_library(
"quic_string_piece_impl.h",
"quic_uint128_impl.h",
] + envoy_select_quiche([
"quic_expect_bug_impl.h",
"quic_logging_impl.h",
"quic_mock_log_impl.h",
"quic_stack_trace_impl.h",
Expand All @@ -96,6 +114,7 @@ envoy_cc_library(
],
visibility = ["//visibility:public"],
deps = ["@com_googlesource_quiche//:quic_platform_export"] + envoy_select_quiche([
":quic_platform_logging_impl_lib",
"//include/envoy/thread:thread_interface",
"//source/common/common:assert_lib",
"//source/server:backtrace_lib",
Expand All @@ -113,7 +132,6 @@ envoy_cc_library(
"quic_mutex_impl.h",
"quic_str_cat_impl.h",
] + envoy_select_quiche([
"quic_bug_tracker_impl.h",
"quic_hostname_utils_impl.h",
"quic_string_utils_impl.h",
"quic_test_output_impl.h",
Expand Down Expand Up @@ -157,7 +175,11 @@ envoy_cc_library(
"spdy_test_helpers_impl.h",
"spdy_test_utils_prod_impl.h",
"spdy_unsafe_arena_impl.h",
] + envoy_select_quiche(["spdy_string_utils_impl.h"]),
] + envoy_select_quiche([
"spdy_bug_tracker_impl.h",
"spdy_logging_impl.h",
"spdy_string_utils_impl.h",
]),
external_deps = [
"abseil_base",
"abseil_hash",
Expand All @@ -167,6 +189,7 @@ envoy_cc_library(
],
visibility = ["//visibility:public"],
deps = envoy_select_quiche([
":quic_platform_logging_impl_lib",
":string_utils_lib",
"//source/common/common:assert_lib",
]),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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 "extensions/quic_listeners/quiche/platform/quic_bug_tracker_impl.h"

#define HTTP2_BUG_IMPL QUIC_BUG_IMPL
#define HTTP2_BUG_IF_IMPL QUIC_BUG_IF_IMPL
#define FLAGS_http2_always_log_bugs_for_tests_IMPL true
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#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 "extensions/quic_listeners/quiche/platform/quic_logging_impl.h"

#define HTTP2_LOG_IMPL(severity) QUIC_LOG_IMPL(severity)

#define HTTP2_VLOG_IMPL(verbose_level) QUIC_VLOG_IMPL(verbose_level)

#define HTTP2_DLOG_IMPL(severity) QUIC_DLOG_IMPL(severity)

#define HTTP2_DLOG_IF_IMPL(severity, condition) QUIC_DLOG_IF_IMPL(severity, condition)

#define HTTP2_DVLOG_IMPL(verbose_level) QUIC_DVLOG_IMPL(verbose_level)

#define HTTP2_DVLOG_IF_IMPL(verbose_level, condition) QUIC_DVLOG_IF_IMPL(verbose_level, condition)

#define HTTP2_DLOG_EVERY_N_IMPL(severity, n) QUIC_DLOG_EVERY_N_IMPL(severity, n)
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
// consumed or referenced directly by other Envoy code. It serves purely as a
// porting layer for QUICHE.

#include "quiche/quic/platform/api/quic_logging.h"
#include "extensions/quic_listeners/quiche/platform/quic_logging_impl.h"

#define QUIC_BUG_IMPL QUIC_LOG(DFATAL)
#define QUIC_BUG_IF_IMPL(condition) QUIC_LOG_IF(DFATAL, condition)
#define QUIC_PEER_BUG_IMPL QUIC_LOG(ERROR)
#define QUIC_PEER_BUG_IF_IMPL(condition) QUIC_LOG_IF(ERROR, condition)
// TODO(wub): Implement exponential back off to avoid performance problems due
// to excessive QUIC_BUG.
#define QUIC_BUG_IMPL QUIC_LOG_IMPL(DFATAL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preexisted, but doesn't QUIC_BUG work based on the exponential back-off, and could cause serious perf problems if we don't do that?
Should we get a TODO to get around to that work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUIC_BUG has the exponential back off in google3 but not Chromium. It, like other error logs, could cause serious perf problems if it happens too frequently.

TODO added to implement exponential back off in envoy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, per-packet logging server side scales less well than client side :-) thanks for the TODO

#define QUIC_BUG_IF_IMPL(condition) QUIC_LOG_IF_IMPL(DFATAL, condition)
#define QUIC_PEER_BUG_IMPL QUIC_LOG_IMPL(ERROR)
#define QUIC_PEER_BUG_IF_IMPL(condition) QUIC_LOG_IF_IMPL(ERROR, condition)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#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 "extensions/quic_listeners/quiche/platform/quic_logging_impl.h"
#include "extensions/quic_listeners/quiche/platform/quic_mock_log_impl.h"

#define EXPECT_QUIC_BUG_IMPL(statement, regex) \
EXPECT_QUIC_DFATAL_IMPL(statement, testing::ContainsRegex(regex))

#define EXPECT_QUIC_PEER_BUG_IMPL(statement, regex) \
EXPECT_QUIC_LOG_IMPL(statement, ERROR, testing::ContainsRegex(regex))
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace quic {

namespace {
std::atomic<int> g_verbosity_threshold;
std::atomic<bool> g_dfatal_exit_disabled;

// Pointer to the global log sink, usually it is nullptr.
// If not nullptr, as in some tests, the sink will receive a copy of the log message right after the
Expand Down Expand Up @@ -39,7 +40,15 @@ QuicLogEmitter::~QuicLogEmitter() {
}

if (level_ == FATAL) {
#ifdef NDEBUG
// Release mode.
abort();
#else
// Debug mode.
if (!g_dfatal_exit_disabled) {
abort();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine this if block with the #ifdef NDEBUG block above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#endif
}
}

Expand All @@ -49,6 +58,12 @@ void SetVerbosityLogThreshold(int new_verbosity) {
g_verbosity_threshold.store(new_verbosity, std::memory_order_relaxed);
}

bool IsDFatalExitDisabled() { return g_dfatal_exit_disabled.load(std::memory_order_relaxed); }

void SetDFatalExitDisabled(bool is_disabled) {
g_dfatal_exit_disabled.store(is_disabled, std::memory_order_relaxed);
}

QuicLogSink* SetLogSink(QuicLogSink* new_sink) {
absl::MutexLock lock(&g_quic_log_sink_mutex);
QuicLogSink* old_sink = g_quic_log_sink.load(std::memory_order_relaxed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
// TODO(wub): Implement QUIC_LOG_FIRST_N_IMPL.
#define QUIC_LOG_FIRST_N_IMPL(severity, n) QUIC_LOG_IMPL(severity)

// TODO(wub): Implement QUIC_LOG_EVERY_N_IMPL.
#define QUIC_LOG_EVERY_N_IMPL(severity, n) QUIC_LOG_IMPL(severity)

// TODO(wub): Implement QUIC_LOG_EVERY_N_SEC_IMPL.
#define QUIC_LOG_EVERY_N_SEC_IMPL(severity, seconds) QUIC_LOG_IMPL(severity)

Expand All @@ -63,6 +66,7 @@
#define QUIC_DLOG_IMPL(severity) QUIC_COMPILED_OUT_LOG()
#define QUIC_DLOG_IF_IMPL(severity, condition) QUIC_COMPILED_OUT_LOG()
#define QUIC_DLOG_INFO_IS_ON_IMPL() 0
#define QUIC_DLOG_EVERY_N_IMPL(severity, n) QUIC_COMPILED_OUT_LOG()
#define QUIC_NOTREACHED_IMPL()
#else
// Debug build
Expand All @@ -71,6 +75,7 @@
#define QUIC_DLOG_IMPL(severity) QUIC_LOG_IMPL(severity)
#define QUIC_DLOG_IF_IMPL(severity, condition) QUIC_LOG_IF_IMPL(severity, condition)
#define QUIC_DLOG_INFO_IS_ON_IMPL() QUIC_LOG_INFO_IS_ON_IMPL()
#define QUIC_DLOG_EVERY_N_IMPL(severity, n) QUIC_LOG_EVERY_N_IMPL(severity, n)
#define QUIC_NOTREACHED_IMPL() NOT_REACHED_GCOVR_EXCL_LINE
#endif

Expand Down Expand Up @@ -132,6 +137,9 @@ inline bool IsVerboseLogEnabled(int verbosity) {
return IsLogLevelEnabled(INFO) && verbosity <= GetVerbosityLogThreshold();
}

bool IsDFatalExitDisabled();
void SetDFatalExitDisabled(bool is_disabled);

// QuicLogSink is used to capture logs emitted from the QUIC_LOG... macros.
class QuicLogSink {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ class QuicEnvoyMockLog : public QuicLogSink {
bool is_capturing_;
};

// ScopedDisableExitOnDFatal is used to disable exiting the program when we encounter a
// QUIC_LOG(DFATAL) within the current block. After we leave the current block, the previous
// behavior is restored.
class ScopedDisableExitOnDFatal {
public:
ScopedDisableExitOnDFatal() : previous_value_(IsDFatalExitDisabled()) {
SetDFatalExitDisabled(true);
}

ScopedDisableExitOnDFatal(const ScopedDisableExitOnDFatal&) = delete;
ScopedDisableExitOnDFatal& operator=(const ScopedDisableExitOnDFatal&) = delete;

~ScopedDisableExitOnDFatal() { SetDFatalExitDisabled(previous_value_); }

private:
const bool previous_value_;
};

} // namespace quic

using QuicMockLogImpl = quic::QuicEnvoyMockLog;
Expand All @@ -57,3 +75,25 @@ using QuicMockLogImpl = quic::QuicEnvoyMockLog;

#define EXPECT_QUIC_LOG_CALL_CONTAINS_IMPL(log, level, content) \
EXPECT_CALL(log, Log(quic::level, testing::HasSubstr(content)))

// Not part of the api exposed by quic_mock_log.h. This is used by
// quic_expect_bug_impl.h.
#define EXPECT_QUIC_LOG_IMPL(statement, level, matcher) \
do { \
quic::QuicEnvoyMockLog mock_log; \
EXPECT_CALL(mock_log, Log(quic::level, matcher)).Times(testing::AtLeast(1)); \
mock_log.StartCapturingLogs(); \
{ statement; } \
mock_log.StopCapturingLogs(); \
if (!testing::Mock::VerifyAndClear(&mock_log)) { \
GTEST_NONFATAL_FAILURE_(""); \
} \
} while (false)

#define EXPECT_QUIC_DFATAL_IMPL(statement, matcher) \
EXPECT_QUIC_LOG_IMPL( \
{ \
quic::ScopedDisableExitOnDFatal disable_exit_on_dfatal; \
statement; \
}, \
DFATAL, matcher)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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 "extensions/quic_listeners/quiche/platform/quic_bug_tracker_impl.h"

#define SPDY_BUG_IMPL QUIC_BUG_IMPL
#define SPDY_BUG_IF_IMPL QUIC_BUG_IF_IMPL
#define FLAGS_spdy_always_log_bugs_for_tests_impl true
Loading