Skip to content

Commit 0c1385a

Browse files
committed
Merge branch 'main' of https://github.com/envoyproxy/envoy into dev-refactor-dynamic-module-abi
2 parents 17cf2fe + c561059 commit 0c1385a

File tree

39 files changed

+742
-380
lines changed

39 files changed

+742
-380
lines changed

.github/workflows/_run.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ jobs:
240240
if: inputs.diskspace-hack || github.event.repository.private
241241
with:
242242
to_remove: ${{ inputs.diskspace-hack-paths }}
243+
- run: |
244+
mount
245+
df -h
243246
244247
- run: |
245248
sudo mkdir -p /etc/docker

api/tools/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ py_test(
1919
],
2020
# Don't run this by default, since we don't want to force local dependency on Wireshark/tshark,
2121
# will explicitly invoke in CI.
22-
tags = ["manual"],
22+
tags = [
23+
"manual",
24+
"no-remote-exec",
25+
],
2326
visibility = ["//visibility:public"],
2427
deps = [":tap2pcap"],
2528
)

bazel/external/fips_build.bzl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ BUILD_COMMAND = """
55
set -eo pipefail
66
77
# c++
8-
export CC=$(CC)
8+
export CC="$$(realpath $(CC))"
99
# bazel doesnt expose CXX so we have to construct it (or use foreign_cc)
1010
if [[ "%s" == "libc++" ]]; then
1111
export CXXFLAGS="-stdlib=libc++"
12-
export LDFLAGS="-stdlib=libc++ -lc++ -lc++abi -lm -pthread"
12+
export LDFLAGS="-fuse-ld=lld -stdlib=libc++ -lc++ -lc++abi -lm -pthread"
1313
else
1414
export CXXFLAGS=""
15-
export LDFLAGS="-lstdc++ -lm -pthread"
15+
export LDFLAGS="-fuse-ld=lld -lstdc++ -lm -pthread"
1616
fi
1717
1818
# ninja
@@ -56,15 +56,15 @@ set -eo pipefail
5656
SRC_DIR=$$(dirname $(location @fips_ninja//:configure.py))
5757
OUT_FILE=$$(realpath $@)
5858
PYTHON_BIN=$$(realpath $(PYTHON3))
59-
export CC=$(CC)
60-
export CXX=$(CC)
59+
export CC="$$(realpath $(CC))"
60+
export CXX="$$(realpath $(CC))"
6161
# bazel doesnt expose CXX so we have to construct it (or use foreign_cc)
6262
if [[ "%s" == "libc++" ]]; then
6363
export CXXFLAGS="-stdlib=libc++"
64-
export LDFLAGS="-stdlib=libc++ -lc++ -lc++abi -lm -pthread"
64+
export LDFLAGS="-fuse-ld=lld -stdlib=libc++ -lc++ -lc++abi -lm -pthread"
6565
else
6666
export CXXFLAGS=""
67-
export LDFLAGS="-lstdc++ -lm -pthread"
67+
export LDFLAGS="-fuse-ld=lld -lstdc++ -lm -pthread"
6868
fi
6969
cd $$SRC_DIR
7070
OUTPUT=$$(mktemp)

ci/do_ci.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ function bazel_with_collection() {
6868
then
6969
pushd bazel-testlogs
7070
failed_logs=$(grep " /build.*test.log" "${BAZEL_OUTPUT}" | sed -e 's/ \/build.*\/testlogs\/\(.*\)/\1/')
71-
while read -r f; do
72-
cp --parents -f "$f" "${ENVOY_FAILED_TEST_LOGS}"
73-
done <<< "$failed_logs"
74-
popd
71+
if [[ -n "${failed_logs}" ]]; then
72+
while read -r f; do
73+
cp --parents -f "$f" "${ENVOY_FAILED_TEST_LOGS}"
74+
done <<< "$failed_logs"
75+
popd
76+
fi
7577
fi
7678
exit "${BAZEL_STATUS}"
7779
fi
@@ -192,7 +194,7 @@ function bazel_envoy_api_build() {
192194
--//tools/api_proto_plugin:extra_args=api_version:3.7 \
193195
//tools/protoprint:protoprint_test
194196
echo "Validating API structure..."
195-
"${ENVOY_SRCDIR}"/tools/api/validate_structure.py
197+
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/api:validate_structure "${PWD}/api/envoy"
196198
echo "Testing API..."
197199
bazel_with_collection \
198200
test "${BAZEL_BUILD_OPTIONS[@]}" \

ci/format_pre.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CURRENT=configs
5656
bazel "${BAZEL_STARTUP_OPTIONS[@]}" run "${BAZEL_BUILD_OPTIONS[@]}" //configs:example_configs_validation
5757

5858
CURRENT=spelling
59-
"${ENVOY_SRCDIR}/tools/spelling/check_spelling_pedantic.py" --mark check
59+
bazel "${BAZEL_STARTUP_OPTIONS[@]}" run "${BAZEL_BUILD_OPTIONS[@]}" //tools/spelling:check_spelling_pedantic -- --mark check --target_root="$PWD"
6060

6161
CURRENT=check_format
6262
bazel "${BAZEL_STARTUP_OPTIONS[@]}" run "${BAZEL_BUILD_OPTIONS[@]}" //tools/code_format:check_format -- fix --fail_on_diff

docs/root/configuration/http/http_filters/rate_limit_quota_filter.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,37 @@ Rate limit filter :ref:`configuration <envoy_v3_api_msg_extensions.filters.http.
8686
at the virtual host or route levels using the :ref:`RateLimitQuotaOverride <envoy_v3_api_msg_extensions.filters.http.rate_limit_quota.v3.RateLimitQuotaOverride>`
8787
configuration. The more specific configuration fully overrides less specific configuration.
8888

89+
gRPC Status Configuration
90+
-------------------------
91+
92+
The rate limit quota filter supports customizing the response when requests exceed quota limits through the
93+
:ref:`deny_response_settings <envoy_v3_api_field_extensions.filters.http.rate_limit_quota.v3.RateLimitQuotaBucketSettings.deny_response_settings>`
94+
configuration.
95+
96+
For HTTP requests, you can configure the HTTP status code via ``http_status`` (defaults to 429).
97+
98+
For gRPC requests, you can optionally set ``grpc_status`` to specify the exact gRPC status code and message.
99+
If not set, Envoy will derive the gRPC status from the HTTP status code.
100+
101+
**Example: Using default behavior (gRPC status derived from HTTP status)**
102+
103+
.. code-block:: yaml
104+
105+
deny_response_settings:
106+
http_status:
107+
code: 429
108+
109+
**Example: Using explicit gRPC status**
110+
111+
.. code-block:: yaml
112+
113+
deny_response_settings:
114+
http_status:
115+
code: 429
116+
grpc_status:
117+
code: 8 # RESOURCE_EXHAUSTED
118+
message: "Quota exhausted"
119+
89120
Matcher extensions
90121
------------------
91122

source/extensions/dynamic_modules/abi.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,36 @@ void envoy_dynamic_module_on_http_filter_scheduled(
757757
envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
758758
envoy_dynamic_module_type_http_filter_module_ptr filter_module_ptr, uint64_t event_id);
759759

760+
/**
761+
* envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark is called when
762+
* the buffer for the downstream stream goes over the high watermark for a terminal filter. This may
763+
* be called multiple times, in which case envoy_dynamic_module_on_above_write_buffer_low_watermark
764+
* will be called an equal number of times until the write buffer is completely drained below the
765+
* low watermark.
766+
*
767+
* @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
768+
* corresponding HTTP filter.
769+
* @param filter_module_ptr is the pointer to the in-module HTTP filter created by
770+
* envoy_dynamic_module_on_http_filter_new.
771+
*/
772+
void envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark(
773+
envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
774+
envoy_dynamic_module_type_http_filter_module_ptr filter_module_ptr);
775+
776+
/**
777+
* envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark is called when
778+
* any buffer for the response stream goes from over its high watermark to under its low watermark
779+
* for a terminal filter.
780+
*
781+
* @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
782+
* corresponding HTTP filter.
783+
* @param filter_module_ptr is the pointer to the in-module HTTP filter created by
784+
* envoy_dynamic_module_on_http_filter_new.
785+
*/
786+
void envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark(
787+
envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
788+
envoy_dynamic_module_type_http_filter_module_ptr filter_module_ptr);
789+
760790
// -----------------------------------------------------------------------------
761791
// -------------------------------- Callbacks ----------------------------------
762792
// -----------------------------------------------------------------------------

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 = "b8d4d4c79b5f4743fea77f27a84f9a6f7523f97201c113508ccae569888f8be7";
9+
const char* kAbiVersion = "dcd3808436396000e681f7014dda187ca87708995367ea1374e4b3191281cb7c";
1010

1111
#ifdef __cplusplus
1212
} // namespace DynamicModules

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ pub trait HttpFilter<EHF: EnvoyHttpFilter> {
365365
///
366366
/// See [`EnvoyHttpFilter::new_scheduler`] for more details on how to use this.
367367
fn on_scheduled(&mut self, _envoy_filter: &mut EHF, _event_id: u64) {}
368+
369+
/// This is called when the downstream buffer size goes above the high watermark for a
370+
/// terminal filter.
371+
///
372+
/// * `envoy_filter` can be used to interact with the underlying Envoy filter object.
373+
fn on_downstream_above_write_buffer_high_watermark(&mut self, _envoy_filter: &mut EHF) {}
374+
375+
/// This is called when the downstream buffer size goes below the low watermark for a
376+
/// terminal filter.
377+
///
378+
/// * `envoy_filter` can be used to interact with the underlying Envoy filter object.
379+
fn on_downstream_below_write_buffer_low_watermark(&mut self, _envoy_filter: &mut EHF) {}
368380
}
369381

370382
/// An opaque object that represents the underlying Envoy Http filter config. This has one to one
@@ -2148,8 +2160,10 @@ impl EnvoyHttpFilterImpl {
21482160
/// Since this is primarily designed to be used from a different thread than the one
21492161
/// where the [`HttpFilter`] instance was created, it is marked as `Send` so that
21502162
/// the [`Box<dyn EnvoyHttpFilterScheduler>`] can be sent across threads.
2163+
///
2164+
/// It is also safe to be called concurrently, so it is marked as `Sync` as well.
21512165
#[automock]
2152-
pub trait EnvoyHttpFilterScheduler: Send {
2166+
pub trait EnvoyHttpFilterScheduler: Send + Sync {
21532167
/// Commit the scheduled event to the worker thread where [`HttpFilter`] is running.
21542168
///
21552169
/// It accepts an `event_id` which can be used to distinguish different events
@@ -2168,6 +2182,7 @@ struct EnvoyHttpFilterSchedulerImpl {
21682182
}
21692183

21702184
unsafe impl Send for EnvoyHttpFilterSchedulerImpl {}
2185+
unsafe impl Sync for EnvoyHttpFilterSchedulerImpl {}
21712186

21722187
impl Drop for EnvoyHttpFilterSchedulerImpl {
21732188
fn drop(&mut self) {
@@ -2472,6 +2487,26 @@ unsafe extern "C" fn envoy_dynamic_module_on_http_filter_scheduled(
24722487
filter.on_scheduled(&mut EnvoyHttpFilterImpl::new(envoy_ptr), event_id);
24732488
}
24742489

2490+
#[no_mangle]
2491+
unsafe extern "C" fn envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark(
2492+
envoy_ptr: abi::envoy_dynamic_module_type_http_filter_envoy_ptr,
2493+
filter_ptr: abi::envoy_dynamic_module_type_http_filter_module_ptr,
2494+
) {
2495+
let filter = filter_ptr as *mut *mut dyn HttpFilter<EnvoyHttpFilterImpl>;
2496+
let filter = &mut **filter;
2497+
filter.on_downstream_above_write_buffer_high_watermark(&mut EnvoyHttpFilterImpl::new(envoy_ptr));
2498+
}
2499+
2500+
#[no_mangle]
2501+
unsafe extern "C" fn envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark(
2502+
envoy_ptr: abi::envoy_dynamic_module_type_http_filter_envoy_ptr,
2503+
filter_ptr: abi::envoy_dynamic_module_type_http_filter_module_ptr,
2504+
) {
2505+
let filter = filter_ptr as *mut *mut dyn HttpFilter<EnvoyHttpFilterImpl>;
2506+
let filter = &mut **filter;
2507+
filter.on_downstream_below_write_buffer_low_watermark(&mut EnvoyHttpFilterImpl::new(envoy_ptr));
2508+
}
2509+
24752510
impl From<envoy_dynamic_module_type_metrics_result>
24762511
for Result<(), envoy_dynamic_module_type_metrics_result>
24772512
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ absl::StatusOr<Http::FilterFactoryCb> DynamicModuleConfigFactory::createFilterFa
2929
Envoy::Extensions::DynamicModules::HttpFilters::DynamicModuleHttpFilterConfigSharedPtr>
3030
filter_config =
3131
Envoy::Extensions::DynamicModules::HttpFilters::newDynamicModuleHttpFilterConfig(
32-
proto_config.filter_name(), config, std::move(dynamic_module.value()),
33-
dual_info.scope, context);
32+
proto_config.filter_name(), config, proto_config.terminal_filter(),
33+
std::move(dynamic_module.value()), dual_info.scope, context);
3434

3535
if (!filter_config.ok()) {
3636
return absl::InvalidArgumentError("Failed to create filter config: " +

0 commit comments

Comments
 (0)