From ead1130e5fdfd4041565ab11b5218c7fd2d2645e Mon Sep 17 00:00:00 2001 From: Crimson Date: Tue, 12 May 2026 14:24:02 +0500 Subject: [PATCH] =?UTF-8?q?fix25:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B8=D0=B4=D0=B5=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D0=BD=D1=82=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20swap?= =?UTF-8?q?=20=D0=B8=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?default=20qdisc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- traffic_core/src/swap.rs | 5 ++++- traffic_core/src/traffic.rs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/traffic_core/src/swap.rs b/traffic_core/src/swap.rs index fe6fd5a..c8edfa7 100644 --- a/traffic_core/src/swap.rs +++ b/traffic_core/src/swap.rs @@ -339,7 +339,7 @@ fn render_fstab_line(path: &Path, priority: i32) -> String { fn enable_desired_swap(desired: &DesiredSwap) -> anyhow::Result<()> { let active = read_active_swaps()?; if let Some(found) = active.iter().find(|v| v.name == desired.path) - && found.size_bytes == desired.size_bytes + && active_swap_size_matches(found.size_bytes, desired.size_bytes) && found.priority == desired.priority { return Ok(()); @@ -553,8 +553,11 @@ mod tests { #[test] fn active_swap_size_accepts_mkswap_usable_size_delta() { + // Debian 13: swapon may report 4096 bytes less than file size. assert!(active_swap_size_matches(2147479552, 2147483648)); + assert!(active_swap_size_matches(2147483648, 2147483648)); assert!(!active_swap_size_matches(2146435072, 2147483648)); + assert!(!active_swap_size_matches(2147487744, 2147483648)); } #[test] diff --git a/traffic_core/src/traffic.rs b/traffic_core/src/traffic.rs index 6c9c168..43c94da 100644 --- a/traffic_core/src/traffic.rs +++ b/traffic_core/src/traffic.rs @@ -600,6 +600,7 @@ fn is_not_found_error(stderr_or_msg: &str) -> bool { || s.contains("cannot find device") || s.contains("no such device") || s.contains("no such file") + || s.contains("handle of zero") } fn parse_root_class_rate_ceil(raw: &str, class_id: &str) -> Option { @@ -953,6 +954,7 @@ fn run_allow_notfound(transport: &dyn NsTransport, args: &[&str]) -> anyhow::Res || msg.contains("cannot find device") || msg.contains("no such device") || msg.contains("does not exist") + || msg.contains("handle of zero") { return Ok(()); } @@ -1115,6 +1117,9 @@ mod tests { assert!(is_not_found_error("RTNETLINK answers: No such device")); assert!(is_not_found_error("Cannot find device \"ifb0\"")); assert!(is_not_found_error("does not exist")); + assert!(is_not_found_error( + "Cannot delete qdisc with handle of zero" + )); assert!(!is_not_found_error("permission denied")); }