Skip to content

filter state: add hashable string factory - #43208

Merged
kyessenov merged 2 commits into
envoyproxy:mainfrom
kyessenov:hashing_string
Feb 2, 2026
Merged

kyessenov merged 2 commits into
envoyproxy:mainfrom
kyessenov:hashing_string

Conversation

@kyessenov

Copy link
Copy Markdown
Contributor

Change-Id: Ide0862550ebd67fc0de034daaac42be8f0fd6688

Commit Message: add a hashable string that can influence HTTP connection pool when shared with upstream.
Additional Description:
Risk Level: low
Testing: yes
Docs Changes: yes
Release Notes: no

Change-Id: Ide0862550ebd67fc0de034daaac42be8f0fd6688
Signed-off-by: Kuat Yessenov <[email protected]>

@agrawroh agrawroh left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! I remember that I followed your suggestion long back when we saw an issue with filter-state mixup in TCPProxy and had an internal patch (which I also tried upstreaming before) with almost the same implementation running internally.

It's awesome that we are adding this now as I was too scared to switch back to envoy.string after that outage and have the custom patch running all this time.

@kyessenov

Copy link
Copy Markdown
Contributor Author

@agrawroh Yeah, I know it's a tricky configuration. Let me know how else I can improve it. I am worried that people are blindly copy-pasting configs from LLM without thinking about it, and this is quite subtle.

@agrawroh

Copy link
Copy Markdown
Member

@agrawroh Yeah, I know it's a tricky configuration. Let me know how else I can improve it. I am worried that people are blindly copy-pasting configs from LLM without thinking about it, and this is quite subtle.

It looks good to me. Maybe just a warning or note in the docs on the performance penalty as compared to envoy.string would be good.

agrawroh
agrawroh previously approved these changes Jan 30, 2026
Change-Id: I4f1ddd88d55001ab2eb887db32ec1d13c5a182e5
Signed-off-by: Kuat Yessenov <[email protected]>

@agrawroh agrawroh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Thanks @kyessenov.

@kyessenov
kyessenov merged commit 3574957 into envoyproxy:main Feb 2, 2026
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
Change-Id: Ide0862550ebd67fc0de034daaac42be8f0fd6688

Commit Message: add a hashable string that can influence HTTP connection
pool when shared with upstream.
Additional Description:
Risk Level: low
Testing: yes
Docs Changes: yes
Release Notes: no

---------

Signed-off-by: Kuat Yessenov <[email protected]>
@krinkinmu

Copy link
Copy Markdown
Contributor

@kyessenov @agrawroh @phlax by any chance, would it be ok if I backported this to Envoy's 1.37 release branch?

I fully realize that this is not a security or bug fix, but a new feature and therefore, as a matter of general policy, it wouldn't be wise to backport it to stable release branch. That being said, the reason I'm asking is that backporting this to 1.37 would help to fix a bug in an Istio release more easily.

It's totally fine if we don't want to do that - I will look for other options, but wanted to check explicitly before I go for altenrative ways.

@kyessenov

Copy link
Copy Markdown
Contributor Author

@krinknmu I don't think it's right to back-port features in the mainline project. It sets a bad precedent and it makes any future (potential) fixes for the extension become complicated for all distributors. Why don't you backport in Istio OSS repo or your vendor fork?

@krinkinmu

krinkinmu commented Mar 16, 2026 via email

Copy link
Copy Markdown
Contributor

krinkinmu added a commit to krinkinmu/proxy that referenced this pull request Mar 16, 2026
This is part of the fix for istio/istio#58630
and you can find some additional context in that ticket (the other part
will be to the pilot, and we'd also like to backport this change to 1.29
release branch as well).

To understand why this change is needed we have to start with some
background.

In ambient multicluster, specifically in multi-network deployments, we
rely on ambient E/W gateway to transfer data from one network to
another.

When communicating across network boundaries in ambient we use
double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the
outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the
destination.

Envoy configuration of ambient E/W gateway has two listeners important
for understanding this change - `connect_terminate` and `main_internal`.
`connect_terminate` listener is responsible for terminating outer HBONE
tunnel, extracting and preserving all the relevant routing information
(e.g. authority from HTTP CONNECT request and some headers).

However, `connect_terminate` does not make any routing decisions,
instead it passes all the relevant information to the internal
`main_internal` listener via filter state, and then `main_internal`
listener is actually responsible for routing the request correctly.

To transfer data to `main_internal` listener, `connect_terminate`
listener opens an "internal" connection - it's a connection implemented
purely in Envoy, but it implements the same interface as any other
connections that Envoy supports and for many intents and purposes is not
that different from say TCP connections.

One thing that is particularly important for this PR is that Envoy does
connection pooling for internal connections like it does for any other
connections. Connections from the same pool assumed to share the same
filter state (via transport socket options) with the upstream internal
listener (e.g., `main_internal` listener in our case).

So if you have two HTTP2 streams with different authority in the HBONE
connect requests, only authority from the stream handled first will be
communicated to the upstream internal listener - that's not what we
want.

Envoy in principle recognizes that filter state may affect some routing
decisions, so for some types of filter state objects shared with
upstream Envoy can tell that it should use different connection pools
to avoid mixing unrelated requests together, however `envoy.string` type
we currently use to communicate authority from the HBONE CONNECT requests
is not one of such types.

Recently, Envoy introduced `envoy.hashable_string` that does what we
need (see envoyproxy/envoy#43208), but this
change didn't make it to Envoy 1.37 release branch and it will not be
backported.

NOTE: I checked other existing filter state object types, and they don't
suit us either, so upstream Envoy `envoy.hashable_string` is basically
the first and the only one that works for us.

NOTE: From Envoy point of view that change is not a bug or security fix,
so the fact that it should not be backported makes perfect sense, but
just in case I also explicitly asked in that PR if we could backport it
and got an explicit response that it's quite undesirable.

So this PR introduces `istio.hashable_string` which does exactly the
same thing that upstream `envoy.hashable_string` does, however we can
backport it to the Istio's 1.29 release branch without relying on
upstream Envoy. Eventually, we can phase it out in favor of the upstream
Envoy `envoy.hashable_string`.

With the current Istio release cadence, according to
https://istio.io/latest/docs/releases/supported-releases/, we should be
able to phase it out completely in about 2 quarters and 6 weeks.
Together with the fact that the extensions is quite small, I think that
it's manageable to add it to the Istio proxy repor, even if it's not
ideal.

Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing pushed a commit to istio/proxy that referenced this pull request Mar 16, 2026
This is part of the fix for istio/istio#58630
and you can find some additional context in that ticket (the other part
will be to the pilot, and we'd also like to backport this change to 1.29
release branch as well).

To understand why this change is needed we have to start with some
background.

In ambient multicluster, specifically in multi-network deployments, we
rely on ambient E/W gateway to transfer data from one network to
another.

When communicating across network boundaries in ambient we use
double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the
outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the
destination.

Envoy configuration of ambient E/W gateway has two listeners important
for understanding this change - `connect_terminate` and `main_internal`.
`connect_terminate` listener is responsible for terminating outer HBONE
tunnel, extracting and preserving all the relevant routing information
(e.g. authority from HTTP CONNECT request and some headers).

However, `connect_terminate` does not make any routing decisions,
instead it passes all the relevant information to the internal
`main_internal` listener via filter state, and then `main_internal`
listener is actually responsible for routing the request correctly.

To transfer data to `main_internal` listener, `connect_terminate`
listener opens an "internal" connection - it's a connection implemented
purely in Envoy, but it implements the same interface as any other
connections that Envoy supports and for many intents and purposes is not
that different from say TCP connections.

One thing that is particularly important for this PR is that Envoy does
connection pooling for internal connections like it does for any other
connections. Connections from the same pool assumed to share the same
filter state (via transport socket options) with the upstream internal
listener (e.g., `main_internal` listener in our case).

So if you have two HTTP2 streams with different authority in the HBONE
connect requests, only authority from the stream handled first will be
communicated to the upstream internal listener - that's not what we
want.

Envoy in principle recognizes that filter state may affect some routing
decisions, so for some types of filter state objects shared with
upstream Envoy can tell that it should use different connection pools
to avoid mixing unrelated requests together, however `envoy.string` type
we currently use to communicate authority from the HBONE CONNECT requests
is not one of such types.

Recently, Envoy introduced `envoy.hashable_string` that does what we
need (see envoyproxy/envoy#43208), but this
change didn't make it to Envoy 1.37 release branch and it will not be
backported.

NOTE: I checked other existing filter state object types, and they don't
suit us either, so upstream Envoy `envoy.hashable_string` is basically
the first and the only one that works for us.

NOTE: From Envoy point of view that change is not a bug or security fix,
so the fact that it should not be backported makes perfect sense, but
just in case I also explicitly asked in that PR if we could backport it
and got an explicit response that it's quite undesirable.

So this PR introduces `istio.hashable_string` which does exactly the
same thing that upstream `envoy.hashable_string` does, however we can
backport it to the Istio's 1.29 release branch without relying on
upstream Envoy. Eventually, we can phase it out in favor of the upstream
Envoy `envoy.hashable_string`.

With the current Istio release cadence, according to
https://istio.io/latest/docs/releases/supported-releases/, we should be
able to phase it out completely in about 2 quarters and 6 weeks.
Together with the fact that the extensions is quite small, I think that
it's manageable to add it to the Istio proxy repor, even if it's not
ideal.

Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing pushed a commit to istio-testing/proxy that referenced this pull request Mar 16, 2026
This is part of the fix for istio/istio#58630
and you can find some additional context in that ticket (the other part
will be to the pilot, and we'd also like to backport this change to 1.29
release branch as well).

To understand why this change is needed we have to start with some
background.

In ambient multicluster, specifically in multi-network deployments, we
rely on ambient E/W gateway to transfer data from one network to
another.

When communicating across network boundaries in ambient we use
double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the
outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the
destination.

Envoy configuration of ambient E/W gateway has two listeners important
for understanding this change - `connect_terminate` and `main_internal`.
`connect_terminate` listener is responsible for terminating outer HBONE
tunnel, extracting and preserving all the relevant routing information
(e.g. authority from HTTP CONNECT request and some headers).

However, `connect_terminate` does not make any routing decisions,
instead it passes all the relevant information to the internal
`main_internal` listener via filter state, and then `main_internal`
listener is actually responsible for routing the request correctly.

To transfer data to `main_internal` listener, `connect_terminate`
listener opens an "internal" connection - it's a connection implemented
purely in Envoy, but it implements the same interface as any other
connections that Envoy supports and for many intents and purposes is not
that different from say TCP connections.

One thing that is particularly important for this PR is that Envoy does
connection pooling for internal connections like it does for any other
connections. Connections from the same pool assumed to share the same
filter state (via transport socket options) with the upstream internal
listener (e.g., `main_internal` listener in our case).

So if you have two HTTP2 streams with different authority in the HBONE
connect requests, only authority from the stream handled first will be
communicated to the upstream internal listener - that's not what we
want.

Envoy in principle recognizes that filter state may affect some routing
decisions, so for some types of filter state objects shared with
upstream Envoy can tell that it should use different connection pools
to avoid mixing unrelated requests together, however `envoy.string` type
we currently use to communicate authority from the HBONE CONNECT requests
is not one of such types.

Recently, Envoy introduced `envoy.hashable_string` that does what we
need (see envoyproxy/envoy#43208), but this
change didn't make it to Envoy 1.37 release branch and it will not be
backported.

NOTE: I checked other existing filter state object types, and they don't
suit us either, so upstream Envoy `envoy.hashable_string` is basically
the first and the only one that works for us.

NOTE: From Envoy point of view that change is not a bug or security fix,
so the fact that it should not be backported makes perfect sense, but
just in case I also explicitly asked in that PR if we could backport it
and got an explicit response that it's quite undesirable.

So this PR introduces `istio.hashable_string` which does exactly the
same thing that upstream `envoy.hashable_string` does, however we can
backport it to the Istio's 1.29 release branch without relying on
upstream Envoy. Eventually, we can phase it out in favor of the upstream
Envoy `envoy.hashable_string`.

With the current Istio release cadence, according to
https://istio.io/latest/docs/releases/supported-releases/, we should be
able to phase it out completely in about 2 quarters and 6 weeks.
Together with the fact that the extensions is quite small, I think that
it's manageable to add it to the Istio proxy repor, even if it's not
ideal.

Signed-off-by: Mikhail Krinkin <[email protected]>
istio-testing added a commit to istio/proxy that referenced this pull request Mar 17, 2026
This is part of the fix for istio/istio#58630
and you can find some additional context in that ticket (the other part
will be to the pilot, and we'd also like to backport this change to 1.29
release branch as well).

To understand why this change is needed we have to start with some
background.

In ambient multicluster, specifically in multi-network deployments, we
rely on ambient E/W gateway to transfer data from one network to
another.

When communicating across network boundaries in ambient we use
double-HBONE (HBONE inside another HBONE). The E/W gateway terminate the
outer HBONE tunnel and transfers the inner HBONE tunnel untouched to the
destination.

Envoy configuration of ambient E/W gateway has two listeners important
for understanding this change - `connect_terminate` and `main_internal`.
`connect_terminate` listener is responsible for terminating outer HBONE
tunnel, extracting and preserving all the relevant routing information
(e.g. authority from HTTP CONNECT request and some headers).

However, `connect_terminate` does not make any routing decisions,
instead it passes all the relevant information to the internal
`main_internal` listener via filter state, and then `main_internal`
listener is actually responsible for routing the request correctly.

To transfer data to `main_internal` listener, `connect_terminate`
listener opens an "internal" connection - it's a connection implemented
purely in Envoy, but it implements the same interface as any other
connections that Envoy supports and for many intents and purposes is not
that different from say TCP connections.

One thing that is particularly important for this PR is that Envoy does
connection pooling for internal connections like it does for any other
connections. Connections from the same pool assumed to share the same
filter state (via transport socket options) with the upstream internal
listener (e.g., `main_internal` listener in our case).

So if you have two HTTP2 streams with different authority in the HBONE
connect requests, only authority from the stream handled first will be
communicated to the upstream internal listener - that's not what we
want.

Envoy in principle recognizes that filter state may affect some routing
decisions, so for some types of filter state objects shared with
upstream Envoy can tell that it should use different connection pools
to avoid mixing unrelated requests together, however `envoy.string` type
we currently use to communicate authority from the HBONE CONNECT requests
is not one of such types.

Recently, Envoy introduced `envoy.hashable_string` that does what we
need (see envoyproxy/envoy#43208), but this
change didn't make it to Envoy 1.37 release branch and it will not be
backported.

NOTE: I checked other existing filter state object types, and they don't
suit us either, so upstream Envoy `envoy.hashable_string` is basically
the first and the only one that works for us.

NOTE: From Envoy point of view that change is not a bug or security fix,
so the fact that it should not be backported makes perfect sense, but
just in case I also explicitly asked in that PR if we could backport it
and got an explicit response that it's quite undesirable.

So this PR introduces `istio.hashable_string` which does exactly the
same thing that upstream `envoy.hashable_string` does, however we can
backport it to the Istio's 1.29 release branch without relying on
upstream Envoy. Eventually, we can phase it out in favor of the upstream
Envoy `envoy.hashable_string`.

With the current Istio release cadence, according to
https://istio.io/latest/docs/releases/supported-releases/, we should be
able to phase it out completely in about 2 quarters and 6 weeks.
Together with the fact that the extensions is quite small, I think that
it's manageable to add it to the Istio proxy repor, even if it's not
ideal.

Signed-off-by: Mikhail Krinkin <[email protected]>
Co-authored-by: Mikhail Krinkin <[email protected]>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
Change-Id: Ide0862550ebd67fc0de034daaac42be8f0fd6688

Commit Message: add a hashable string that can influence HTTP connection
pool when shared with upstream.
Additional Description:
Risk Level: low
Testing: yes
Docs Changes: yes
Release Notes: no

---------

Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Gustavo <[email protected]>
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.

3 participants