Skip to content

Commit 5bc731b

Browse files
committed
Improve UAPI error handler
Replace the fixed count-based error handler with a duration-based mechanism and add FeatureHealthMonitoring feature for configuring it. Signed-off-by: Lukas Pukenis <lukas.pukenis@nordsec.com>
1 parent 8d50da7 commit 5bc731b

File tree

6 files changed

+392
-28
lines changed

6 files changed

+392
-28
lines changed

.unreleased/LLT-6859

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix critical error handler and allow it to be configurable

crates/telio-model/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ macro_rules! report_event {
2222
}
2323

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

3939
/// Error code. Common error code representation (for statistics).
40-
#[derive(Clone, Debug, Default, Serialize)]
40+
#[derive(Clone, Debug, Default, Serialize, Eq, PartialEq)]
4141
#[serde(rename_all = "lowercase")]
4242
pub enum ErrorCode {
4343
/// There is no error in the execution

crates/telio-model/src/features.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ pub struct FeatureBatching {
9393
}
9494

9595
/// Configurable features for Wireguard peers
96-
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
96+
#[derive(Clone, Debug, SmartDefault, PartialEq, Eq, Serialize, Deserialize)]
9797
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
98+
#[serde(default)]
9899
pub struct FeatureWireguard {
99100
/// Configurable persistent keepalive periods for wireguard peers
100101
#[serde(default)]
101102
pub persistent_keepalive: FeaturePersistentKeepalive,
102103
/// Configurable wireguard polling period
103104
#[serde(default)]
104105
pub polling: FeaturePolling,
106+
/// Configurable Wireguard health monitor
107+
#[serde(default)]
108+
pub health_monitoring: FeatureHealthMonitoring,
105109
/// Configurable up/down behavior of WireGuard-NT adapter. See RFC LLT-0089 for details
106110
#[serde(default)]
107111
pub enable_dynamic_wg_nt_control: bool,
@@ -148,6 +152,19 @@ pub struct FeaturePersistentKeepalive {
148152
pub stun: Option<u32>,
149153
}
150154

155+
/// Configurable Wireguard health monitor
156+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SmartDefault)]
157+
#[serde(default)]
158+
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
159+
pub struct FeatureHealthMonitoring {
160+
/// Minimum interval between two UAPI errors required before escalating to a critical error (in seconds) [default 10s]
161+
#[default(10)]
162+
pub failure_escalation_min_interval_secs: u32,
163+
/// Maximum acceptable gap between consecutive UAPI polls before suspecting system suspension (in seconds) [default 60s]
164+
#[default(60)]
165+
pub expected_max_uapi_poll_interval: u32,
166+
}
167+
151168
/// Configurable Wireguard polling period
152169
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SmartDefault)]
153170
#[serde(default)]
@@ -698,6 +715,10 @@ mod tests {
698715
"wireguard_polling_period": 1000,
699716
"wireguard_polling_period_after_state_change": 50
700717
},
718+
"health_monitoring": {
719+
"failure_escalation_min_interval_secs": 44,
720+
"expected_max_uapi_poll_interval": 55
721+
},
701722
"enable_dynamic_wg_nt_control": true,
702723
"skt_buffer_size": 123456,
703724
"inter_thread_channel_size": 123456,
@@ -801,6 +822,10 @@ mod tests {
801822
wireguard_polling_period: 1000,
802823
wireguard_polling_period_after_state_change: 50
803824
},
825+
health_monitoring: FeatureHealthMonitoring {
826+
failure_escalation_min_interval_secs: 44,
827+
expected_max_uapi_poll_interval: 55
828+
},
804829
enable_dynamic_wg_nt_control: true,
805830
skt_buffer_size: Some(123456),
806831
inter_thread_channel_size: Some(123456),

0 commit comments

Comments
 (0)