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

transport socket: Add proxy proto transport socket. #11584

Merged
merged 36 commits into from
Jul 28, 2020
Merged

transport socket: Add proxy proto transport socket. #11584

merged 36 commits into from
Jul 28, 2020

Conversation

wez470
Copy link
Contributor

@wez470 wez470 commented Jun 14, 2020

Signed-off-by: Weston Carlson wez470@gmail.com

Commit Message: Add proxy proto transport socket

Additional Description: This is the part 1 PR described in #10682. It adds the transports socket / unit tests, a transport socket options struct for the proxy proto header, and does a refactor to make the listener filter use the common proxy proto constants (potentially want to move these now since the proxy proto config api type is not in extensions?)

Risk Level: Small
Testing: Unit
Docs Changes: None
Release Notes: None
Part Of: #1031

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
@wez470
Copy link
Contributor Author

wez470 commented Jun 15, 2020

Posting question I had in slack here. https://envoyproxy.slack.com/archives/C78HA81DH/p1592235285286200. Essentially wondering if there's a way for me to get docs passing with the current state or if I need to add the API / config factories, etc all in this PR.

envoy_package()

envoy_cc_extension(
name = "proxy_protocol",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be named upstream_proxy_protocol or similar, so it is clear that it is only for use in an upstream context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, very good suggestion


Network::IoResult ProxyProtocolSocket::doWrite(Buffer::Instance& buffer, bool end_stream) {
if (!generated_header_) {
generateHeader();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be done in the constructor or onConnected() or somewhere earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved to onConnected for now. Do you know if that method gets called after setTransportSocketCallbacks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, could probably just move the generation to setTransportSocketCallbacks

namespace Envoy {
namespace Network {

struct ProxyProtocolHeader {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename ProxyProtocolOptions? When I think of header, I think of something in wire-format.

* @returns TransportSocketOptionsSharedPtr a shared pointer to the transport socket options,
* nullptr if nothing is in the filter state or no PROXY protocol info is supplied.
*/
static TransportSocketOptionsSharedPtr fromFilterStateWithProxyProtocolHeader(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this function needed? Couldn't the proxy protocol data be part of the FilterState?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely can just add the proxy proto data to the FilterState.

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
@wez470
Copy link
Contributor Author

wez470 commented Jun 18, 2020

@cpakulski looked into the docs stuff a bit for me (thanks!). Essentially it seems like having an API is assumed. i.e. needing a proto with // [#extension: envoy.transport_sockets.upstream_proxy_protocol]. The generated security posture docs link to it.

Seems like I'm going to have to add the API, docs, TCP Proxy changes, e2e tests, etc all to this branch and just have one big PR. Not sure what the best course of action is. Maybe close this for now while I add all that stuff? It's definitely going to take me more than a few days to add it all.

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Very cool to see this going out (and thank you for the manageable chunks! =P)
First pass thoughts below!

namespace Envoy {
namespace Network {

struct ProxyProtocolOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

optional rename, maybe ProxyProtocolData ?

namespace TransportSockets {
namespace ProxyProtocol {

class ProxyProtocolSocket : public Network::TransportSocket,
Copy link
Contributor

Choose a reason for hiding this comment

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

totally optional, but what do you think of a base class that's a pure wrapper, and subclassing that to make it clear what's being overridden and what's passthrough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, seems like a good idea. Could potentially be used for the tap socket as well. I'll look into it.

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
@repokitteh-read-only
Copy link

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

🐱

Caused by: #11584 was synchronize by wez470.

see: more, trace.

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
@wez470
Copy link
Contributor Author

wez470 commented Jul 13, 2020

hmm, now ssl integration tests are failing 😕

@alyssawilk
Copy link
Contributor

@lizan I'm pretty good with this PR modulo CI failures. Would you take second pass as Greg is out?

wez470 and others added 6 commits July 18, 2020 13:33
Co-authored-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
@wez470
Copy link
Contributor Author

wez470 commented Jul 21, 2020

FYI, CI is happy and this should be good to look at again

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Can we add integration tests?

namespace Network {

struct ProxyProtocolData {
const Network::Address::InstanceConstSharedPtr& src_addr_;
Copy link
Member

Choose a reason for hiding this comment

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

This has a high chance to be dangling reference when it is passed around. I'm not sure why our tests didn't catch, do we have integration test for the whole setup?

Copy link
Contributor Author

@wez470 wez470 Jul 21, 2020

Choose a reason for hiding this comment

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

No full setup integration tests at this point. The API (marked as unimplemented) / config factory / TCP Proxy / Doc / etc changes aren't in this PR to try and reduce scope. Those changes + more unit / integration tests would come in a follow up PR. Do you want to change this data type now or in the future PR? This won't be used at all right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could also add a TODO to check / fix this for now?

Copy link
Member

Choose a reason for hiding this comment

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

At least make this non-reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I can do that 👍

Signed-off-by: Weston Carlson <wez470@gmail.com>
Signed-off-by: Weston Carlson <wez470@gmail.com>
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

@alyssawilk alyssawilk dismissed ggreenway’s stale review July 28, 2020 13:46

I think issues are resolved

@alyssawilk alyssawilk merged commit 8972b47 into envoyproxy:master Jul 28, 2020
@wez470
Copy link
Contributor Author

wez470 commented Jul 28, 2020

🎉. Thanks for the feedback, everyone!

KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
Commit Message: Add proxy proto transport socket

Additional Description: This is the part 1 PR described in envoyproxy#10682. It adds the transports socket / unit tests, a transport socket options struct for the proxy proto header, and does a refactor to make the listener filter use the common proxy proto constants (potentially want to move these now since the proxy proto config api type is not in extensions?)

Risk Level: Small
Testing: Unit
Docs Changes: None
Release Notes: None
Part Of: #1031

Signed-off-by: Weston Carlson <wez470@gmail.com>
Co-authored-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
Commit Message: Add proxy proto transport socket

Additional Description: This is the part 1 PR described in envoyproxy#10682. It adds the transports socket / unit tests, a transport socket options struct for the proxy proto header, and does a refactor to make the listener filter use the common proxy proto constants (potentially want to move these now since the proxy proto config api type is not in extensions?)

Risk Level: Small
Testing: Unit
Docs Changes: None
Release Notes: None
Part Of: envoyproxy#1031

Signed-off-by: Weston Carlson <wez470@gmail.com>
Co-authored-by: Lizan Zhou <lizan@tetrate.io>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
Commit Message: Add proxy proto transport socket

Additional Description: This is the part 1 PR described in envoyproxy#10682. It adds the transports socket / unit tests, a transport socket options struct for the proxy proto header, and does a refactor to make the listener filter use the common proxy proto constants (potentially want to move these now since the proxy proto config api type is not in extensions?)

Risk Level: Small
Testing: Unit
Docs Changes: None
Release Notes: None
Part Of: envoyproxy#1031

Signed-off-by: Weston Carlson <wez470@gmail.com>
Co-authored-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: chaoqinli <chaoqinli@google.com>
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.

5 participants