-
Notifications
You must be signed in to change notification settings - Fork 5.2k
tcp_proxy: added changes to support ppv2 tlvs to be merged when downstream proxy protocol values are present #42824
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
base: main
Are you sure you want to change the base?
Conversation
…tocol values are present Signed-off-by: Prasad I V <[email protected]>
Signed-off-by: Prasad I V <[email protected]>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Prasad I V <[email protected]>
Signed-off-by: Prasad I V <[email protected]>
Signed-off-by: Prasad I V <[email protected]>
| // When set to true and the connection already contains ``PROXY`` protocol state | ||
| // (including TLVs) from a downstream proxy protocol listener filter, the TLVs | ||
| // specified in ``proxy_protocol_tlvs`` are merged with the downstream TLVs. | ||
| // | ||
| // **Precedence behavior**: | ||
| // | ||
| // - TLVs specified in ``proxy_protocol_tlvs`` take precedence over downstream TLVs | ||
| // with the same type. | ||
| // - This allows adding or overriding specific TLV values while preserving | ||
| // other downstream TLVs. | ||
| // - The source/destination addresses from the downstream ``PROXY`` protocol state | ||
| // are preserved (not modified). | ||
| // | ||
| // When set to false (default), the ``proxy_protocol_tlvs`` are ignored if | ||
| // downstream ``PROXY`` protocol state already exists. | ||
| bool merge_proxy_protocol_tlvs = 23; |
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 would suggest calling it merge_with_downstream_tlvs to be more clear and also add more info to the docs.
| // When set to true and the connection already contains ``PROXY`` protocol state | |
| // (including TLVs) from a downstream proxy protocol listener filter, the TLVs | |
| // specified in ``proxy_protocol_tlvs`` are merged with the downstream TLVs. | |
| // | |
| // **Precedence behavior**: | |
| // | |
| // - TLVs specified in ``proxy_protocol_tlvs`` take precedence over downstream TLVs | |
| // with the same type. | |
| // - This allows adding or overriding specific TLV values while preserving | |
| // other downstream TLVs. | |
| // - The source/destination addresses from the downstream ``PROXY`` protocol state | |
| // are preserved (not modified). | |
| // | |
| // When set to false (default), the ``proxy_protocol_tlvs`` are ignored if | |
| // downstream ``PROXY`` protocol state already exists. | |
| bool merge_proxy_protocol_tlvs = 23; | |
| // Controls whether TLVs specified in ``proxy_protocol_tlvs`` are merged with downstream | |
| // ``PROXY`` protocol TLVs when downstream ``PROXY`` protocol state already exists. | |
| // | |
| // When set to ``true`` and the connection already contains ``PROXY`` protocol state | |
| // (including TLVs) from a downstream proxy protocol listener filter, the TLVs | |
| // specified in ``proxy_protocol_tlvs`` are merged with the downstream TLVs. | |
| // | |
| // When set to ``false`` (default), the TLVs specified in ``proxy_protocol_tlvs`` are | |
| // ignored if downstream ``PROXY`` protocol state already exists. In this case, only | |
| // the downstream TLVs are forwarded to the upstream. | |
| // | |
| // **Precedence behavior**: | |
| // | |
| // - TLVs specified in ``proxy_protocol_tlvs`` take precedence over downstream TLVs | |
| // with the same type. This allows adding or overriding specific TLV values while | |
| // preserving other downstream TLVs. | |
| // - The source/destination addresses from the downstream ``PROXY`` protocol state | |
| // are preserved (not modified). | |
| // - TLVs with types that do not conflict are combined, resulting in a merged set | |
| // of TLVs from both sources. | |
| // | |
| // .. note:: | |
| // This field only takes effect when downstream ``PROXY`` protocol state exists. | |
| // If the TCP proxy filter is creating new ``PROXY`` protocol state, this field | |
| // has no effect and the TLVs specified in ``proxy_protocol_tlvs`` are always | |
| // included. | |
| // | |
| // .. note:: | |
| // To ensure the merged TLVs are allowed in the upstream ``PROXY`` protocol header, | |
| // you must also configure passthrough TLVs on the upstream proxy protocol transport. | |
| // See :ref:`core.v3.ProxyProtocolConfig.pass_through_tlvs <envoy_v3_api_field_config.core.v3.ProxyProtocolConfig.pass_through_tlvs>` | |
| // for details. | |
| bool merge_with_downstream_tlvs = 23; |
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.
Makes sense. I've made the changes to rename the field along with the doc suggestions
|
/assign @ggreenway |
…ith_downstream_tlvs Signed-off-by: Prasad I V <[email protected]>
ggreenway
left a comment
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.
/wait
| // you must also configure passthrough TLVs on the upstream proxy protocol transport. | ||
| // See :ref:`core.v3.ProxyProtocolConfig.pass_through_tlvs <envoy_v3_api_field_config.core.v3.ProxyProtocolConfig.pass_through_tlvs>` | ||
| // for details. | ||
| bool merge_with_downstream_tlvs = 23; |
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 think we need to be careful with how we handle merge vs override, when considering #42075. Would it ever make sense to add an additional TLV of the same key? Maybe we should use an enum instead of a bool here so that if different behaviors are needed in the future we can easily add it to the API.
|
|
||
| // Add downstream TLVs that don't conflict with tcp_proxy TLVs. | ||
| for (const auto& tlv : existing_data.tlv_vector_) { | ||
| if (!seen_types.contains(tlv.type)) { |
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 will introduce the bug reported in #42075 to tcp_proxy.
Currently proxy_protocol_tlvs field in tcp_proxy ignores the TLVs specified when downstream has proxy protocol data. This changes adds support to merge the TLVs through an explicit field
merge_proxy_protocol_tlvs. When enabledproxy_protocol_tlvstake precedence over downstream TLVs with the same type.other downstream TLVs.
PROXYprotocol state are preserved.Commit Message: tcp_proxy: added changes to support ppv2 tlvs to be merged when downstream proxy protocol values are present
Additional Description: Currently proxy_protocol_tlvs field in tcp_proxy ignores the TLVs specified when downstream has proxy protocol data. This changes adds support to merge the TLVs through an explicit field
merge_proxy_protocol_tlvs.Risk Level: Low
Testing: Unit tests
Docs Changes: Added
Release Notes: Added
Platform Specific Features: N/A
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]