Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: allowing an optional proxy proto header when terminating CONNECT requests #10975

Merged
merged 3 commits into from
Apr 30, 2020

Conversation

alyssawilk
Copy link
Contributor

Risk Level: low (only affects CONNECT requests)
Testing: new unit tests
Docs Changes: n/a
Release Notes: n/a
Part of #1630 #1451

…T requests

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

@wez470 would you be up for doing a review pass of this one?

@mattklein123 mattklein123 self-assigned this Apr 28, 2020
@wez470
Copy link
Contributor

wez470 commented Apr 28, 2020

Yes, I'll take a look.

.value()
.proxy_protocol_config()
.version();
// FIXME versions.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this FIXME in regards to?

wez470
wez470 previously approved these changes Apr 28, 2020
Copy link
Contributor

@wez470 wez470 left a comment

Choose a reason for hiding this comment

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

LGTM. I like the new header convenience methods!

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #10975 was synchronize by alyssawilk.

see: more, trace.

Copy link
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 with format fix and optional comment, thanks.

/wait

->connectConfig()
.value()
.has_proxy_protocol_config()) {
auto version = upstream_request_->parent()
Copy link
Member

Choose a reason for hiding this comment

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

I suspect we are going to need this elsewhere so it might be worth it to do a utility that takes the config, the connection, and the buffer to fill, but up to you if you want to do this now or not.

EXPECT_CALL(connection_, write(BufferEqual(&expected_data), false));
tcp_upstream_->encodeHeaders(request_, false);

// Data is proxied as usuak.
Copy link
Member

Choose a reason for hiding this comment

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

typo usuak (maybe why format is failing)

@htuch
Copy link
Member

htuch commented Apr 30, 2020

/lgtm api

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
const Network::Connection& connection, Buffer::Instance& out) {
const Network::Address::Ip& dest_address = *connection.localAddress()->ip();
const Network::Address::Ip& source_address = *connection.remoteAddress()->ip();
if (config.version() == envoy::config::core::v3::ProxyProtocolConfig::V1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the utility, which I think is 100% worthwhile especially if folks eventually make use of extensions.

one concern I noticed that I've got source/dest local/remote inverted from what Weston did in
https://github.com/envoyproxy/envoy/pull/10682/files

I think this is right - we're trying to communicate about the downstream connection. the client's destination address is the server's local address, and the client's source address is the remote address as Envoy sees it, but I'd appreciate a sanity check in case I have it backwards.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this looks right to me. We should fix in other places if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup this is correct for downstream connections.

As you noticed, mine defaults to the reversed way for V1 (https://github.com/envoyproxy/envoy/pull/10682/files#diff-a25674ee929a59f2ed07b39eedfff4ccR84). This is because if there's no downstream address info (in health checks, for example), the proxy proto info is just the standard upstream connection info. If there is downstream address info available, it's sets up the src/dst the same as you have here (https://github.com/envoyproxy/envoy/pull/10682/files#diff-a25674ee929a59f2ed07b39eedfff4ccR93)

Copy link
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, thanks!

Comment on lines +549 to +550
Extensions::Common::ProxyProtocol::generateProxyProtoHeader(
connect_config.proxy_protocol_config(), connection, data);
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to action on this in this PR, but I think this means that the proxy proto code is no longer an extension. Can we move it into the core somewhere?

const Network::Connection& connection, Buffer::Instance& out) {
const Network::Address::Ip& dest_address = *connection.localAddress()->ip();
const Network::Address::Ip& source_address = *connection.remoteAddress()->ip();
if (config.version() == envoy::config::core::v3::ProxyProtocolConfig::V1) {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah this looks right to me. We should fix in other places if needed.

@mattklein123 mattklein123 merged commit 8654ea2 into envoyproxy:master Apr 30, 2020
@alyssawilk alyssawilk deleted the proxy_proto branch August 27, 2020 16:33
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