Skip to content

quiche: more platform implementations and enhancement#7283

Merged
mattklein123 merged 20 commits intoenvoyproxy:masterfrom
danzh2010:cryptoconfig
Jun 19, 2019
Merged

quiche: more platform implementations and enhancement#7283
mattklein123 merged 20 commits intoenvoyproxy:masterfrom
danzh2010:cryptoconfig

Conversation

@danzh2010
Copy link
Copy Markdown
Contributor

@danzh2010 danzh2010 commented Jun 14, 2019

Roll up quiche tar ball to 88e3e05c341147f4052e17a2769ac2722739c498.
Add more platform implementations: quic_optional_impl, quic_macros_impl, quic_error_code_wrappers_imp.

Enhance quic_client_stats_impl and quic_mem_slice_span_impl with more functionalities or make them more robust.

Add an overload function of std::operator<< to streaming out a std::vector.

Risk Level: low, not in use
Testing: Added tests for newly added impl's and functionality.
Part of #2557

danzh1989 added 11 commits June 6, 2019 16:16
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

/assign @wu-bin @mattklein123

@danzh2010 danzh2010 changed the title Cryptoconfig quiche: more platform implementations and enhancement Jun 14, 2019
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: asan (failed build)

🐱

Caused by: a #7283 (comment) was created by @danzh2010.

see: more, trace.


envoy_cc_library(
name = "quic_core_alarm_lib",
name = "quic_core_alarm_interface",
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.

Why rename these quic core libraries? We've discussed this before and agreed to mirror the internal libraries names.

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.

This is envoy convention. For interface libraries, use suffix _interface instead of _lib. This is clearer than internal libraries names.

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.

This is a quic core library, the code does not use envoy convention, the build rule also doesn't have to. (recall that we want to export the build rules in quiche and use it from envoy some day)

That said, in this case we can use envoy convention and the same name at the same time, just rename the internal library to _interface.

)

envoy_cc_library(
name = "quic_platform_logging",
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.

Why put logging into a separate library? As we discussed before, we should avoid adding standalone platform libraries unless necessary.

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.

I put it outside of quic_platform_base so that quic_socket_address.h can be placed in quic_platform_base. So other core libraries don't have to explicitly depend on quic_platform_socket_address. Becaue quic_platform_ip_address depends on it, and quic_socket_address depends on quic_platform_ip_address.

But considering that quic_socket_address will be moved to core eventually, I think it makes much more sends to make these 2 network address libraries stand-alone and keep logging as part of quic_platform_base.

)

envoy_cc_library(
name = "quic_platform_ip_address",
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.

It's ok to keep this as a standalone library because it will be moved to quic core soon.

QuicLogSink* SetLogSink(QuicLogSink* new_sink);

// Overload std::operator<< to output a vector.
template <class T> std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
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.

This function is not specific to QUIC, can you move it to a better place?

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.

Only quic use this type of logging right? Envoy has it's only logging macros.

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.

It doesn't need to be used by the QUIC_LOG macros. It can also be used in unit tests to pretty-print the content of a vector, similar to

std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p) {

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.

I'm not sure where is the best place for such overload. This seems very much like an overload only for tests, but we definitely don't want to place it under /test.

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.

source/common/common/stl_helpers.h sounds like a fine place for this.

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

template <class T> std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
out << "vector { ";
size_t i = 0;
for (; i < v.size() - 1; ++i) {
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.

I think line 186-193 can be replaced by absl::StrJoin(v, ", ", absl::StreamFormatter()).

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.

Good point. Done


TEST_F(QuicPlatformTest, QuicLogVector) {
std::vector<int32_t> v = {1, 2, 3, 4, 5};
EXPECT_LOG_CONTAINS("info", "vector { 1, 2, 3, 4, 5 }", QUIC_LOG(INFO) << v);
Copy link
Copy Markdown
Contributor

@wu-bin wu-bin Jun 17, 2019

Choose a reason for hiding this comment

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

Does it work? IIRC, the default log level is ERROR, and INFO will not be logged unless you do GetLogger().set_level(INFO)

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 shouldn't. But it did pass. It seems to be a bug in quic logging implementation. Anyway, the purpose of this test is testing operator<< overload, not logging level. I changed it to output at error instead.

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.

It works because the macro forcefully set the log level to "trace".

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

@danzh2010 danzh2010 closed this Jun 17, 2019
@repokitteh-read-only
Copy link
Copy Markdown

🐴 hold your horses - no failures detected, yet.

🐱

Caused by: a #7283 (comment) was created by @danzh2010.

see: more, trace.

@danzh2010 danzh2010 reopened this Jun 17, 2019
@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🐴 hold your horses - no failures detected, yet.

🐱

Caused by: a #7283 (comment) was created by @danzh2010.

see: more, trace.

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #7283 (comment) was created by @danzh2010.

see: more, trace.

@mattklein123
Copy link
Copy Markdown
Member

Please merge master to fix CI.

/wait

@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #7283 (comment) was created by @danzh2010.

see: more, trace.

Signed-off-by: Dan Zhang <danzh@google.com>

// NOLINT(namespace-envoy)
// Overload functions in std library.
namespace std {
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 we put it into the global namespace? I think it can be used everywhere that way.

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.

in std namespace can also be used everywhere, at least in Envoy and quic namespaces as tested.
Similar overloads are all in std namespace in envoy. I just follow the convention.

@@ -10,7 +10,7 @@

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.

Since QuicSocketAddress has been de-platformized, can we delete this file now?

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.

QuicSocketAddress has not been de-platformized in this tar ball yet. I still has problem to roll the tar ball upto where it is de-platformized, waiting for upstream fix to be merged into quiche. But quic_ip_address_impl.h should.

Signed-off-by: Dan Zhang <danzh@google.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM @wu-bin any further comments?

@mattklein123 mattklein123 merged commit 280c722 into envoyproxy:master Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants