-
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
stream info: cleanup address handling #14432
Conversation
Consolidate all downstream address handling setting into a single function. Also remove duplicate setting in the connection handler. This should make this logic less error prone than it was previously. Fixes #14133 Signed-off-by: Matt Klein <[email protected]>
/retest |
Retrying Azure Pipelines: |
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 really like the approach. This cleans things up quite a bit.
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
3f6e50f
to
e157108
Compare
@ggreenway I pushed a partial change which implements a variant of your suggestion which is to fundamentally fix the problem by having an address provider that we pass around via shared_ptr so it's not possible for anything to get out of date. I like this solution, but it's a lot of work so I don't want to spend more time on fixing all the tests and various pieces of code unless you agree with the direction. Also, there is a small downside of an extra shared_ptr allocation per connection, and there will be another one on top of that for HTTP connections that change remote address due to XFF (to have a provider that wraps the original). IMO this is worth it given the severity of possible bugs in this area, but let me know what you think! |
I like that the connection and streaminfo addresses are combined. I'm not sure I like that the http streaminfo and connection streaminfo sometimes share an address. If XFF has a different address than the connection remoteAddress, the http streaminfo will need to replace it's addressprovider. Given that the http and connection addresses aren't necessarily the same, I think it may make sense for the http streaminfo to get a one-time copy of the addresses in the connection streaminfo when it is constructed, and from there are be separate/uncoupled. |
We discussed ^ offline and my plan is to make a special version of StreamInfo, OverridableAddressStrreamInfo, or whatever, that implements SocketAddressProvider and also has a setDownstreamAddress function. Then, the overriding will happen in that stream info and pass through otherwise. I think it will be pretty clean. It can be self contained to the HCM code. |
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
@ggreenway I need to take another pass over this but I think this should be ready for review. Sorry for the size of the change but I think it's the right thing to do. It should mostly be a mechanical review. |
@ggreenway I went over the change again and I'm happy with it. I don't think tidy is doing to pass given the size of the change. No rush on reviewing. |
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 looks great overall! A couple minor nits, but the approach looks good, and this cleaned up the source of bugs.
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
@ggreenway updated PTAL |
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.
LGTM.
This will give your github stats a nice boost.
Signed-off-by: Matt Klein <[email protected]>
Signed-off-by: Matt Klein <[email protected]>
@ggreenway I had to fix a merge conflict so I will need another review. cc @KBaichoo see last commit. |
* master: (48 commits) Resolve 14506, avoid libidn2 for our curl dependency (envoyproxy#14601) fix new/free mismatch in Mainthread utility (envoyproxy#14596) opencensus: deprecate Zipkin configuration. (envoyproxy#14576) upstream: clean up code location (envoyproxy#14580) configuration impl: add cast for ios compilation (envoyproxy#14590) buffer impl: add cast for android compilation (envoyproxy#14589) ratelimit: add dynamic metadata to ratelimit response (envoyproxy#14508) tcp_proxy: wait for CONNECT response before start streaming data (envoyproxy#14317) stream info: cleanup address handling (envoyproxy#14432) [deps] update upb to latest commit (envoyproxy#14582) Add utility to check whether the execution is in main thread. (envoyproxy#14457) listener: undeprecate bind_to_port (envoyproxy#14480) Fix data race in overload integration test (envoyproxy#14586) deps: update PGV (envoyproxy#14571) dependencies: update cve_scan.py for some libcurl 7.74.0 false positives. (envoyproxy#14572) Network::Connection: Add L4 crash dumping support (envoyproxy#14509) ssl: remember stat names for configured ciphers. (envoyproxy#14534) formatter: add custom date formatting to downstream cert start and end dates (envoyproxy#14502) feat(lua): allow setting response body when the upstream response body is empty (envoyproxy#14486) Generalize the gRPC access logger base classes (envoyproxy#14469) ... Signed-off-by: Michael Puncel <[email protected]>
@mattklein123 so |
Ok, so circling back. Our options are:
I really wanted to avoid 3), given the work that's gone into cleaning up StreamInfo but after some thought I think I'd prefer to send a PR to get that going. 1) is the most correct approach, but I don't have the immediate cycles for that. 2) is easier but requires some juggling in terms of rollout so the time doing that is probably better spent doing 1). So how about:
Thoughts? |
This allows us to do a dynamic_cast<Http::OverridableRemoteSocketAddressSetterStreamInfo> and be able to call setDownstreamRemoteAddress() from our filter. See: envoyproxy#14432 (comment) Signed-off-by: Raul Gutierrez Segales <[email protected]>
Ok with #14633 we can do this from our filter:
I am not massively proud, but it probably works. |
Yeah per offline convo I think that is your best bet until we get something better implemented for you. |
This is a follow-up to: envoyproxy#14432 (comment) After that PR, it's no longer possible (unless you do a dynamic_cast) to set the remote address from a filter. This is something that we need to do because we have specialized logic for this (XFF doesn't work for us). So this adds an extension point which will allow us to push that logic down to ConnectionManagerUtility::mutateRequestHeaders() where it belongs. Signed-off-by: Raul Gutierrez Segales <[email protected]>
This is a follow-up to: #14432 (comment) After that PR, it's no longer possible (unless you do a dynamic_cast) to set the remote address from a filter. This is something that we need to do because we have specialized logic for this (XFF doesn't work for us). So this adds an extension point which will allow us to push that logic down to ConnectionManagerUtility::mutateRequestHeaders() where it belongs. Signed-off-by: Raul Gutierrez Segales <[email protected]>
This is a follow-up to: envoyproxy#14432 (comment) After that PR, it's no longer possible (unless you do a dynamic_cast) to set the remote address from a filter. This is something that we need to do because we have specialized logic for this (XFF doesn't work for us). So this adds an extension point which will allow us to push that logic down to ConnectionManagerUtility::mutateRequestHeaders() where it belongs. Signed-off-by: Raul Gutierrez Segales <[email protected]> Signed-off-by: Sixiang Gu <[email protected]>
Consolidate all downstream address handling setting into a single
function. Also remove duplicate setting in the connection handler.
This should make this logic less error prone than it was previously.
Fixes #14133
Risk Level: Low
Testing: Existing tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A