Skip to content

Commit 1913192

Browse files
authored
dynamic_modules: add dynamic modules support for Network filters (#42605)
## Description This PR adds support for a new Network filter for Dynamic Modules. With this it should be possible to write new Network Filters similar to HTTP Filters in Go, RUST, etc. --- **Commit Message:** dynamic_modules: add dynamic modules support for Network filters **Additional Description:** Adds support for a new Network filter for Dynamic Modules. **Risk Level:** Low **Testing:** Added Unit + Integration Tests **Docs Changes:** Added **Release Notes:** Added --------- Signed-off-by: Rohit Agrawal <[email protected]>
1 parent 7b1c7b1 commit 1913192

File tree

33 files changed

+3621
-6
lines changed

33 files changed

+3621
-6
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ extensions/upstreams/tcp @ggreenway @mattklein123
399399
# Dynamic Modules
400400
/*/extensions/dynamic_modules @mattklein123 @mathetake @marc-barry
401401
/*/extensions/filters/http/dynamic_modules @mattklein123 @mathetake @marc-barry
402+
/*/extensions/filters/network/dynamic_modules @agrawroh @mathetake @wbpcode
402403
# Linux network namespace override
403404
/*/extensions/local_address_selectors/filter_state_override @tonya11en @kyessenov
404405

api/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ proto_library(
242242
"//envoy/extensions/filters/network/direct_response/v3:pkg",
243243
"//envoy/extensions/filters/network/dubbo_proxy/router/v3:pkg",
244244
"//envoy/extensions/filters/network/dubbo_proxy/v3:pkg",
245+
"//envoy/extensions/filters/network/dynamic_modules/v3:pkg",
245246
"//envoy/extensions/filters/network/echo/v3:pkg",
246247
"//envoy/extensions/filters/network/ext_authz/v3:pkg",
247248
"//envoy/extensions/filters/network/ext_proc/v3:pkg",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.
2+
3+
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
4+
5+
licenses(["notice"]) # Apache 2
6+
7+
api_proto_package(
8+
deps = [
9+
"//envoy/extensions/dynamic_modules/v3:pkg",
10+
"@com_github_cncf_xds//udpa/annotations:pkg",
11+
],
12+
)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
syntax = "proto3";
2+
3+
package envoy.extensions.filters.network.dynamic_modules.v3;
4+
5+
import "envoy/extensions/dynamic_modules/v3/dynamic_modules.proto";
6+
7+
import "google/protobuf/any.proto";
8+
9+
import "udpa/annotations/status.proto";
10+
11+
option java_package = "io.envoyproxy.envoy.extensions.filters.network.dynamic_modules.v3";
12+
option java_outer_classname = "DynamicModulesProto";
13+
option java_multiple_files = true;
14+
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/dynamic_modules/v3;dynamic_modulesv3";
15+
option (udpa.annotations.file_status).package_version_status = ACTIVE;
16+
17+
// [#protodoc-title: Network filter for dynamic modules]
18+
// [#extension: envoy.filters.network.dynamic_modules]
19+
20+
// Configuration of the network filter for dynamic modules. This filter allows loading shared object
21+
// files that can be loaded via dlopen by the network filter.
22+
//
23+
// A module can be loaded by multiple network filters, hence the program can be structured in a way
24+
// that the module is loaded only once and shared across multiple filters providing multiple
25+
// functionalities.
26+
//
27+
// Unlike HTTP filters which operate on structured headers, body, and trailers, network filters
28+
// work with raw TCP byte streams. The filter can:
29+
//
30+
// * Inspect, modify, or inject data into the downstream connection.
31+
// * Access connection-level information such as addresses and TLS status.
32+
// * Control connection lifecycle (e.g., close the connection).
33+
//
34+
message DynamicModuleNetworkFilter {
35+
// Specifies the shared-object level configuration.
36+
envoy.extensions.dynamic_modules.v3.DynamicModuleConfig dynamic_module_config = 1;
37+
38+
// The name for this filter configuration. This can be used to distinguish between different
39+
// filter implementations inside a dynamic module. For example, a module can have completely
40+
// different filter implementations. When Envoy receives this configuration, it passes the
41+
// ``filter_name`` to the dynamic module's network filter config init function together with
42+
// the ``filter_config``. That way a module can decide which in-module filter implementation
43+
// to use based on the name at load time.
44+
string filter_name = 2;
45+
46+
// The configuration for the filter chosen by ``filter_name``. This is passed to the module's
47+
// network filter initialization function. Together with the ``filter_name``, the module can
48+
// decide which in-module filter implementation to use and fine-tune the behavior of the filter.
49+
//
50+
// For example, if a module has two filter implementations, one for echo and one for rate
51+
// limiting, ``filter_name`` is used to choose either echo or rate limiting. The ``filter_config``
52+
// can be used to configure the echo behavior or the rate limiting parameters.
53+
//
54+
// ``google.protobuf.Struct`` is serialized as JSON before passing it to the module.
55+
// ``google.protobuf.BytesValue`` and ``google.protobuf.StringValue`` are passed directly
56+
// without the wrapper.
57+
//
58+
// .. code-block:: yaml
59+
//
60+
// # Passing a string value
61+
// filter_config:
62+
// "@type": "type.googleapis.com/google.protobuf.StringValue"
63+
// value: hello
64+
//
65+
// # Passing raw bytes
66+
// filter_config:
67+
// "@type": "type.googleapis.com/google.protobuf.BytesValue"
68+
// value: aGVsbG8= # echo -n "hello" | base64
69+
//
70+
google.protobuf.Any filter_config = 3;
71+
}

api/versioning/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ proto_library(
181181
"//envoy/extensions/filters/network/direct_response/v3:pkg",
182182
"//envoy/extensions/filters/network/dubbo_proxy/router/v3:pkg",
183183
"//envoy/extensions/filters/network/dubbo_proxy/v3:pkg",
184+
"//envoy/extensions/filters/network/dynamic_modules/v3:pkg",
184185
"//envoy/extensions/filters/network/echo/v3:pkg",
185186
"//envoy/extensions/filters/network/ext_authz/v3:pkg",
186187
"//envoy/extensions/filters/network/ext_proc/v3:pkg",

changelogs/current.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ new_features:
264264
change: |
265265
Added support for loading dynamic modules globally by setting :ref:`load_globally
266266
<envoy_v3_api_field_extensions.dynamic_modules.v3.DynamicModuleConfig.load_globally>` to ``true``.
267+
- area: dynamic modules
268+
change: |
269+
Added :ref:`network filter <envoy_v3_api_msg_extensions.filters.network.dynamic_modules.v3.DynamicModuleNetworkFilter>`
270+
support for dynamic modules, enabling TCP stream processing with dynamic modules.
267271
- area: http filter
268272
change: |
269273
Added :ref:`transform http filter <config_http_filters_transform>` to modify request and response bodies in any

docs/root/intro/arch_overview/advanced/dynamic_modules.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ official SDK that abstracts these details and provides a high-level API to imple
1919
available in Rust. In theory, any language that can produce a shared library can be used to implement dynamic modules.
2020
Future development may include support for other languages.
2121

22-
Currently, dynamic modules are only supported at the following extension points:
22+
Currently, dynamic modules are supported at the following extension points:
2323

24-
* As an :ref:`HTTP filter <envoy_v3_api_msg_extensions.filters.http.dynamic_modules.v3.DynamicModuleFilter>`
24+
* As an :ref:`HTTP filter <envoy_v3_api_msg_extensions.filters.http.dynamic_modules.v3.DynamicModuleFilter>`.
25+
* As a :ref:`network filter <envoy_v3_api_msg_extensions.filters.network.dynamic_modules.v3.DynamicModuleNetworkFilter>`.
2526

2627
There are a few design goals for the dynamic modules:
2728

0 commit comments

Comments
 (0)