Skip to main content

H2FloodConfig

Struct H2FloodConfig 

Source
pub struct H2FloodConfig { /* private fields */ }
Expand description

Configurable thresholds for H2 flood detection.

All values have safe defaults matching the compile-time constants. When configured via listener config, None values fall back to these defaults.

Implementations§

Source§

impl H2FloodConfig

Source

pub fn new( max_rst_stream_per_window: u32, max_ping_per_window: u32, max_settings_per_window: u32, max_empty_data_per_window: u32, max_window_update_stream0_per_window: u32, max_continuation_frames: u32, max_glitch_count: u32, max_rst_stream_lifetime: u64, max_rst_stream_abusive_lifetime: u64, max_rst_stream_emitted_lifetime: u64, max_header_list_size: u32, max_header_table_size: u32, max_header_fields: u32, stream_refusal_percent: u32, ) -> Self

Create a validated config, clamping all thresholds to at least 1. Zero thresholds would cause immediate flood detection on any frame.

With Self::from_optional, this is the only way to build an H2FloodConfig: the fields above are private, so the clamp below cannot be routed around by a raw struct literal the way lib/src/http.rs and lib/src/https.rs used to route around it (sozu-proxy/sozu#1418).

Source

pub fn from_optional( max_rst_stream_per_window: Option<u32>, max_ping_per_window: Option<u32>, max_settings_per_window: Option<u32>, max_empty_data_per_window: Option<u32>, max_window_update_stream0_per_window: Option<u32>, max_continuation_frames: Option<u32>, max_glitch_count: Option<u32>, max_rst_stream_lifetime: Option<u64>, max_rst_stream_abusive_lifetime: Option<u64>, max_rst_stream_emitted_lifetime: Option<u64>, max_header_list_size: Option<u32>, max_header_table_size: Option<u32>, max_header_fields: Option<u32>, stream_refusal_percent: Option<u32>, ) -> Self

Build a validated config from a listener’s per-knob overrides: each None takes the compile-time default, then Self::new clamps. Mirrors super::h2::H2ConnectionConfig::from_optional, which the adjacent get_h2_connection_config already uses for the connection knobs read out of the very same listener config.

This is what lib/src/http.rs and lib/src/https.rs call. They used to spell the same unwrap_or(default) table into a raw struct literal, which skipped new and therefore skipped the clamp on the one production path that carries operator-set thresholds (sozu-proxy/sozu#1418). A zero that survives to here does not disable a check, it makes the first event its counter sees a violation, and how far that reaches depends on the knob: max_header_list_size and max_header_fields are also the HPACK decode budget pkawa::decode_headers_with_budget enforces, so 0 refuses every request on the listener with ENHANCE_YOUR_CALM — per stream for a header block that fits one HEADERS frame, and as a connection GOAWAY for one that spans CONTINUATION frames, where H2FloodDetector::record_continuation_frame lifts accumulated_header_size above the zero threshold and h2.rs’s check_flood_or_return! fires before the explicit size test. max_rst_stream_per_window = 0 (and every other per-window or lifetime frame counter) is inert until a client actually sends the frame it counts — check_flood compares count > threshold, and 0 > 0 is false.

Every door that STATES a listener configuration now rejects an out-of-range knob outright — the configuration file and sozu ctl add listener via ConfigError::H2ThresholdBelowMinimum (command/src/config.rs), UpdateHttp(s)Listener and a raw protobuf Add{Http,Https}Listener via command/src/state.rs’s four validate_h2_flood_knobs_* — so the operator is told which key to fix rather than having their stated value silently rewritten. The clamp reached through here is the backstop for the one path that deliberately does NOT reject: replay of a state file saved before those gates existed, where dropping the listener would be a worse outcome than clamping one threshold (bin/src/command/requests.rs’s RequestOrigin::Replayed).

Source

pub fn max_rst_stream_per_window(&self) -> u32

Maximum RST_STREAM frames per rate window (CVE-2023-44487, CVE-2019-9514).

Source

pub fn max_ping_per_window(&self) -> u32

Maximum PING frames per rate window (CVE-2019-9512).

Source

pub fn max_settings_per_window(&self) -> u32

Maximum SETTINGS frames per rate window (CVE-2019-9515).

Source

pub fn max_empty_data_per_window(&self) -> u32

Maximum empty DATA frames per rate window (CVE-2019-9518).

Source

pub fn max_window_update_stream0_per_window(&self) -> u32

Maximum unsolicited connection-level (stream 0) WINDOW_UPDATE frames per rate window.

Source

pub fn max_continuation_frames(&self) -> u32

Maximum CONTINUATION frames per header block (CVE-2024-27316).

Source

pub fn max_glitch_count(&self) -> u32

Maximum accumulated protocol anomalies before ENHANCE_YOUR_CALM.

Source

pub fn max_rst_stream_lifetime(&self) -> u64

Floor of the lifetime cap on RST_STREAM frames received (CVE-2023-44487).

Source

pub fn max_rst_stream_abusive_lifetime(&self) -> u64

Floor of the cap on pre-response-start RST_STREAM frames (CVE-2023-44487).

Source

pub fn max_rst_stream_emitted_lifetime(&self) -> u64

Floor of the cap on peer-provoked server-emitted RST_STREAM frames (CVE-2025-8671).

Source

pub fn max_header_list_size(&self) -> u32

Maximum accumulated HPACK-decoded header list size (RFC 9113 §6.5.2).

Source

pub fn max_header_table_size(&self) -> u32

Maximum HPACK dynamic table size accepted from the peer.

Source

pub fn max_header_fields(&self) -> u32

Maximum number of materialized header fields per HEADERS/trailers block.

Source

pub fn stream_refusal_percent(&self) -> u32

Share, in percent, of the pre-response cap’s floor at which new client streams are refused; 0 disables the soft state.

Trait Implementations§

Source§

impl Clone for H2FloodConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for H2FloodConfig

Source§

impl Debug for H2FloodConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for H2FloodConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for H2FloodConfig

Source§

impl PartialEq for H2FloodConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for H2FloodConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

Source§

impl<T> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.