From bee6e468bb6d4b77a4517ebee26dcc492b77c74e Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 22 May 2026 08:06:49 +0200 Subject: [PATCH] fix(route): report Windows route cleanup failures The Windows client relies on scoped guards to restore TAP MTU, interface metric, default-route policy, and the relay host route when the client exits. Those cleanups are still best-effort because they run from Drop, but silently ignoring errors makes the manual MVP test harder to recover from if Windows refuses one of the restore operations. Log cleanup failures with the interface family, index, LUID, or relay route identity involved. Successful cleanup remains quiet, and the guard ownership model is unchanged. Test Plan: - cargo fmt --check - cargo test -p lanparty-client-route - cargo check -p lanparty-client-route --target x86_64-pc-windows-msvc - cargo clippy -p lanparty-client-route --all-targets -- -D warnings - cargo clippy -p lanparty-client-route --target x86_64-pc-windows-msvc \ -- -D warnings - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings - git diff --check - git diff --cached --check Refs: MVP Windows cleanup diagnostics --- crates/lanparty-client-route/src/windows.rs | 38 +++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/crates/lanparty-client-route/src/windows.rs b/crates/lanparty-client-route/src/windows.rs index 67a72f1..b199b4c 100644 --- a/crates/lanparty-client-route/src/windows.rs +++ b/crates/lanparty-client-route/src/windows.rs @@ -184,7 +184,14 @@ impl Drop for ScopedInterfaceMetric { return; } - let _ = restore_interface_metric(self.previous); + if let Err(error) = restore_interface_metric(self.previous) { + eprintln!( + "failed to restore {:?} interface metric for index {} LUID {}: {error:#}", + self.previous.family(), + self.previous.identity().index(), + self.previous.identity().luid(), + ); + } } } @@ -215,7 +222,14 @@ impl Drop for ScopedDefaultRoutes { return; } - let _ = restore_default_routes(self.previous); + if let Err(error) = restore_default_routes(self.previous) { + eprintln!( + "failed to restore {:?} default-route state for index {} LUID {}: {error:#}", + self.previous.family(), + self.previous.identity().index(), + self.previous.identity().luid(), + ); + } } } @@ -246,7 +260,14 @@ impl Drop for ScopedInterfaceMtu { return; } - let _ = restore_interface_mtu(self.previous); + if let Err(error) = restore_interface_mtu(self.previous) { + eprintln!( + "failed to restore {:?} interface MTU for index {} LUID {}: {error:#}", + self.previous.family(), + self.previous.identity().index(), + self.previous.identity().luid(), + ); + } } } @@ -519,10 +540,15 @@ impl Drop for PinnedRelayRoute { return; } - unsafe { + let status = unsafe { // SAFETY: self.row is the same route row that was successfully created for this guard. - // Deletion failure is intentionally ignored during Drop. - DeleteIpForwardEntry2(&self.row); + DeleteIpForwardEntry2(&self.row) + }; + if let Err(error) = windows_status(status) { + eprintln!( + "failed to delete relay host route to {} on interface index {} LUID {}: {error:#}", + self.destination, self.interface_index, self.interface_luid, + ); } } }