Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ minor_behavior_changes:
change: |
Use mobile specific network observer registries to propagate network change signals. This behavior can be reverted by
setting the runtime guard ``envoy.reloadable_features.mobile_use_network_observer_registry``.
- area: wasm
change: |
Foreign functions are executed on effective context, if such is defined. Effective context is set by wasm SDKs, but was not used
when foreign function was called. This fixes an issue where a foreign function is called from HTTP or GRPC callback and
that foreign function needs a stream context, not root context. This behavior can be reverted by
setting the runtime guard ``envoy.reloadable_features.wasm_use_effective_ctx_for_foreign_functions`` to false.

bug_fixes:
# *Changes expected to improve the state of the world and are unlikely to have negative effects*
Expand Down
1 change: 1 addition & 0 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ RUNTIME_GUARD(envoy_reloadable_features_use_migration_in_quiche);
RUNTIME_GUARD(envoy_reloadable_features_use_response_decoder_handle);
RUNTIME_GUARD(envoy_reloadable_features_validate_connect);
RUNTIME_GUARD(envoy_reloadable_features_validate_upstream_headers);
RUNTIME_GUARD(envoy_reloadable_features_wasm_use_effective_ctx_for_foreign_functions);
RUNTIME_GUARD(envoy_reloadable_features_websocket_allow_4xx_5xx_through_filter_chain);
RUNTIME_GUARD(envoy_reloadable_features_websocket_enable_timeout_on_upgrade_response);
RUNTIME_GUARD(envoy_reloadable_features_xds_failover_to_primary_enabled);
Expand Down
12 changes: 10 additions & 2 deletions source/extensions/common/wasm/foreign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ RegisterForeignFunction registerSetEnvoyFilterStateForeignFunction(
const std::function<void*(size_t size)>&) -> WasmResult {
envoy::source::extensions::common::wasm::SetEnvoyFilterStateArguments args;
if (args.ParseFromString(arguments)) {
auto context = static_cast<Context*>(proxy_wasm::current_context_);
auto context = static_cast<Context*>(
Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.wasm_use_effective_ctx_for_foreign_functions")
? proxy_wasm::contextOrEffectiveContext()
: proxy_wasm::current_context_);
return context->setEnvoyFilterState(args.path(), args.value(),
toFilterStateLifeSpan(args.span()));
}
Expand All @@ -220,7 +224,11 @@ RegisterForeignFunction registerSetEnvoyFilterStateForeignFunction(
RegisterForeignFunction registerClearRouteCacheForeignFunction(
"clear_route_cache",
[](WasmBase&, std::string_view, const std::function<void*(size_t size)>&) -> WasmResult {
auto context = static_cast<Context*>(proxy_wasm::current_context_);
auto context = static_cast<Context*>(
Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.wasm_use_effective_ctx_for_foreign_functions")
? proxy_wasm::contextOrEffectiveContext()
: proxy_wasm::current_context_);
context->clearRouteCache();
return WasmResult::Ok;
});
Expand Down
Loading