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
1 change: 1 addition & 0 deletions .unreleased/LLT-6859
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve critical error handler
4 changes: 2 additions & 2 deletions crates/telio-model/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ macro_rules! report_event {
}

/// Error levels. Used for app to decide what to do with `telio` device when error happens.
#[derive(Clone, Debug, Default, Serialize)]
#[derive(Clone, Debug, Default, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ErrorLevel {
/// The error level is critical (highest priority)
Expand All @@ -37,7 +37,7 @@ pub enum ErrorLevel {
}

/// Error code. Common error code representation (for statistics).
#[derive(Clone, Debug, Default, Serialize)]
#[derive(Clone, Debug, Default, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ErrorCode {
/// There is no error in the execution
Expand Down
33 changes: 33 additions & 0 deletions crates/telio-model/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ pub struct FeatureWireguard {
/// Configurable wireguard polling period
#[serde(default)]
pub polling: FeaturePolling,
/// Configurable wireguard interface health monitor
#[serde(default)]
pub interface_health: FeatureInterfaceHealth,
/// Configurable up/down behavior of WireGuard-NT adapter. See RFC LLT-0089 for details
#[serde(default)]
pub enable_dynamic_wg_nt_control: bool,
Expand Down Expand Up @@ -148,6 +151,28 @@ pub struct FeaturePersistentKeepalive {
pub stun: Option<u32>,
}

/// Configurable interface health monitoring
///
/// Accounts for WireguardNT-specific behavior which
/// produces transient errors around power transitions of the device.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SmartDefault)]
#[serde(default)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct FeatureInterfaceHealth {
/// Minimum duration of a continuous UAPI failure period required to
/// classify the failure as non-transient. (in seconds) [default: 10]
#[default(10)]
pub sustained_failure_threshold: u32,

/// Max UAPI poll gap expected to detect libtelio(device) suspension. Must be
/// higher than FeaturePolling.wireguard_polling_period.
/// Used to filter out transient WireguardNT errors that happen
/// just before power-suspend and right after power-resume.
/// (in seconds) [default 2s]
#[default(2)]
pub suspension_detection_gap: u32,
}

/// Configurable Wireguard polling period
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SmartDefault)]
#[serde(default)]
Expand Down Expand Up @@ -698,6 +723,10 @@ mod tests {
"wireguard_polling_period": 1000,
"wireguard_polling_period_after_state_change": 50
},
"interface_health": {
"sustained_failure_threshold": 44,
"suspension_detection_gap": 55
},
"enable_dynamic_wg_nt_control": true,
"skt_buffer_size": 123456,
"inter_thread_channel_size": 123456,
Expand Down Expand Up @@ -801,6 +830,10 @@ mod tests {
wireguard_polling_period: 1000,
wireguard_polling_period_after_state_change: 50
},
interface_health: FeatureInterfaceHealth {
sustained_failure_threshold: 44,
suspension_detection_gap: 55
},
enable_dynamic_wg_nt_control: true,
skt_buffer_size: Some(123456),
inter_thread_channel_size: Some(123456),
Expand Down
Loading
Loading