-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
transport socket: Add proxy proto transport socket. #11584
Conversation
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>
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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>
@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 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>
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
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>
hmm, now ssl integration tests are failing 😕 |
@lizan I'm pretty good with this PR modulo CI failures. Would you take second pass as Greg is out? |
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>
FYI, CI is happy and this should be good to look at again |
There was a problem hiding this 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_; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉. Thanks for the feedback, everyone! |
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>
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>
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>
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