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

Add filter state receive_before_connect to tcp_proxy #36581

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

akshita31
Copy link

Commit Message:
This PR picks up the work done in #25804.

  1. It adds a receive_before_connect filter state which can be read by TCP_PROXY and if set TCP_PROXY will not disable downstream reads until the upstream connection is established. This can hence be used by filters before TCP_PROXY to set the filter state in initializeReadFilterCallbacks, and then StopIteration in onNewConnection and onData, until they have read the required amount of data before upstream connection establishment.
  2. Based on feedback in tcp_proxy: Add filter state envoy.tcp_proxy.receive_before_connect #25804 , this PR adds a flow control to prevent early_data_buffer from overflowing, by disabling downstream reads on early data until the upstream connection establishment is finished.
  3. Adds integration and unit tests to cover the newly added functionality.

Additional Description:
Risk Level: Low
Testing: Added integration and unit tests
Docs Changes: Done
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

jrajahalme and others added 4 commits October 14, 2024 11:29
Add filter state object bool proxy_receive_before_connect that tcp_proxy
filter checks for and when set to 'true' will not set readDisable on the
downstream connection before upstream connection is established.

This change allows advanced cases where a network read filter needs to
receive (and possibly send) downstream data that may change the
destination of the upstream TCP connection, e.g. via metadata set based
on the received data. If this is the case, then the read filter preceding
the tcp_proxy filter must return StopIteration from its onNewConnection()
call, causing tcp_proxy filter to postpone its upstream connection
establishment until onData() returns Continue.

Any data reaching the tcp_proxy filter before the upstream connection is
established is buffered so that the downstream filters do not see the
same data again which would be the case if it would remaining in the buffer
and more data is received. This also allows downstream filters inject
data before the upstream connection is established; such injected data
would be lost if tcp_proxy would not buffer it while connection
establishment is still ongoing.

An existing dynamic metadata integration test is modified to use
proxy_receive_before_connect=true. This makes the use case less
reliant on the tcp_proxy internal detail, such as balancing and timing of
the readDisable() calls on the downstream connection.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Akshita Agarwal <akshita.agarwal@airbnb.com>
Copy link

Hi @akshita31, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #36581 was opened by akshita31.

see: more, trace.

Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #36581 was opened by akshita31.

see: more, trace.

@akshita31 akshita31 force-pushed the akshita-tcp-proxy branch 4 times, most recently from 8cde6be to 5f83a94 Compare October 14, 2024 20:16
Signed-off-by: Akshita Agarwal <akshita.agarwal@airbnb.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.

2 participants