Skip to content

network_ext_proc: support connection attributes and filter state - #46551

Merged
yanavlasov merged 2 commits into
envoyproxy:mainfrom
botengyao:network_ext_proc_filter_state
Aug 6, 2026
Merged

yanavlasov merged 2 commits into
envoyproxy:mainfrom
botengyao:network_ext_proc_filter_state

Conversation

@botengyao

Copy link
Copy Markdown
Member

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:

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]>
@repokitteh-read-only

Copy link
Copy Markdown

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: #46551 was opened by botengyao.

see: more, trace.

@botengyao
botengyao marked this pull request as ready for review August 6, 2026 02:34
@botengyao
botengyao requested a review from yanavlasov as a code owner August 6, 2026 02:34
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #46551 was ready_for_review by botengyao.

see: more, trace.

@adisuissa

Copy link
Copy Markdown
Contributor

Assigning @yanavlasov as codeowner
/assign @yanavlasov

@markdroth

Copy link
Copy Markdown
Contributor

/lgtm api

@repokitteh-read-only repokitteh-read-only Bot removed the api label Aug 6, 2026
@yanavlasov
yanavlasov merged commit 3afca09 into envoyproxy:main Aug 6, 2026
29 checks passed
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.
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.

4 participants