Skip to content

Commit 6d11931

Browse files
authored
dynamic modules: enhanced ABI to support header addition and body size retrieval (#41908)
Commit Message: dynamic modules: enhanced ABI to support header addition and body size retrieval Additional Description: 1. New ABI to support header addition. By this way users could append header value rather than only overwrite. 2. New ABI to get body size without read the body content. 3. naming change: body_vector -> body_chunks 4. Updated the get_header and get_headers ABI to use return value as status and parameter as output. 5. All the structs and enums types have a name. This is necessary for CGO to identify it correctly. Risk Level: low. Testing: unit/integration. Docs Changes: n/a. Release Notes: added. Platform Specific Features: n/a. --------- Signed-off-by: wbpcode <[email protected]>
1 parent aca529f commit 6d11931

29 files changed

+1156
-387
lines changed

changelogs/current.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ new_features:
147147
change: |
148148
Support process-level rate limiting on access log emission by
149149
:ref:`ProcessRateLimitFilter <envoy_v3_api_msg_extensions.access_loggers.filters.process_ratelimit.v3.ProcessRateLimitFilter>`.
150+
- area: dynamic modules
151+
change: |
152+
Enhanced dynamic module ABIs to support headers addition and body size retrieval.
153+
See the latest ABI header file for more details.
150154
- area: udp_sink
151155
change: |
152156
Enhanced the UDP sink to support tapped messages larger than 64 KB.

source/extensions/dynamic_modules/abi.h

Lines changed: 270 additions & 149 deletions
Large diffs are not rendered by default.

source/extensions/dynamic_modules/abi_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DynamicModules {
66
#endif
77
// This is the ABI version calculated as a sha256 hash of the ABI header files. When the ABI
88
// changes, this value must change, and the correctness of this value is checked by the test.
9-
const char* kAbiVersion = "52972436b8fd594556e76e1f9adfe1c22b7fd4a6bd3bbe6d9cdc8e0d7903dc68";
9+
const char* kAbiVersion = "cb4b1a2acfcb8b68e74f754d8a9197e64eb3b926056d4054971b86eee6f19d95";
1010

1111
#ifdef __cplusplus
1212
} // namespace DynamicModules

source/extensions/dynamic_modules/sdk/rust/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl bindgen::callbacks::ParseCallbacks for TrimEnumNameFromVariantName {
5252
) -> Option<String> {
5353
let variant_name = match enum_name {
5454
Some(enum_name) => original_variant_name
55-
.trim_start_matches(enum_name)
55+
.trim_start_matches(enum_name.trim_start_matches("enum "))
5656
.trim_start_matches('_'),
5757
None => original_variant_name,
5858
};

source/extensions/dynamic_modules/sdk/rust/src/lib.rs

Lines changed: 236 additions & 43 deletions
Large diffs are not rendered by default.

source/extensions/filters/http/dynamic_modules/abi_impl.cc

Lines changed: 164 additions & 53 deletions
Large diffs are not rendered by default.

source/extensions/filters/http/dynamic_modules/filter.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ void DynamicModuleHttpFilter::HttpCalloutCallback::onSuccess(const AsyncClient::
170170
return;
171171
}
172172

173-
absl::InlinedVector<envoy_dynamic_module_type_http_header, 16> headers_vector;
173+
absl::InlinedVector<envoy_dynamic_module_type_envoy_http_header, 16> headers_vector;
174174
headers_vector.reserve(response->headers().size());
175175
response->headers().iterate([&headers_vector](
176176
const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate {
177-
headers_vector.emplace_back(envoy_dynamic_module_type_http_header{
177+
headers_vector.emplace_back(envoy_dynamic_module_type_envoy_http_header{
178178
const_cast<char*>(header.key().getStringView().data()), header.key().getStringView().size(),
179179
const_cast<char*>(header.value().getStringView().data()),
180180
header.value().getStringView().size()});

test/extensions/dynamic_modules/http/abi_impl_test.cc

Lines changed: 286 additions & 109 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "source/extensions/dynamic_modules/abi.h"
22

3-
envoy_dynamic_module_type_abi_version_envoy_ptr envoy_dynamic_module_on_program_init() {
3+
envoy_dynamic_module_type_abi_version_module_ptr envoy_dynamic_module_on_program_init() {
44
return "invalid-version-hash";
55
}

test/extensions/dynamic_modules/test_data/c/http_filter_per_route_config_new_fail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "source/extensions/dynamic_modules/abi.h"
44
#include "source/extensions/dynamic_modules/abi_version.h"
55

6-
envoy_dynamic_module_type_abi_version_envoy_ptr envoy_dynamic_module_on_program_init() {
6+
envoy_dynamic_module_type_abi_version_module_ptr envoy_dynamic_module_on_program_init() {
77
return kAbiVersion;
88
}
99

0 commit comments

Comments
 (0)