You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2025/05/15 18:12:39 UTC
(trafficserver) branch 10.1.x updated (56a10c9d71 -> 7c83a7d004)
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
from 56a10c9d71 Add a StatusCode() macro for Cripts convenience mode (#12170)
new 16c4548388 cachekey doc: --include-headers matched case insensitively (#12235)
new 23e70742f7 revert #10996 move session pool metrics outside critical section (#12233)
new 82e627fa03 Update SNI for origin side connections (#12231)
new 332fdbfce9 XPACK: Inspect _start_expanding_capacity before expanding (#12228)
new ce27946eff Fix compilation problem with wasm plugin + Update the use of proxy-wasm library (#12222)
new 6de6ebb1d2 Call SSL_get_negotiated_group not during read early data (#12224)
new 7c83a7d004 Reset write lock state to init after closing write (#12215)
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CMakePresets.json | 7 ++-
cmake/ExperimentalPlugins.cmake | 22 +++++++++-
cmake/Findwamr.cmake | 2 +-
cmake/{Findjemalloc.cmake => Findwasmedge.cmake} | 36 +++++++---------
cmake/{Findjemalloc.cmake => Findwasmtime.cmake} | 36 +++++++---------
doc/admin-guide/plugins/cachekey.en.rst | 2 +-
doc/admin-guide/plugins/wasm.en.rst | 21 ++++-----
include/iocore/net/TLSBasicSupport.h | 1 +
include/iocore/net/TLSSNISupport.h | 24 ++++++++++-
include/proxy/hdrs/XPACK.h | 15 ++++++-
plugins/experimental/CMakeLists.txt | 5 ++-
plugins/experimental/wasm/CMakeLists.txt | 23 +++++++++-
plugins/experimental/wasm/lib/CMakeLists.txt | 10 +++++
.../wasm/lib/README.proxy-wasm-cpp-host.md | 4 ++
.../wasm/lib/include/proxy-wasm/context.h | 4 +-
.../lib/include/proxy-wasm/context_interface.h | 5 +--
.../wasm/lib/include/proxy-wasm/exports.h | 10 +++--
.../wasm/lib/include/proxy-wasm/pairs_util.h | 1 +
.../experimental/wasm/lib/include/proxy-wasm/sdk.h | 50 ++++++++++++++++++++++
.../wasm/lib/include/proxy-wasm/vm_id_handle.h | 4 +-
.../wasm/lib/include/proxy-wasm/wasm.h | 3 +-
.../wasm/lib/include/proxy-wasm/wasm_api_impl.h | 4 +-
.../wasm/lib/include/proxy-wasm/wasm_vm.h | 4 +-
.../wasm/lib/include/proxy-wasm/word.h | 4 +-
plugins/experimental/wasm/lib/src/exports.cc | 25 +++++++++++
plugins/experimental/wasm/lib/src/wamr/wamr.cc | 33 ++++++++++----
plugins/experimental/wasm/lib/src/wasm.cc | 5 ++-
plugins/experimental/wasm/lib/src/wasmtime/types.h | 2 +-
.../experimental/wasm/lib/src/wasmtime/wasmtime.cc | 6 +--
src/iocore/net/QUICNetVConnection.cc | 1 +
src/iocore/net/SSLNetVConnection.cc | 4 +-
src/iocore/net/SSLUtils.cc | 22 ----------
src/iocore/net/TLSBasicSupport.cc | 33 ++++++++++++++
src/iocore/net/TLSSNISupport.cc | 27 ++++++++++--
src/proxy/hdrs/XPACK.cc | 7 ++-
src/proxy/hdrs/unit_tests/test_XPACK.cc | 7 +++
src/proxy/http/HttpSM.cc | 2 +
src/proxy/http/HttpSessionManager.cc | 19 +++-----
38 files changed, 354 insertions(+), 136 deletions(-)
copy cmake/{Findjemalloc.cmake => Findwasmedge.cmake} (57%)
copy cmake/{Findjemalloc.cmake => Findwasmtime.cmake} (57%)
create mode 100644 plugins/experimental/wasm/lib/include/proxy-wasm/sdk.h
(trafficserver) 06/07: Call SSL_get_negotiated_group not during read early data (#12224)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 6de6ebb1d2985103d6a862b1bca09f4a58335b50
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Wed May 7 16:18:36 2025 -0500
Call SSL_get_negotiated_group not during read early data (#12224)
Recent versions of OpenSSL define SSL_CB_HANDSHAKE_DONE as follows:
> Callback has been called because a handshake is finished. It also
> occurs if the handshake is paused to allow the exchange of early data.
Calling SSL_get_negotiated_group duing early data situations was causing
a crash. This moves the calling of SSL_get_negotiated_group next to
_record_tls_handshake_end_time where it will reliably not be called in
the context of processing early data.
Fixes: #12140
(cherry picked from commit afbb1f5d6d60996db410b765817e4763eb27650c)
---
include/iocore/net/TLSBasicSupport.h | 1 +
src/iocore/net/QUICNetVConnection.cc | 1 +
src/iocore/net/SSLNetVConnection.cc | 2 +-
src/iocore/net/SSLUtils.cc | 22 ----------------------
src/iocore/net/TLSBasicSupport.cc | 33 +++++++++++++++++++++++++++++++++
5 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/include/iocore/net/TLSBasicSupport.h b/include/iocore/net/TLSBasicSupport.h
index c269c51c0f..c814357ca4 100644
--- a/include/iocore/net/TLSBasicSupport.h
+++ b/include/iocore/net/TLSBasicSupport.h
@@ -79,6 +79,7 @@ protected:
void _record_tls_handshake_begin_time();
void _record_tls_handshake_end_time();
+ void _update_end_of_handshake_stats();
/**
* Implementation should schedule either TS_EVENT_SSL_VERIFY_SERVER or TS_EVENT_SSL_VERIFY_CLIENT accordingly.
diff --git a/src/iocore/net/QUICNetVConnection.cc b/src/iocore/net/QUICNetVConnection.cc
index 27efe4a952..6a07b2cc32 100644
--- a/src/iocore/net/QUICNetVConnection.cc
+++ b/src/iocore/net/QUICNetVConnection.cc
@@ -250,6 +250,7 @@ QUICNetVConnection::_switch_to_established_state()
{
QUICConDebug("Enter state_connection_established");
this->_record_tls_handshake_end_time();
+ this->_update_end_of_handshake_stats();
SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_established);
this->_start_application();
this->_handshake_completed = true;
diff --git a/src/iocore/net/SSLNetVConnection.cc b/src/iocore/net/SSLNetVConnection.cc
index 0b719e460d..ff453b8bdd 100644
--- a/src/iocore/net/SSLNetVConnection.cc
+++ b/src/iocore/net/SSLNetVConnection.cc
@@ -1321,7 +1321,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err)
if (this->get_tls_handshake_begin_time()) {
this->_record_tls_handshake_end_time();
- Metrics::Counter::increment(ssl_rsb.total_success_handshake_count_in);
+ this->_update_end_of_handshake_stats();
}
if (this->get_tunnel_type() != SNIRoutingType::NONE) {
diff --git a/src/iocore/net/SSLUtils.cc b/src/iocore/net/SSLUtils.cc
index 40bbf7b470..a71180fa21 100644
--- a/src/iocore/net/SSLUtils.cc
+++ b/src/iocore/net/SSLUtils.cc
@@ -1077,28 +1077,6 @@ ssl_callback_info(const SSL *ssl, int where, int ret)
}
Metrics::Counter::increment(it->second);
}
-
-#if defined(OPENSSL_IS_BORINGSSL)
- uint16_t group_id = SSL_get_group_id(ssl);
- if (group_id != 0) {
- const char *group_name = SSL_get_group_name(group_id);
- if (auto it = tls_group_map.find(group_name); it != tls_group_map.end()) {
- Metrics::Counter::increment(it->second);
- } else {
- Warning("Unknown TLS Group");
- }
- }
-#elif defined(SSL_get_negotiated_group)
- int nid = SSL_get_negotiated_group(const_cast<SSL *>(ssl));
- if (nid != NID_undef) {
- if (auto it = tls_group_map.find(nid); it != tls_group_map.end()) {
- Metrics::Counter::increment(it->second);
- } else {
- auto other = tls_group_map.find(SSL_GROUP_STAT_OTHER_KEY);
- Metrics::Counter::increment(other->second);
- }
- }
-#endif // OPENSSL_IS_BORINGSSL or SSL_get_negotiated_group
}
}
diff --git a/src/iocore/net/TLSBasicSupport.cc b/src/iocore/net/TLSBasicSupport.cc
index add717fb1c..ab97412ea4 100644
--- a/src/iocore/net/TLSBasicSupport.cc
+++ b/src/iocore/net/TLSBasicSupport.cc
@@ -24,6 +24,9 @@
#include "SSLStats.h"
#include "iocore/net/TLSBasicSupport.h"
+#if defined(OPENSSL_IS_BORINGSSL)
+#include "tscore/Diags.h" // For Warning
+#endif // OPENSSL_IS_BORINGSSL
#include "tsutil/DbgCtl.h"
#include <cinttypes>
@@ -201,3 +204,33 @@ TLSBasicSupport::_record_tls_handshake_end_time()
Dbg(dbg_ctl_ssl, "ssl handshake time:%" PRId64, ssl_handshake_time);
Metrics::Counter::increment(ssl_rsb.total_handshake_time, ssl_handshake_time);
}
+
+void
+TLSBasicSupport::_update_end_of_handshake_stats()
+{
+ Metrics::Counter::increment(ssl_rsb.total_success_handshake_count_in);
+
+#if defined(OPENSSL_IS_BORINGSSL)
+ SSL *ssl = this->_get_ssl_object();
+ uint16_t group_id = SSL_get_group_id(ssl);
+ if (group_id != 0) {
+ const char *group_name = SSL_get_group_name(group_id);
+ if (auto it = tls_group_map.find(group_name); it != tls_group_map.end()) {
+ Metrics::Counter::increment(it->second);
+ } else {
+ Warning("Unknown TLS Group");
+ }
+ }
+#elif defined(SSL_get_negotiated_group)
+ SSL *ssl = this->_get_ssl_object();
+ int nid = SSL_get_negotiated_group(const_cast<SSL *>(ssl));
+ if (nid != NID_undef) {
+ if (auto it = tls_group_map.find(nid); it != tls_group_map.end()) {
+ Metrics::Counter::increment(it->second);
+ } else {
+ auto other = tls_group_map.find(SSL_GROUP_STAT_OTHER_KEY);
+ Metrics::Counter::increment(other->second);
+ }
+ }
+#endif // OPENSSL_IS_BORINGSSL or SSL_get_negotiated_group
+}
(trafficserver) 05/07: Fix compilation problem with wasm plugin + Update the use of proxy-wasm library (#12222)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit ce27946effff4a326226cd2e4060359a0eda92f1
Author: Kit Chan <ki...@apache.org>
AuthorDate: Thu May 8 10:44:17 2025 -0700
Fix compilation problem with wasm plugin + Update the use of proxy-wasm library (#12222)
* Fix compilation problem with wasm plugin
* Fix format error
* Fix format error
* Fix format error in cmake files
* Fix engine requirement problem
* Remove wamr fro fedora build for now
* Fix fedora compile requirements
* Turn off wamr engine support for experimental plugin
* Fix typo
* Fix another missing line
* Enable wamr
* Disable wamr because the fedora has an older version
* wasmtime and wamr cannot be used together
(cherry picked from commit 8206ab363b325b1255511a4cb058ccaf5af8bfbf)
---
CMakePresets.json | 7 ++-
cmake/ExperimentalPlugins.cmake | 22 +++++++++-
cmake/Findwamr.cmake | 2 +-
cmake/{Findwamr.cmake => Findwasmedge.cmake} | 32 +++++++-------
cmake/{Findwamr.cmake => Findwasmtime.cmake} | 32 +++++++-------
doc/admin-guide/plugins/wasm.en.rst | 21 ++++-----
plugins/experimental/CMakeLists.txt | 5 ++-
plugins/experimental/wasm/CMakeLists.txt | 23 +++++++++-
plugins/experimental/wasm/lib/CMakeLists.txt | 10 +++++
.../wasm/lib/README.proxy-wasm-cpp-host.md | 4 ++
.../wasm/lib/include/proxy-wasm/context.h | 4 +-
.../lib/include/proxy-wasm/context_interface.h | 5 +--
.../wasm/lib/include/proxy-wasm/exports.h | 10 +++--
.../wasm/lib/include/proxy-wasm/pairs_util.h | 1 +
.../experimental/wasm/lib/include/proxy-wasm/sdk.h | 50 ++++++++++++++++++++++
.../wasm/lib/include/proxy-wasm/vm_id_handle.h | 4 +-
.../wasm/lib/include/proxy-wasm/wasm.h | 3 +-
.../wasm/lib/include/proxy-wasm/wasm_api_impl.h | 4 +-
.../wasm/lib/include/proxy-wasm/wasm_vm.h | 4 +-
.../wasm/lib/include/proxy-wasm/word.h | 4 +-
plugins/experimental/wasm/lib/src/exports.cc | 25 +++++++++++
plugins/experimental/wasm/lib/src/wamr/wamr.cc | 33 ++++++++++----
plugins/experimental/wasm/lib/src/wasm.cc | 5 ++-
plugins/experimental/wasm/lib/src/wasmtime/types.h | 2 +-
.../experimental/wasm/lib/src/wasmtime/wasmtime.cc | 6 +--
25 files changed, 235 insertions(+), 83 deletions(-)
diff --git a/CMakePresets.json b/CMakePresets.json
index 218a465424..8a68e24b35 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -47,6 +47,7 @@
"CMAKE_COMPILE_WARNING_AS_ERROR": "OFF",
"CMAKE_INSTALL_PREFIX": "/opt/ats",
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
+ "ENABLE_WASM_WAMR": "OFF",
"ENABLE_VERIFY_PLUGINS": "OFF"
}
},
@@ -58,6 +59,7 @@
"ENABLE_AUTEST": "ON",
"CMAKE_INSTALL_PREFIX": "/tmp/ts-autest",
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
+ "ENABLE_WASM_WAMR": "OFF",
"ENABLE_EXAMPLE": "ON"
}
},
@@ -106,6 +108,7 @@
"CMAKE_COMPILE_WARNING_AS_ERROR": "ON",
"ENABLE_CCACHE": "ON",
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
+ "ENABLE_WASM_WAMR": "OFF",
"ENABLE_EXAMPLE": "ON",
"CMAKE_INSTALL_PREFIX": "/tmp/ats"
}
@@ -210,7 +213,8 @@
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "/tmp/ats",
- "BUILD_EXPERIMENTAL_PLUGINS": "ON"
+ "BUILD_EXPERIMENTAL_PLUGINS": "ON",
+ "ENABLE_WASM_WAMR": "OFF"
}
},
{
@@ -391,6 +395,7 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
+ "ENABLE_WASM_WAMR": "OFF",
"ENABLE_EXAMPLE": "ON",
"ENABLE_CCACHE": "OFF"
}
diff --git a/cmake/ExperimentalPlugins.cmake b/cmake/ExperimentalPlugins.cmake
index 754dfe926a..2fa1524c77 100644
--- a/cmake/ExperimentalPlugins.cmake
+++ b/cmake/ExperimentalPlugins.cmake
@@ -115,13 +115,31 @@ auto_option(
)
auto_option(URL_SIG FEATURE_VAR BUILD_URL_SIG DEFAULT ${_DEFAULT})
auto_option(
- WASM
+ WASM_WAMR
FEATURE_VAR
- BUILD_WASM
+ BUILD_WASM_WAMR
PACKAGE_DEPENDS
wamr
DEFAULT
${_DEFAULT}
)
+auto_option(
+ WASM_WASMTIME
+ FEATURE_VAR
+ BUILD_WASM_WASMTIME
+ PACKAGE_DEPENDS
+ wasmtime
+ DEFAULT
+ ${_DEFAULT}
+)
+auto_option(
+ WASM_WASMEDGE
+ FEATURE_VAR
+ BUILD_WASM_WASMEDGE
+ PACKAGE_DEPENDS
+ wasmedge
+ DEFAULT
+ ${_DEFAULT}
+)
unset(_DEFAULT)
diff --git a/cmake/Findwamr.cmake b/cmake/Findwamr.cmake
index e74b2f023f..4c599d9980 100644
--- a/cmake/Findwamr.cmake
+++ b/cmake/Findwamr.cmake
@@ -29,7 +29,7 @@
#
find_library(iwasm_LIBRARY NAMES iwasm)
-find_path(wamr_INCLUDE_DIR NAMES wasm_export.h)
+find_path(wamr_INCLUDE_DIR NAMES wasm_c_api.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(wamr REQUIRED_VARS iwasm_LIBRARY wamr_INCLUDE_DIR)
diff --git a/cmake/Findwamr.cmake b/cmake/Findwasmedge.cmake
similarity index 56%
copy from cmake/Findwamr.cmake
copy to cmake/Findwasmedge.cmake
index e74b2f023f..11df6a54f2 100644
--- a/cmake/Findwamr.cmake
+++ b/cmake/Findwasmedge.cmake
@@ -15,33 +15,33 @@
#
#######################
-# Findwamr.cmake
+# Findwasmedge.cmake
#
# This will define the following variables
#
-# wamr_FOUND
-# wamr_LIBRARY
-# wamr_INCLUDE_DIR
+# wasmedge_FOUND
+# wasmedge_LIBRARY
+# wasmedge_INCLUDE_DIR
#
# and the following imported targets
#
-# wamr::wamr
+# wasmedge::wasmedge
#
-find_library(iwasm_LIBRARY NAMES iwasm)
-find_path(wamr_INCLUDE_DIR NAMES wasm_export.h)
+find_library(lwasmedge_LIBRARY NAMES wasmedge)
+find_path(wasmedge_INCLUDE_DIR NAMES wasmedge/wasmedge.h)
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(wamr REQUIRED_VARS iwasm_LIBRARY wamr_INCLUDE_DIR)
+find_package_handle_standard_args(wasmedge REQUIRED_VARS lwasmedge_LIBRARY wasmedge_INCLUDE_DIR)
-if(wamr_FOUND)
- mark_as_advanced(wamr_FOUND wamr_LIBRARY)
- set(wamr_INCLUDE_DIRS ${wamr_INCLUDE_DIR})
- set(wamr_LIBRARY ${iwasm_LIBRARY})
+if(wasmedge_FOUND)
+ mark_as_advanced(wasmedge_FOUND wasmedge_LIBRARY)
+ set(wasmedge_INCLUDE_DIRS ${wasmedge_INCLUDE_DIR})
+ set(wasmedge_LIBRARY ${lwasmedge_LIBRARY})
endif()
-if(wamr_FOUND AND NOT TARGET wamr::wamr)
- add_library(wamr::wamr INTERFACE IMPORTED)
- target_include_directories(wamr::wamr INTERFACE ${wamr_INCLUDE_DIRS})
- target_link_libraries(wamr::wamr INTERFACE ${wamr_LIBRARY})
+if(wasmedge_FOUND AND NOT TARGET wasmedge::wasmedge)
+ add_library(wasmedge::wasmedge INTERFACE IMPORTED)
+ target_include_directories(wasmedge::wasmedge INTERFACE ${wasmedge_INCLUDE_DIRS})
+ target_link_libraries(wasmedge::wasmedge INTERFACE ${wasmedge_LIBRARY})
endif()
diff --git a/cmake/Findwamr.cmake b/cmake/Findwasmtime.cmake
similarity index 56%
copy from cmake/Findwamr.cmake
copy to cmake/Findwasmtime.cmake
index e74b2f023f..4685f916cb 100644
--- a/cmake/Findwamr.cmake
+++ b/cmake/Findwasmtime.cmake
@@ -15,33 +15,33 @@
#
#######################
-# Findwamr.cmake
+# Findwasmtime.cmake
#
# This will define the following variables
#
-# wamr_FOUND
-# wamr_LIBRARY
-# wamr_INCLUDE_DIR
+# wasmtime_FOUND
+# wasmtime_LIBRARY
+# wasmtime_INCLUDE_DIR
#
# and the following imported targets
#
-# wamr::wamr
+# wasmtime::wasmtime
#
-find_library(iwasm_LIBRARY NAMES iwasm)
-find_path(wamr_INCLUDE_DIR NAMES wasm_export.h)
+find_library(lwasmtime_LIBRARY NAMES wasmtime)
+find_path(wasmtime_INCLUDE_DIR NAMES crates/c-api/include/wasm.h)
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(wamr REQUIRED_VARS iwasm_LIBRARY wamr_INCLUDE_DIR)
+find_package_handle_standard_args(wasmtime REQUIRED_VARS lwasmtime_LIBRARY wasmtime_INCLUDE_DIR)
-if(wamr_FOUND)
- mark_as_advanced(wamr_FOUND wamr_LIBRARY)
- set(wamr_INCLUDE_DIRS ${wamr_INCLUDE_DIR})
- set(wamr_LIBRARY ${iwasm_LIBRARY})
+if(wasmtime_FOUND)
+ mark_as_advanced(wasmtime_FOUND wasmtime_LIBRARY)
+ set(wasmtime_INCLUDE_DIRS ${wasmtime_INCLUDE_DIR})
+ set(wasmtime_LIBRARY ${lwasmtime_LIBRARY})
endif()
-if(wamr_FOUND AND NOT TARGET wamr::wamr)
- add_library(wamr::wamr INTERFACE IMPORTED)
- target_include_directories(wamr::wamr INTERFACE ${wamr_INCLUDE_DIRS})
- target_link_libraries(wamr::wamr INTERFACE ${wamr_LIBRARY})
+if(wasmtime_FOUND AND NOT TARGET wasmtime::wasmtime)
+ add_library(wasmtime::wasmtime INTERFACE IMPORTED)
+ target_include_directories(wasmtime::wasmtime INTERFACE ${wasmtime_INCLUDE_DIRS})
+ target_link_libraries(wasmtime::wasmtime INTERFACE ${wasmtime_LIBRARY})
endif()
diff --git a/doc/admin-guide/plugins/wasm.en.rst b/doc/admin-guide/plugins/wasm.en.rst
index 0e58777285..459318490e 100644
--- a/doc/admin-guide/plugins/wasm.en.rst
+++ b/doc/admin-guide/plugins/wasm.en.rst
@@ -39,11 +39,11 @@ How it Works
The plugin uses the library and header files from the Proxy-Wasm project.
-* https://github.com/proxy-wasm/proxy-wasm-cpp-host/tree/b7e690703c7f26707438a2f1ebd7c197bc8f0296
+* https://github.com/proxy-wasm/proxy-wasm-cpp-host/tree/c4d7bb0fda912e24c64daf2aa749ec54cec99412
* https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/tree/fd0be8405db25de0264bdb78fae3a82668c03782
-Proxy-Wasm in turn uses an underlying WebAssembly runtime to execute the WebAssembly module. (Currently only WAMR and
-WasmEdge are supported)
+Proxy-Wasm in turn uses an underlying WebAssembly runtime to execute the WebAssembly module. (Currently only WAMR,
+Wasmtime and WasmEdge are supported)
The plugin creates a root context when ATS starts and a new context will be created out of the root context for each
transaction. ATS plugin events will trigger the corresponding functions in the WebAssembly module to be executed through
@@ -61,9 +61,9 @@ Compiling the Plugin
::
- wget https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-1.2.1.tar.gz
- tar zxvf WAMR-1.2.1.tar.gz
- cd wasm-micro-runtime-WAMR-1.2.1
+ wget https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-2.1.1.tar.gz
+ tar zxvf WAMR-2.1.1.tar.gz
+ cd wasm-micro-runtime-WAMR-2.1.1
cp core/iwasm/include/* /usr/local/include/
cd product-mini/platforms/linux
mkdir build
@@ -78,16 +78,13 @@ Compiling the Plugin
git clone https://github.com/bytecodealliance/wasmtime.git
cd wasmtime/
- git checkout release-9.0.0
+ git checkout release-24.0.0
git submodule update --init
cargo build
cargo build --release --manifest-path crates/c-api/Cargo.toml
sudo cp target/release/libwasmtime.so /usr/local/lib
- wget https://github.com/WebAssembly/wasm-c-api/archive/c9d31284651b975f05ac27cee0bab1377560b87e.tar.gz
- tar zxvf c9d31284651b975f05ac27cee0bab1377560b87e.tar.gz
- cd wasm-c-api-c9d31284651b975f05ac27cee0bab1377560b87e/
- sudo mkdir /usr/local/include/include/
- sudo cp include/wasm.h /usr/local/include/include/
+ sudo mkdir -p /usr/local/include/crates/c-api/include/
+ sudo cp crates/c-api/include/wasm.h /usr/local/include/crates/c-api/include/
**Install WasmEdge**
diff --git a/plugins/experimental/CMakeLists.txt b/plugins/experimental/CMakeLists.txt
index bec349b33d..38b01049b5 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/CMakeLists.txt
@@ -116,6 +116,9 @@ endif()
if(BUILD_URL_SIG)
add_subdirectory(url_sig)
endif()
-if(BUILD_WASM)
+if(BUILD_WASM_WAMR
+ OR BUILD_WASM_WASMTIME
+ OR BUILD_WASM_WASMEDGE
+)
add_subdirectory(wasm)
endif()
diff --git a/plugins/experimental/wasm/CMakeLists.txt b/plugins/experimental/wasm/CMakeLists.txt
index d5ae90cbd6..0cccbc2082 100644
--- a/plugins/experimental/wasm/CMakeLists.txt
+++ b/plugins/experimental/wasm/CMakeLists.txt
@@ -18,5 +18,26 @@
add_subdirectory(lib)
add_atsplugin(wasm ats_context.cc ats_wasm.cc wasm_main.cc)
-target_link_libraries(wasm PRIVATE wasmlib wamr::wamr)
+
+set(WASM_RUNTIME wasmlib)
+if(wamr_FOUND)
+ list(APPEND WASM_RUNTIME wamr::wamr)
+elseif(wasmtime_FOUND)
+ list(APPEND WASM_RUNTIME wasmtime::wasmtime)
+endif()
+if(wasmedge_FOUND)
+ list(APPEND WASM_RUNTIME wasmedge::wasmedge)
+endif()
+
+target_link_libraries(wasm PRIVATE ${WASM_RUNTIME})
+
+if(wamr_FOUND)
+ target_compile_options(wasm PRIVATE -DWAMR)
+elseif(wasmtime_FOUND)
+ target_compile_options(wasm PRIVATE -DWASMTIME)
+endif()
+if(wasmedge_FOUND)
+ target_compile_options(wasm PRIVATE -DWASMEDGE)
+endif()
+
verify_global_plugin(wasm)
diff --git a/plugins/experimental/wasm/lib/CMakeLists.txt b/plugins/experimental/wasm/lib/CMakeLists.txt
index be158adcad..f838461d7b 100644
--- a/plugins/experimental/wasm/lib/CMakeLists.txt
+++ b/plugins/experimental/wasm/lib/CMakeLists.txt
@@ -29,6 +29,11 @@ set(CC_FILES
)
if(wamr_FOUND)
list(APPEND CC_FILES src/wamr/wamr.cc)
+elseif(wasmtime_FOUND)
+ list(APPEND CC_FILES src/wasmtime/wasmtime.cc)
+endif()
+if(wasmedge_FOUND)
+ list(APPEND CC_FILES src/wasmedge/wasmedge.cc)
endif()
add_library(wasmlib STATIC ${CC_FILES})
@@ -36,6 +41,11 @@ target_compile_options(wasmlib PUBLIC -Wno-unused-parameter)
if(wamr_FOUND)
target_compile_options(wasmlib PRIVATE -Wno-missing-field-initializers)
target_link_libraries(wasmlib PUBLIC wamr::wamr)
+elseif(wasmtime_FOUND)
+ target_link_libraries(wasmlib PUBLIC wasmtime::wasmtime)
+endif()
+if(wasmedge_FOUND)
+ target_link_libraries(wasmlib PUBLIC wasmedge::wasmedge)
endif()
target_include_directories(wasmlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/plugins/experimental/wasm/lib/README.proxy-wasm-cpp-host.md b/plugins/experimental/wasm/lib/README.proxy-wasm-cpp-host.md
index 8cb5694ee8..bd198e7236 100644
--- a/plugins/experimental/wasm/lib/README.proxy-wasm-cpp-host.md
+++ b/plugins/experimental/wasm/lib/README.proxy-wasm-cpp-host.md
@@ -1 +1,5 @@
# WebAssembly for Proxies (C++ host implementation)
+
+## How to Contribute
+
+See [CONTRIBUTING](CONTRIBUTING.md).
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/context.h b/plugins/experimental/wasm/lib/include/proxy-wasm/context.h
index ab99cad70a..12937041f4 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/context.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/context.h
@@ -26,13 +26,11 @@
#include <string_view>
#include <vector>
+#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/context_interface.h"
namespace proxy_wasm {
-#include "proxy_wasm_common.h"
-#include "proxy_wasm_enums.h"
-
class PluginHandleBase;
class WasmBase;
class WasmVm;
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/context_interface.h b/plugins/experimental/wasm/lib/include/proxy-wasm/context_interface.h
index 81973eed2b..48fce76d9e 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/context_interface.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/context_interface.h
@@ -25,10 +25,9 @@
#include <memory>
#include <vector>
-namespace proxy_wasm {
+#include "include/proxy-wasm/sdk.h"
-#include "proxy_wasm_common.h"
-#include "proxy_wasm_enums.h"
+namespace proxy_wasm {
using Pairs = std::vector<std::pair<std::string_view, std::string_view>>;
using PairsWithStringValues = std::vector<std::pair<std::string_view, std::string>>;
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/exports.h b/plugins/experimental/wasm/lib/include/proxy-wasm/exports.h
index 376a4d3b60..91c51150c4 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/exports.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/exports.h
@@ -139,10 +139,13 @@ Word wasi_unstable_fd_read(Word, Word, Word, Word);
Word wasi_unstable_fd_seek(Word, int64_t, Word, Word);
Word wasi_unstable_fd_close(Word);
Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut);
+Word wasi_unstable_fd_fdstat_set_flags(Word fd, Word flags);
Word wasi_unstable_environ_get(Word, Word);
Word wasi_unstable_environ_sizes_get(Word count_ptr, Word buf_size_ptr);
Word wasi_unstable_args_get(Word argc_ptr, Word argv_buf_size_ptr);
Word wasi_unstable_args_sizes_get(Word argc_ptr, Word argv_buf_size_ptr);
+Word wasi_unstable_sched_yield();
+Word wasi_unstable_poll_oneoff(Word in, Word out, Word nsubscriptions, Word nevents);
void wasi_unstable_proc_exit(Word);
Word wasi_unstable_clock_time_get(Word, uint64_t, Word);
Word wasi_unstable_random_get(Word, Word);
@@ -170,9 +173,10 @@ void emscripten_notify_memory_growth(Word);
_f(continue_stream) _f(close_stream) _f(get_log_level)
#define FOR_ALL_WASI_FUNCTIONS(_f) \
- _f(fd_write) _f(fd_read) _f(fd_seek) _f(fd_close) _f(fd_fdstat_get) _f(environ_get) \
- _f(environ_sizes_get) _f(args_get) _f(args_sizes_get) _f(clock_time_get) _f(random_get) \
- _f(proc_exit) _f(path_open) _f(fd_prestat_get) _f(fd_prestat_dir_name)
+ _f(fd_write) _f(fd_read) _f(fd_seek) _f(fd_close) _f(fd_fdstat_get) _f(fd_fdstat_set_flags) \
+ _f(environ_get) _f(environ_sizes_get) _f(args_get) _f(args_sizes_get) _f(clock_time_get) \
+ _f(random_get) _f(sched_yield) _f(poll_oneoff) _f(proc_exit) _f(path_open) \
+ _f(fd_prestat_get) _f(fd_prestat_dir_name)
// Helpers to generate a stub to pass to VM, in place of a restricted proxy-wasm capability.
#define _CREATE_PROXY_WASM_STUB(_fn) \
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/pairs_util.h b/plugins/experimental/wasm/lib/include/proxy-wasm/pairs_util.h
index 54df2fd886..019c970bae 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/pairs_util.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/pairs_util.h
@@ -15,6 +15,7 @@
#pragma once
+#include <cstddef>
#include <string>
#include <string_view>
#include <vector>
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/sdk.h b/plugins/experimental/wasm/lib/include/proxy-wasm/sdk.h
new file mode 100644
index 0000000000..1058543731
--- /dev/null
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/sdk.h
@@ -0,0 +1,50 @@
+// Copyright 2016-2019 Envoy Project Authors
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include <string>
+#include <cstdint>
+
+namespace proxy_wasm {
+
+namespace internal {
+
+// isolate those includes to prevent ::proxy_wasm namespace pollution with std
+// namespace definitions.
+#include "proxy_wasm_common.h"
+#include "proxy_wasm_enums.h"
+
+} // namespace internal
+
+// proxy_wasm_common.h
+using WasmResult = internal::WasmResult;
+using WasmHeaderMapType = internal::WasmHeaderMapType;
+using WasmBufferType = internal::WasmBufferType;
+using WasmBufferFlags = internal::WasmBufferFlags;
+using WasmStreamType = internal::WasmStreamType;
+
+// proxy_wasm_enums.h
+using LogLevel = internal::LogLevel;
+using FilterStatus = internal::FilterStatus;
+using FilterHeadersStatus = internal::FilterHeadersStatus;
+using FilterMetadataStatus = internal::FilterMetadataStatus;
+using FilterTrailersStatus = internal::FilterTrailersStatus;
+using FilterDataStatus = internal::FilterDataStatus;
+using GrpcStatus = internal::GrpcStatus;
+using MetricType = internal::MetricType;
+using CloseType = internal::CloseType;
+
+} // namespace proxy_wasm
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/vm_id_handle.h b/plugins/experimental/wasm/lib/include/proxy-wasm/vm_id_handle.h
index 547eca229e..16ebb4bf03 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/vm_id_handle.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/vm_id_handle.h
@@ -15,8 +15,10 @@
#pragma once
#include <functional>
-#include <mutex>
#include <memory>
+#include <mutex>
+#include <string>
+#include <string_view>
#include <unordered_map>
namespace proxy_wasm {
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm.h b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm.h
index 1a785a8f9a..9fa2bda1f1 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm.h
@@ -24,6 +24,7 @@
#include <unordered_map>
#include <unordered_set>
+#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/context.h"
#include "include/proxy-wasm/exports.h"
#include "include/proxy-wasm/wasm_vm.h"
@@ -31,8 +32,6 @@
namespace proxy_wasm {
-#include "proxy_wasm_common.h"
-
class ContextBase;
class WasmHandleBase;
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_api_impl.h b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_api_impl.h
index 8bd9626ff7..899af7e415 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_api_impl.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_api_impl.h
@@ -30,15 +30,13 @@
#include <utility>
#include <vector>
+#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/exports.h"
#include "include/proxy-wasm/word.h"
namespace proxy_wasm {
namespace null_plugin {
-#include "proxy_wasm_enums.h"
-#include "proxy_wasm_common.h"
-
#define WS(_x) Word(static_cast<uint64_t>(_x))
#define WR(_x) Word(reinterpret_cast<uint64_t>(_x))
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_vm.h b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_vm.h
index acf0ccf3bc..a573212e00 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_vm.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/wasm_vm.h
@@ -19,16 +19,16 @@
#include <memory>
#include <optional>
#include <string>
+#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include "include/proxy-wasm/sdk.h"
#include "include/proxy-wasm/word.h"
namespace proxy_wasm {
-#include "proxy_wasm_enums.h"
-
class ContextBase;
// These are templates and its helper for constructing signatures of functions calling into Wasm
diff --git a/plugins/experimental/wasm/lib/include/proxy-wasm/word.h b/plugins/experimental/wasm/lib/include/proxy-wasm/word.h
index 90ea932df2..bc0d23a8cb 100644
--- a/plugins/experimental/wasm/lib/include/proxy-wasm/word.h
+++ b/plugins/experimental/wasm/lib/include/proxy-wasm/word.h
@@ -17,9 +17,9 @@
#include <iostream>
-namespace proxy_wasm {
+#include "include/proxy-wasm/sdk.h"
-#include "proxy_wasm_common.h"
+namespace proxy_wasm {
// Use byteswap functions only when compiling for big-endian platforms.
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
diff --git a/plugins/experimental/wasm/lib/src/exports.cc b/plugins/experimental/wasm/lib/src/exports.cc
index 0290dcf0ff..25ca06c9d4 100644
--- a/plugins/experimental/wasm/lib/src/exports.cc
+++ b/plugins/experimental/wasm/lib/src/exports.cc
@@ -646,6 +646,9 @@ Word grpc_send(Word token, Word message_ptr, Word message_size, Word end_stream)
return context->grpcSend(token, message.value(), end_stream != 0U);
}
+// WASIp1 typings in comments sourced from
+// https://github.com/WebAssembly/wasi-libc/blob/446cb3f1aa21f9b1a1eab372f82d65d19003e924/libc-bottom-half/headers/public/wasi/api.h
+
// __wasi_errno_t path_open(__wasi_fd_t fd, __wasi_lookupflags_t dirflags, const char *path,
// size_t path_len, __wasi_oflags_t oflags, __wasi_rights_t fs_rights_base, __wasi_rights_t
// fs_rights_inheriting, __wasi_fdflags_t fdflags, __wasi_fd_t *retptr0)
@@ -776,6 +779,13 @@ Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut) {
return 0; // __WASI_ESUCCESS
}
+// __wasi_errno_t __wasi_fd_fdstat_set_flags(__wasi_fd_t fd, __wasi_fdflags_t flags)
+Word wasi_unstable_fd_fdstat_set_flags(Word /*fd*/, Word /*flags*/) {
+ // Flags that can be specified: append, dsync, nonblock, rsync, and sync. Proxy-wasm only supports
+ // STDOUT and STDERR, but none of these flags have any effect in Proxy-Wasm.
+ return 52; // __WASI_ERRNO_ENOSYS
+}
+
// __wasi_errno_t __wasi_environ_get(char **environ, char *environ_buf);
Word wasi_unstable_environ_get(Word environ_array_ptr, Word environ_buf) {
auto *context = contextOrEffectiveContext();
@@ -879,6 +889,21 @@ Word wasi_unstable_random_get(Word result_buf_ptr, Word buf_len) {
return 0; // __WASI_ESUCCESS
}
+// __wasi_errno_t __wasi_sched_yield()
+Word wasi_unstable_sched_yield() {
+ // Per POSIX man pages, it is valid to return success if the calling thread is the only thread in
+ // the highest priority list. This is vacuously true for wasm without threads. There are no valid
+ // error cases defined.
+ return 0; // __WASI_ESUCCESS
+}
+
+// __wasi_errno_t __wasi_poll_oneoff(const __wasi_subscription_t *in, __wasi_event_t *out,
+// __wasi_size_t nsubscriptions, __wasi_size_t *nevents)
+Word wasi_unstable_poll_oneoff(Word /*in*/, Word /*out*/, Word /*nsubscriptions*/,
+ Word /*nevents_ptr*/) {
+ return 52; // __WASI_ERRNO_ENOSYS
+}
+
// void __wasi_proc_exit(__wasi_exitcode_t rval);
void wasi_unstable_proc_exit(Word /*exit_code*/) {
auto *context = contextOrEffectiveContext();
diff --git a/plugins/experimental/wasm/lib/src/wamr/wamr.cc b/plugins/experimental/wasm/lib/src/wamr/wamr.cc
index ea3d140e7d..482a59bf1b 100644
--- a/plugins/experimental/wasm/lib/src/wamr/wamr.cc
+++ b/plugins/experimental/wasm/lib/src/wamr/wamr.cc
@@ -56,7 +56,8 @@ public:
Wamr() = default;
std::string_view getEngineName() override { return "wamr"; }
- std::string_view getPrecompiledSectionName() override { return ""; }
+ // must use the exact name given by test-tools/append-aot-to-wasm/append_aot_to_wasm.py
+ std::string_view getPrecompiledSectionName() override { return "wamr-aot"; }
Cloneable cloneable() override { return Cloneable::CompiledBytecode; }
std::unique_ptr<WasmVm> clone() override;
@@ -118,18 +119,32 @@ private:
std::unordered_map<std::string, WasmFuncPtr> module_functions_;
};
-bool Wamr::load(std::string_view bytecode, std::string_view /*precompiled*/,
+bool Wamr::load(std::string_view bytecode, std::string_view precompiled,
const std::unordered_map<uint32_t, std::string> & /*function_names*/) {
store_ = wasm_store_new(engine());
if (store_ == nullptr) {
return false;
}
- wasm_byte_vec_t binary = {.size = bytecode.size(),
- .data = (char *)bytecode.data(),
- .num_elems = bytecode.size(),
- .size_of_elem = sizeof(byte_t),
- .lock = nullptr};
+ wasm_byte_vec_t binary = {0};
+ if (precompiled.empty()) {
+ binary.size = bytecode.size();
+ binary.data = const_cast<char *>(bytecode.data());
+ binary.num_elems = bytecode.size();
+ binary.size_of_elem = sizeof(byte_t);
+ binary.lock = nullptr;
+ } else {
+ // skip leading paddings
+ auto padding_count = static_cast<uint8_t>(precompiled[0]);
+ precompiled.remove_prefix(padding_count + 1);
+
+ binary.size = precompiled.size();
+ binary.data = const_cast<char *>(precompiled.data());
+ binary.num_elems = precompiled.size();
+ binary.size_of_elem = sizeof(byte_t);
+ binary.lock = nullptr;
+ }
+
module_ = wasm_module_new(store_.get(), &binary);
if (module_ == nullptr) {
return false;
@@ -224,8 +239,8 @@ static const char *printValKind(wasm_valkind_t kind) {
return "f32";
case WASM_F64:
return "f64";
- case WASM_ANYREF:
- return "anyref";
+ case WASM_EXTERNREF:
+ return "externref";
case WASM_FUNCREF:
return "funcref";
default:
diff --git a/plugins/experimental/wasm/lib/src/wasm.cc b/plugins/experimental/wasm/lib/src/wasm.cc
index cb1dd9b3ac..e8a7ce4366 100644
--- a/plugins/experimental/wasm/lib/src/wasm.cc
+++ b/plugins/experimental/wasm/lib/src/wasm.cc
@@ -394,7 +394,10 @@ void WasmBase::startVm(ContextBase *root_context) {
// time
"wasi_unstable.clock_time_get", "wasi_snapshot_preview1.clock_time_get",
// random
- "wasi_unstable.random_get", "wasi_snapshot_preview1.random_get"});
+ "wasi_unstable.random_get", "wasi_snapshot_preview1.random_get",
+ // Go runtime initialization
+ "wasi_unstable.fd_fdstat_get", "wasi_snapshot_preview1.fd_fdstat_get",
+ "wasi_unstable.fd_fdstat_set_flags", "wasi_snapshot_preview1.fd_fdstat_set_flags"});
if (_initialize_) {
// WASI reactor.
_initialize_(root_context);
diff --git a/plugins/experimental/wasm/lib/src/wasmtime/types.h b/plugins/experimental/wasm/lib/src/wasmtime/types.h
index 4ab725c04f..14fe750530 100644
--- a/plugins/experimental/wasm/lib/src/wasmtime/types.h
+++ b/plugins/experimental/wasm/lib/src/wasmtime/types.h
@@ -13,7 +13,7 @@
// limitations under the License.
#include "src/common/types.h"
-#include "include/wasm.h"
+#include "crates/c-api/include/wasm.h"
namespace proxy_wasm::wasmtime {
diff --git a/plugins/experimental/wasm/lib/src/wasmtime/wasmtime.cc b/plugins/experimental/wasm/lib/src/wasmtime/wasmtime.cc
index 2cfc21888f..c4a7646f0e 100644
--- a/plugins/experimental/wasm/lib/src/wasmtime/wasmtime.cc
+++ b/plugins/experimental/wasm/lib/src/wasmtime/wasmtime.cc
@@ -26,7 +26,7 @@
#include "src/wasmtime/types.h"
-#include "include/wasm.h"
+#include "crates/c-api/include/wasm.h"
namespace proxy_wasm {
namespace wasmtime {
@@ -215,8 +215,8 @@ static const char *printValKind(wasm_valkind_t kind) {
return "f32";
case WASM_F64:
return "f64";
- case WASM_ANYREF:
- return "anyref";
+ case WASM_EXTERNREF:
+ return "externref";
case WASM_FUNCREF:
return "funcref";
default:
(trafficserver) 07/07: Reset write lock state to init after closing write (#12215)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 7c83a7d004528631bb760a88146d44236cec35ef
Author: JosiahWI <41...@users.noreply.github.com>
AuthorDate: Mon May 12 19:37:06 2025 -0500
Reset write lock state to init after closing write (#12215)
This commit mitigates the crash reported in #11700. That crash happens when
a redirect is issued on a state machine that has already cached a response
and closed the cache write VC.
After this patch, the state machine will likely open a new cache VC to cache
the response from the origin it was redirected to. We will refer to the
original origin as A, and the origin the state machine was redirected to after
the response from A as B.
We have not yet reproduced this locally - the exact sequence of events that
gets the state machine into this state are still unknown.
(cherry picked from commit 5c0aaf2f9578506089c166b017a5b1c1973f9846)
---
src/proxy/http/HttpSM.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index 051b001386..bba5a4da65 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -6460,6 +6460,7 @@ HttpSM::perform_cache_write_action()
// Write close deletes the old alternate
cache_sm.close_write();
cache_sm.close_read();
+ t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;
break;
}
@@ -6518,6 +6519,7 @@ HttpSM::issue_cache_update()
}
// Now close the write which commits the update
cache_sm.close_write();
+ t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;
}
int
(trafficserver) 01/07: cachekey doc: --include-headers matched case insensitively (#12235)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 16c45483881a9c1206eb9ee7abd8132d084b23b6
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Mon May 12 11:39:54 2025 -0500
cachekey doc: --include-headers matched case insensitively (#12235)
Update the cachekey doc to indicate that the HTTP field name list
provided to --include-headers are matched case insensitively.
(cherry picked from commit bfcb25e061a87c9bd09f44c87e59419efa4194f3)
---
doc/admin-guide/plugins/cachekey.en.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/admin-guide/plugins/cachekey.en.rst b/doc/admin-guide/plugins/cachekey.en.rst
index 713d2667d4..0aeb866f02 100644
--- a/doc/admin-guide/plugins/cachekey.en.rst
+++ b/doc/admin-guide/plugins/cachekey.en.rst
@@ -140,7 +140,7 @@ Cache key structure and related plugin parameters
optional components | └───────────────────┴───────────────────┘
configured |
-* ``--include-headers`` (default: empty list) - comma separated list of headers to be added to the `cache key`. The list of headers defined by ``--include-headers`` are always sorted before adding them to the `cache key`.
+* ``--include-headers`` (default: empty list) - comma separated list of headers to be added to the `cache key`. The list of headers defined by ``--include-headers`` are always sorted before adding them to the `cache key`. These header field names are matched case insensitively.
* ``--capture-header=<headername>:<capture_definition>`` (default: empty) - captures elements from header <headername> using <capture_definition> and adds them to the `cache key`.
(trafficserver) 03/07: Update SNI for origin side connections (#12231)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 82e627fa03b5acf39ac6cdf25a244dbbd19000eb
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Mon May 12 17:21:52 2025 -0500
Update SNI for origin side connections (#12231)
Origin side connection pooling was not able to access the appropriate
SNI of those connections, resulting in those connections not being able
to be reused appropriately. This addresses that issue by setting the
internal SNI buffer for those connections to the appropriate SNI so that
the origin conection pooling feature has access to the SNI value.
This also populates the SNI buffer when an SSLNetVConnection is bound to
an SSL object.
Fixes: #12214
(cherry picked from commit c9a433daf94b28b653f3948ab1c856cce8a47d9b)
---
include/iocore/net/TLSSNISupport.h | 24 +++++++++++++++++++++++-
src/iocore/net/SSLNetVConnection.cc | 2 +-
src/iocore/net/TLSSNISupport.cc | 27 ++++++++++++++++++++++++---
3 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/include/iocore/net/TLSSNISupport.h b/include/iocore/net/TLSSNISupport.h
index fbba3810d5..6897cce36a 100644
--- a/include/iocore/net/TLSSNISupport.h
+++ b/include/iocore/net/TLSSNISupport.h
@@ -58,9 +58,31 @@ public:
int perform_sni_action(SSL &ssl);
// Callback functions for OpenSSL libraries
+
+ /** Process a CLIENT_HELLO from a client.
+ *
+ * This is for client-side connections.
+ */
void on_client_hello(ClientHello &client_hello);
+
+ /** Process the servername extension when a client uses one in the TLS handshake.
+ *
+ * This is for client-side connections.
+ */
void on_servername(SSL *ssl, int *al, void *arg);
+ /** Set the servername extension for server-side connections.
+ *
+ * This is for server-side connections.
+ * This calls SSL_set_tlsext_host_name() to set the servername extension.
+ *
+ * @param ssl The SSL object upon which the servername extension is set.
+ * @param name The servername to set. This is assumed to be a non-empty,
+ * null-terminated string.
+ * @return True if the servername was set successfully, false otherwise.
+ */
+ bool set_sni_server_name(SSL *ssl, char const *name);
+
/**
* Get the server name in SNI
*
@@ -92,5 +114,5 @@ private:
// Null-terminated string, or nullptr if there is no SNI server name.
std::unique_ptr<char[]> _sni_server_name;
- void _set_sni_server_name(std::string_view name);
+ void _set_sni_server_name_buffer(std::string_view name);
};
diff --git a/src/iocore/net/SSLNetVConnection.cc b/src/iocore/net/SSLNetVConnection.cc
index 18c1850cd3..0b719e460d 100644
--- a/src/iocore/net/SSLNetVConnection.cc
+++ b/src/iocore/net/SSLNetVConnection.cc
@@ -1146,7 +1146,7 @@ SSLNetVConnection::sslStartHandShake(int event, int &err)
// SNI
ats_scoped_str &tlsext_host_name = this->options.sni_hostname ? this->options.sni_hostname : this->options.sni_servername;
if (tlsext_host_name) {
- if (SSL_set_tlsext_host_name(this->ssl, tlsext_host_name)) {
+ if (this->set_sni_server_name(this->ssl, tlsext_host_name)) {
Dbg(dbg_ctl_ssl, "using SNI name '%s' for client handshake", tlsext_host_name.get());
} else {
Dbg(dbg_ctl_ssl_error, "failed to set SNI name '%s' for client handshake", tlsext_host_name.get());
diff --git a/src/iocore/net/TLSSNISupport.cc b/src/iocore/net/TLSSNISupport.cc
index 18c7d0deab..ee5e4a8c44 100644
--- a/src/iocore/net/TLSSNISupport.cc
+++ b/src/iocore/net/TLSSNISupport.cc
@@ -54,6 +54,12 @@ void
TLSSNISupport::bind(SSL *ssl, TLSSNISupport *snis)
{
SSL_set_ex_data(ssl, _ex_data_index, snis);
+ char const *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+ if (servername) {
+ snis->_set_sni_server_name_buffer(servername);
+ } else {
+ snis->_clear();
+ }
}
void
@@ -118,7 +124,7 @@ TLSSNISupport::on_client_hello(ClientHello &client_hello)
}
}
if (servername) {
- this->_set_sni_server_name(std::string_view(servername, len));
+ this->_set_sni_server_name_buffer(std::string_view(servername, len));
}
}
@@ -127,8 +133,23 @@ TLSSNISupport::on_servername(SSL *ssl, int * /* al ATS_UNUSED */, void * /* arg
{
const char *name = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
if (name) {
- this->_set_sni_server_name(name);
+ this->_set_sni_server_name_buffer(name);
+ }
+}
+
+bool
+TLSSNISupport::set_sni_server_name(SSL *ssl, char const *name)
+{
+ if (name == nullptr || strnlen(name, 256) == 0) {
+ Dbg(dbg_ctl_ssl_sni, "Empty servername provided, not setting SNI");
+ return false;
+ }
+ if (SSL_set_tlsext_host_name(ssl, name) != 1) {
+ Dbg(dbg_ctl_ssl_sni, "SSL_set_tlsext_host_name failed to set %s", name);
+ return false;
}
+ this->_set_sni_server_name_buffer(name);
+ return true;
}
void
@@ -144,7 +165,7 @@ TLSSNISupport::get_sni_server_name() const
}
void
-TLSSNISupport::_set_sni_server_name(std::string_view name)
+TLSSNISupport::_set_sni_server_name_buffer(std::string_view name)
{
if (name.size()) {
char *n = new char[name.size() + 1];
(trafficserver) 02/07: revert #10996 move session pool metrics outside critical section (#12233)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 23e70742f74f0e95b3dae96b6691b7cfbafeb3cc
Author: Brian Olsen <br...@comcast.com>
AuthorDate: Mon May 12 12:59:48 2025 -0600
revert #10996 move session pool metrics outside critical section (#12233)
Co-authored-by: Brian Olsen <bo...@comcast.com>
(cherry picked from commit 71ff1ec5cecc871d6d0db7163b6a550e5f737c94)
---
src/proxy/http/HttpSessionManager.cc | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/proxy/http/HttpSessionManager.cc b/src/proxy/http/HttpSessionManager.cc
index a3177b3453..6f7ad10368 100644
--- a/src/proxy/http/HttpSessionManager.cc
+++ b/src/proxy/http/HttpSessionManager.cc
@@ -441,7 +441,6 @@ HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostn
{
PoolableSession *to_return = nullptr;
HSMresult_t retval = HSM_NOT_FOUND;
- bool acquired = false;
// Extend the mutex window until the acquired Server session is attached
// to the SM. Releasing the mutex before that results in race conditions
@@ -458,12 +457,10 @@ HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostn
if (locked) {
if (TS_SERVER_SESSION_SHARING_POOL_THREAD == pool_type) {
- retval = ethread->server_session_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
- acquired = (HSM_DONE == retval);
+ retval = ethread->server_session_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
Dbg(dbg_ctl_http_ss, "[acquire session] thread pool search %s", to_return ? "successful" : "failed");
} else {
- retval = m_g_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
- acquired = (HSM_DONE == retval);
+ retval = m_g_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
Dbg(dbg_ctl_http_ss, "[acquire session] global pool search %s", to_return ? "successful" : "failed");
// At this point to_return has been removed from the pool. Do we need to move it
// to the same thread?
@@ -517,10 +514,6 @@ HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostn
}
}
- if (acquired) {
- Metrics::Gauge::decrement(http_rsb.pooled_server_connections);
- }
-
return retval;
}
@@ -552,10 +545,6 @@ HttpSessionManager::release_session(PoolableSession *to_release)
}
}
- if (released_p) {
- Metrics::Gauge::increment(http_rsb.pooled_server_connections);
- }
-
return released_p ? HSM_DONE : HSM_RETRY;
}
@@ -576,6 +565,8 @@ ServerSessionPool::removeSession(PoolableSession *to_remove)
Dbg(dbg_ctl_http_ss, "After Remove session %p m_fqdn_pool size=%zu m_ip_pool_size=%zu", to_remove, m_fqdn_pool.count(),
m_ip_pool.count());
}
+
+ Metrics::Gauge::decrement(http_rsb.pooled_server_connections);
}
void
@@ -592,4 +583,6 @@ ServerSessionPool::addSession(PoolableSession *ss)
ats_ip_nptop(ss->get_remote_addr(), peer_ip, sizeof(peer_ip));
Dbg(dbg_ctl_http_ss, "[%" PRId64 "] [add session] session placed into shared pool under ip %s", ss->connection_id(), peer_ip);
}
+
+ Metrics::Gauge::increment(http_rsb.pooled_server_connections);
}
(trafficserver) 04/07: XPACK: Inspect _start_expanding_capacity before expanding (#12228)
Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 332fdbfce9d59b802e3886049fb08d6367de6d68
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Wed May 7 16:18:16 2025 -0500
XPACK: Inspect _start_expanding_capacity before expanding (#12228)
While expanding XPACK storage, crashes were happening with _old_data
being nullptr. This will likely be fixed by checking the result of
_start_expanding_capacity before trying to expand capacity.
Fixes: #12225
(cherry picked from commit 50c7470e5ab05f050b283cecbd76b4db54fdc41e)
---
include/proxy/hdrs/XPACK.h | 15 ++++++++++++++-
src/proxy/hdrs/XPACK.cc | 7 +++++--
src/proxy/hdrs/unit_tests/test_XPACK.cc | 7 +++++++
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/include/proxy/hdrs/XPACK.h b/include/proxy/hdrs/XPACK.h
index da41b069f9..8a6cd1011c 100644
--- a/include/proxy/hdrs/XPACK.h
+++ b/include/proxy/hdrs/XPACK.h
@@ -165,7 +165,7 @@ public:
/** Begin the storage expansion phase to the @a new_max_size. */
ExpandCapacityContext(XpackDynamicTableStorage &storage, uint32_t new_max_size) : _storage{storage}
{
- this->_storage._start_expanding_capacity(new_max_size);
+ this->_ok_to_expand = this->_storage._start_expanding_capacity(new_max_size);
}
/** End the storage expansion phase, cleaning up the old storage memory. */
~ExpandCapacityContext() { this->_storage._finish_expanding_capacity(); }
@@ -183,8 +183,21 @@ public:
*/
uint32_t copy_field(uint32_t old_offset, uint32_t len);
+ /** Indicate whether the expansion should proceed.
+ * Return whether @a _storage indicates that the new max size is valid for
+ * expanding the storage. If not, the expansion should not proceed.
+ *
+ * @return true if the new size is valid, false otherwise.
+ */
+ bool
+ ok_to_expand() const
+ {
+ return this->_ok_to_expand;
+ }
+
private:
XpackDynamicTableStorage &_storage;
+ bool _ok_to_expand = false;
};
class XpackDynamicTable
diff --git a/src/proxy/hdrs/XPACK.cc b/src/proxy/hdrs/XPACK.cc
index 6898a36fa9..6d0cde9643 100644
--- a/src/proxy/hdrs/XPACK.cc
+++ b/src/proxy/hdrs/XPACK.cc
@@ -485,8 +485,11 @@ void
XpackDynamicTable::_expand_storage_size(uint32_t new_storage_size)
{
ExpandCapacityContext context{this->_storage, new_storage_size};
- uint32_t i = this->_calc_index(this->_entries_tail, 1);
- uint32_t end = this->_calc_index(this->_entries_head, 1);
+ if (!context.ok_to_expand()) {
+ return;
+ }
+ uint32_t i = this->_calc_index(this->_entries_tail, 1);
+ uint32_t end = this->_calc_index(this->_entries_head, 1);
for (; i != end; i = this->_calc_index(i, 1)) {
auto &entry = this->_entries[i];
entry.offset = context.copy_field(entry.offset, entry.name_len + entry.value_len);
diff --git a/src/proxy/hdrs/unit_tests/test_XPACK.cc b/src/proxy/hdrs/unit_tests/test_XPACK.cc
index a0eace5a5f..a7f3da0e92 100644
--- a/src/proxy/hdrs/unit_tests/test_XPACK.cc
+++ b/src/proxy/hdrs/unit_tests/test_XPACK.cc
@@ -460,6 +460,7 @@ TEST_CASE("XpackDynamicTableStorage", "[xpack]")
uint32_t reoffset2 = 0, reoffset3 = 0, reoffset4 = 0;
{
ExpandCapacityContext context{storage, 200};
+ REQUIRE(context.ok_to_expand());
reoffset2 = context.copy_field(offset2, 50);
// Note that the offsets will now be shifted, starting from 0 now.
REQUIRE(reoffset2 == 0);
@@ -478,4 +479,10 @@ TEST_CASE("XpackDynamicTableStorage", "[xpack]")
storage.read(reoffset4, &name, 25, &value, 25);
REQUIRE(memcmp(name, name4.data(), 25) == 0);
REQUIRE(memcmp(value, value4.data(), 25) == 0);
+
+ // Test shrinking capacity. This should be rejected via ok_to_expand().
+ {
+ ExpandCapacityContext context{storage, 0};
+ REQUIRE(!context.ok_to_expand());
+ } // context goes out of scope and finishes the expansion phase.
}