Repository navigation
network_ext_proc: support connection attributes and filter state - #46551
Merged
yanavlasov merged 2 commits intoAug 6, 2026
Merged
Conversation
Add connection_attributes CEL expression evaluation to the Network External Processor filter, allowing connection attributes and filter state (e.g. filter_state['...'], connection.id, connection.mtls) to be evaluated and sent to the external processor in ProcessingRequest.attributes. Signed-off-by: Boteng Yao <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Contributor
|
Assigning @yanavlasov as codeowner |
Contributor
|
/lgtm api |
yanavlasov
approved these changes
Aug 6, 2026
2 tasks done
keithmattix
added a commit
to keithmattix/substrate
that referenced
this pull request
Aug 14, 2026
Adds arbitrary-port ingress via HTTP CONNECT: a connect_terminate
listener (plaintext and TLS variants) terminates the client's CONNECT
and reinjects the tunneled bytes into a main_internal internal
listener. There, a filter-chain matcher keyed on transport protocol
then application protocol splits the traffic:
- HTTP-tunneled requests go through the normal HCM + ext_proc path,
so each inner request still triggers ext_proc/Resume exactly like
plain ingress traffic -- this is what lets a long-lived CONNECT
tunnel keep working across an actor moving to a new worker pod.
- Raw TCP (or anything else) falls through to a tcp_proxy filter
chain fed by a new network (L4) ext_proc server
(ingress.NetworkExtProcServer), resolved once per connection
rather than per request. It shares the same gRPC server/port/drain
sequence as the HTTP ext_proc service -- gRPC dispatches by
service name, not port, so there is nothing to gain from a second
listener for what is already one process.
Getting the actor identity across the internal-listener hop is the
crux of this change. Dynamic metadata does not survive it, so the HTTP
leg captures :authority into filter state at connect_terminate (or, for
plain ingress, at the outer HCM directly) and reads it back via a
request_attributes CEL expression once reinjected --
ingress.Handler.HandleRequestHeaders now resolves the actor from that
forwarded attribute rather than the Host/:authority header directly.
The network leg gets the same identity across the hop via
ConnectionAttributes evaluating the same filter state -- the
network-filter counterpart of RequestAttributes, available since Envoy
gained connection-attribute/filter-state support for
NetworkExternalProcessor (envoyproxy/envoy#46551).
The ORIGINAL_DST cluster moves from header-mutation-based routing to
metadata-based (ingress.OriginalDstMetadataKey/OriginalDstAddressKey):
a header only works for HTTP traffic, and the network ext_proc leg has
none, so one metadata-based mechanism now serves both legs and
:authority/Host is never rewritten -- atunnel authorizes the actor by
its own, unmodified DNS name throughout. atunnel can't read dynamic
metadata directly, so the arbitrary target port travels to it via a
real TargetPortHeader instead, set directly by ingress.Handler and
declaratively derived at the route level via a
%DYNAMIC_METADATA(...)% command operator for the Envoy dataplane.
To extend this design to a mux that dispatches by traffic direction
(ingress vs. egress) rather than a single ext_proc server, the mux's
RequestMetadata/Result now carry the CEL attributes in and dynamic
metadata out that the above needs (extproc/metadata.go, handler.go,
extproc.go) -- mechanism the egress handler doesn't use today but
shares the same request/response shape for.
Also wires the CONNECT listener ports (--port-connect, --port-connect-tls,
the latter defaulting to 8444 rather than colliding with --port-https's
8443, since both can be enabled at once) and the network ext_proc
cluster's own circuit breaker (--extproc-max-connections) into router
startup and manifests, mirrors the same CONNECT binds into
agentgateway's configmap for the non-Envoy dataplane, and bumps the
default --envoy-image to v1.39-latest: the network ext_proc filter's
MetadataOptions.ReceivingNamespaces requires Envoy >= 1.39, and
ConnectionAttributes above requires envoyproxy/envoy#46551.
keithmattix
added a commit
to keithmattix/substrate
that referenced
this pull request
Aug 14, 2026
Adds arbitrary-port ingress via HTTP CONNECT: a connect_terminate
listener (plaintext and TLS variants) terminates the client's CONNECT
and reinjects the tunneled bytes into a main_internal internal
listener. There, a filter-chain matcher keyed on transport protocol
then application protocol splits the traffic:
- HTTP-tunneled requests go through the normal HCM + ext_proc path,
so each inner request still triggers ext_proc/Resume exactly like
plain ingress traffic -- this is what lets a long-lived CONNECT
tunnel keep working across an actor moving to a new worker pod.
- Raw TCP (or anything else) falls through to a tcp_proxy filter
chain fed by a new network (L4) ext_proc server
(ingress.NetworkExtProcServer), resolved once per connection
rather than per request. It shares the same gRPC server/port/drain
sequence as the HTTP ext_proc service -- gRPC dispatches by
service name, not port, so there is nothing to gain from a second
listener for what is already one process.
Getting the actor identity across the internal-listener hop is the
crux of this change. Dynamic metadata does not survive it, so the HTTP
leg captures :authority into filter state at connect_terminate (or, for
plain ingress, at the outer HCM directly) and reads it back via a
request_attributes CEL expression once reinjected --
ingress.Handler.HandleRequestHeaders now resolves the actor from that
forwarded attribute rather than the Host/:authority header directly.
The network leg gets the same identity across the hop via
ConnectionAttributes evaluating the same filter state -- the
network-filter counterpart of RequestAttributes, available since Envoy
gained connection-attribute/filter-state support for
NetworkExternalProcessor (envoyproxy/envoy#46551).
The ORIGINAL_DST cluster moves from header-mutation-based routing to
metadata-based (ingress.OriginalDstMetadataKey/OriginalDstAddressKey):
a header only works for HTTP traffic, and the network ext_proc leg has
none, so one metadata-based mechanism now serves both legs and
:authority/Host is never rewritten -- atunnel authorizes the actor by
its own, unmodified DNS name throughout. atunnel can't read dynamic
metadata directly, so the arbitrary target port travels to it via a
real TargetPortHeader instead, set directly by ingress.Handler and
declaratively derived at the route level via a
%DYNAMIC_METADATA(...)% command operator for the Envoy dataplane.
To extend this design to a mux that dispatches by traffic direction
(ingress vs. egress) rather than a single ext_proc server, the mux's
RequestMetadata/Result now carry the CEL attributes in and dynamic
metadata out that the above needs (extproc/metadata.go, handler.go,
extproc.go) -- mechanism the egress handler doesn't use today but
shares the same request/response shape for.
Also wires the CONNECT listener ports (--port-connect, --port-connect-tls,
the latter defaulting to 8444 rather than colliding with --port-https's
8443, since both can be enabled at once) and the network ext_proc
cluster's own circuit breaker (--extproc-max-connections) into router
startup and manifests, mirrors the same CONNECT binds into
agentgateway's configmap for the non-Envoy dataplane, and bumps the
default --envoy-image to v1.39-latest: the network ext_proc filter's
MetadataOptions.ReceivingNamespaces requires Envoy >= 1.39, and
ConnectionAttributes above requires envoyproxy/envoy#46551.
keithmattix
added a commit
to keithmattix/substrate
that referenced
this pull request
Aug 14, 2026
Adds arbitrary-port ingress via HTTP CONNECT: a connect_terminate
listener (plaintext and TLS variants) terminates the client's CONNECT
and reinjects the tunneled bytes into a main_internal internal
listener. There, a filter-chain matcher keyed on transport protocol
then application protocol splits the traffic:
- HTTP-tunneled requests go through the normal HCM + ext_proc path,
so each inner request still triggers ext_proc/Resume exactly like
plain ingress traffic -- this is what lets a long-lived CONNECT
tunnel keep working across an actor moving to a new worker pod.
- Raw TCP (or anything else) falls through to a tcp_proxy filter
chain fed by a new network (L4) ext_proc server
(ingress.NetworkExtProcServer), resolved once per connection
rather than per request. It shares the same gRPC server/port/drain
sequence as the HTTP ext_proc service -- gRPC dispatches by
service name, not port, so there is nothing to gain from a second
listener for what is already one process.
Getting the actor identity across the internal-listener hop is the
crux of this change. Dynamic metadata does not survive it, so the HTTP
leg captures :authority into filter state at connect_terminate (or, for
plain ingress, at the outer HCM directly) and reads it back via a
request_attributes CEL expression once reinjected --
ingress.Handler.HandleRequestHeaders now resolves the actor from that
forwarded attribute rather than the Host/:authority header directly.
The network leg gets the same identity across the hop via
ConnectionAttributes evaluating the same filter state -- the
network-filter counterpart of RequestAttributes, available since Envoy
gained connection-attribute/filter-state support for
NetworkExternalProcessor (envoyproxy/envoy#46551).
The ORIGINAL_DST cluster moves from header-mutation-based routing to
metadata-based (ingress.OriginalDstMetadataKey/OriginalDstAddressKey):
a header only works for HTTP traffic, and the network ext_proc leg has
none, so one metadata-based mechanism now serves both legs and
:authority/Host is never rewritten -- atunnel authorizes the actor by
its own, unmodified DNS name throughout. atunnel can't read dynamic
metadata directly, so the arbitrary target port travels to it via a
real TargetPortHeader instead, set directly by ingress.Handler and
declaratively derived at the route level via a
%DYNAMIC_METADATA(...)% command operator for the Envoy dataplane.
To extend this design to a mux that dispatches by traffic direction
(ingress vs. egress) rather than a single ext_proc server, the mux's
RequestMetadata/Result now carry the CEL attributes in and dynamic
metadata out that the above needs (extproc/metadata.go, handler.go,
extproc.go) -- mechanism the egress handler doesn't use today but
shares the same request/response shape for.
Also wires the CONNECT listener ports (--port-connect, --port-connect-tls,
the latter defaulting to 8444 rather than colliding with --port-https's
8443, since both can be enabled at once) and the network ext_proc
cluster's own circuit breaker (--extproc-max-connections) into router
startup and manifests, mirrors the same CONNECT binds into
agentgateway's configmap for the non-Envoy dataplane, and bumps the
default --envoy-image to v1.39-latest: the network ext_proc filter's
MetadataOptions.ReceivingNamespaces requires Envoy >= 1.39, and
ConnectionAttributes above requires envoyproxy/envoy#46551.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add connection_attributes CEL expression evaluation to the Network External Processor filter, allowing connection attributes and filter state (e.g. filter_state['...'], connection.id, connection.mtls) to be evaluated and sent to the external processor in ProcessingRequest.attributes.
Commit Message:
Additional Description:
Risk Level: low
Testing:
Docs Changes:
Release Notes: