Add (http2|spdy)_string_utils_impl to QUICHE platform implementation.#6198
Add (http2|spdy)_string_utils_impl to QUICHE platform implementation.#6198htuch merged 12 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Bin Wu <wub@google.com>
…g_utils_impl Signed-off-by: Bin Wu <wub@google.com>
assert_lib. Signed-off-by: Bin Wu <wub@google.com>
|
/assign @mpwarres |
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
Why is envoy_select_quiche needed here? My understanding from when it was first introduced was that it was only needed to avoid compiling targets depending on QUICHE under @envoy//test/..., and that for non-test targets, the omission of QUICHE from source/extensions/extensions_build_config.bzl would keep them from being compiled (e.g. see this comment). Did this turn out to not be the case?
There was a problem hiding this comment.
I have used to put everything(hdrs, srcs, deps) that depends on envoy into envoy_select_quiche. Last time I tried, I think ci still fails without it.
There was a problem hiding this comment.
Ok, got it, SG. Separately, I'll look into if there's anything that can be done to reduce that need, but that's orthogonal to this CL. (And I'm finding it affects the flags_impl CL as well.)
There was a problem hiding this comment.
For my education, why is this header file special vs. others in quich/spdy/platform/api etc.?
There was a problem hiding this comment.
This file depends on "string_utils_lib" which depends on envoy's "//source/common/common:assert_lib".
Other files in this library does not depend on envoy.
There was a problem hiding this comment.
I'm not sure how that dependency is reflected in this code though; where is the line that expresses this dependency?
Also, can you fix the bracket style as per previous comments.
There was a problem hiding this comment.
quiche/spdy/platform/api/spdy_string_utils.h includes source/extensions/quic_listeners/quiche/platform/spdy_string_utils_impl.h, which is provided by build rule "spdy_platform_impl_lib", which depends on "string_utils_lib".
Fixed all single element lists in bazel/external/quiche.BUILD and source/extensions/quic_listeners/quiche/platform/BUILD.
|
|
||
| namespace http2 { | ||
|
|
||
| std::string Http2HexDumpImpl(absl::string_view data) { |
There was a problem hiding this comment.
There's code that's identical to this in QuicTextUtilsImpl::HexDump(), and also later on in SpdyHexDumpImpl. How about having a single copy, in (say) some platform/string_utils.cc file, that all platform impls then delegate to?
| return 0; | ||
| } | ||
|
|
||
| bool SpdyHexDecodeToUInt32Impl(absl::string_view data, uint32_t* out) { |
There was a problem hiding this comment.
Can absl::HexStringToBytes() be used here?
…g_utils_impl Signed-off-by: Bin Wu <wub@google.com>
from quic/spdy/http2 platform impls. Signed-off-by: Bin Wu <wub@google.com>
wu-bin
left a comment
There was a problem hiding this comment.
Thanks Mike for the review. I have added a single string_utils_lib and used it from quic/spdy/http2 string apis.
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
I have used to put everything(hdrs, srcs, deps) that depends on envoy into envoy_select_quiche. Last time I tried, I think ci still fails without it.
|
|
||
| namespace http2 { | ||
|
|
||
| std::string Http2HexDumpImpl(absl::string_view data) { |
Signed-off-by: Bin Wu <wub@google.com>
Signed-off-by: Bin Wu <wub@google.com>
mpwarres
left a comment
There was a problem hiding this comment.
LGTM, thanks!
/assign @alyssawilk
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
Ok, got it, SG. Separately, I'll look into if there's anything that can be done to reduce that need, but that's orthogonal to this CL. (And I'm finding it affects the flags_impl CL as well.)
htuch
left a comment
There was a problem hiding this comment.
Looks good, a couple of comments. Thanks
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
For my education, why is this header file special vs. others in quich/spdy/platform/api etc.?
| "//source/common/http:utility_lib", | ||
| ]), | ||
| deps = | ||
| envoy_select_quiche([ |
There was a problem hiding this comment.
Nit: please stick to normal Bazel style and have deps = envoy_select_quiche(... with no line break.
|
|
||
| envoy_cc_library( | ||
| name = "string_utils_lib", | ||
| srcs = [ |
There was a problem hiding this comment.
Nit: single line lists should just be srcs = ["string_utils.c"], for conciseness.
…g_utils_impl Signed-off-by: Bin Wu <wub@google.com>
Signed-off-by: Bin Wu <wub@google.com>
wu-bin
left a comment
There was a problem hiding this comment.
Thanks for the review!
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
This file depends on "string_utils_lib" which depends on envoy's "//source/common/common:assert_lib".
Other files in this library does not depend on envoy.
|
|
||
| envoy_cc_library( | ||
| name = "string_utils_lib", | ||
| srcs = [ |
| "//source/common/http:utility_lib", | ||
| ]), | ||
| deps = | ||
| envoy_select_quiche([ |
output. Use it in quiche::Base64Encode. Signed-off-by: Bin Wu <wub@google.com>
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
I'm not sure how that dependency is reflected in this code though; where is the line that expresses this dependency?
Also, can you fix the bracket style as per previous comments.
| envoy_cc_test( | ||
| name = "http2_platform_test", | ||
| srcs = envoy_select_quiche( | ||
| [ |
There was a problem hiding this comment.
Please merge make the use of brackets match other places in Envoy. Prefer compact style as with google3 C++ and BUILD files.
| Envoy::Base64::encode(reinterpret_cast<const char*>(data), data_len, /*add_padding=*/false); | ||
| } | ||
|
|
||
| std::string HexDump(absl::string_view data) { |
There was a problem hiding this comment.
There was a problem hiding this comment.
They can not be used since they are not hexdump, rather they are equivalent to absl's HexStringToBytes and BytesToHexString functions.
I could move the body of HexDump to common/hex.cc and use it from here, the caveat is that the format of its output must not change, because quiche unit test expects the same output format(example) from all platforms' implementations. Do you prefer to do it that way?
There was a problem hiding this comment.
Are these only test functions? I don't mind adding them if they are only used for this, but should then have some comments or change their name. I think a few things:
- It's helpful to have these kinds of utils, so it would be nice to have them around in Envoy.
- It would ideally have a bunch of tests to ensure they behave as intended
*I'd prefer we did this as much as possible as pure C++, to avoid any of the evil of C string and buffer management.
There was a problem hiding this comment.
Thanks for the offline chat, Harvey. I have
- Changed the visibility of "string_utils_lib" to private.
- Opened Cleanup BUILD visibility for quiche build rules. #6319 to cleanup the visibility of other quiche build rules.
|
|
||
| // Pad with leading zeros. | ||
| std::string data_padded(8u, '0'); | ||
| memcpy(&data_padded[8u - data.size()], data.data(), data.size()); |
There was a problem hiding this comment.
I have a major aversion to any use of memcpy or C string utilities unless absolutely needed. This is scary from a security perspective.
There was a problem hiding this comment.
Changed to string::insert instead.
|
|
||
| // TODO(danzh): Fill out SpdyMemSliceImpl. | ||
| // | ||
| // SpdyMemSliceImpl wraps a reference counted MemSlice and only provides partial |
There was a problem hiding this comment.
Does absl or C++14 give us this? Where is the implementation?
There was a problem hiding this comment.
This is just a header file included by spdy_string_utils.h. I add it to make this PR compile. @danzh2010 is working on the implementation in a separate PR.
Signed-off-by: Bin Wu <wub@google.com>
wu-bin
left a comment
There was a problem hiding this comment.
Thanks Harvey, PTAL.
|
|
||
| // TODO(danzh): Fill out SpdyMemSliceImpl. | ||
| // | ||
| // SpdyMemSliceImpl wraps a reference counted MemSlice and only provides partial |
There was a problem hiding this comment.
This is just a header file included by spdy_string_utils.h. I add it to make this PR compile. @danzh2010 is working on the implementation in a separate PR.
| Envoy::Base64::encode(reinterpret_cast<const char*>(data), data_len, /*add_padding=*/false); | ||
| } | ||
|
|
||
| std::string HexDump(absl::string_view data) { |
There was a problem hiding this comment.
They can not be used since they are not hexdump, rather they are equivalent to absl's HexStringToBytes and BytesToHexString functions.
I could move the body of HexDump to common/hex.cc and use it from here, the caveat is that the format of its output must not change, because quiche unit test expects the same output format(example) from all platforms' implementations. Do you prefer to do it that way?
| # "quiche/spdy/platform/api/spdy_mem_slice.h", | ||
| # "quiche/spdy/platform/api/spdy_string_utils.h", | ||
| ], | ||
| ] + envoy_select_quiche( |
There was a problem hiding this comment.
quiche/spdy/platform/api/spdy_string_utils.h includes source/extensions/quic_listeners/quiche/platform/spdy_string_utils_impl.h, which is provided by build rule "spdy_platform_impl_lib", which depends on "string_utils_lib".
Fixed all single element lists in bazel/external/quiche.BUILD and source/extensions/quic_listeners/quiche/platform/BUILD.
| envoy_cc_test( | ||
| name = "http2_platform_test", | ||
| srcs = envoy_select_quiche( | ||
| [ |
|
|
||
| // Pad with leading zeros. | ||
| std::string data_padded(8u, '0'); | ||
| memcpy(&data_padded[8u - data.size()], data.data(), data.size()); |
There was a problem hiding this comment.
Changed to string::insert instead.
Signed-off-by: Bin Wu <wub@google.com>
|
/retest |
|
🔨 rebuilding |
Description:
Add (http2|spdy)_string_utils_impl to QUICHE platform implementation.
Enabled their existing test in QUICHE.
Risk Level: minimal: code not used yet
Testing:
bazel test test/extensions/quic_listeners/quiche/platform:quic_platform_test --test_output=all --define quiche=enabled --experimental_remap_main_repo
bazel test @com_googlesource_quiche//:spdy_platform_test --test_output=all --define quiche=enabled
bazel test @com_googlesource_quiche//:http2_platform_test --test_output=all --define quiche=enabled
Docs Changes: none
Release Notes: none
[Optional Fixes #Issue]
[Optional Deprecated:]