From b5d6c276808c0948c2dfb304238989301b9decfd Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 13 Dec 2024 15:53:22 +1100 Subject: [PATCH] fix(linux): don't print error when removing non-existent route (#7502) We are already handling one case where we are trying to remove a route that doesn't exist. `ESRCH` is another variant of this error that manifests as "No such process". According to the Internet, this just means the route doesn't exist so we can bail out early here. --- rust/bin-shared/src/tun_device_manager/linux.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/bin-shared/src/tun_device_manager/linux.rs b/rust/bin-shared/src/tun_device_manager/linux.rs index abb592312..d1d125490 100644 --- a/rust/bin-shared/src/tun_device_manager/linux.rs +++ b/rust/bin-shared/src/tun_device_manager/linux.rs @@ -8,7 +8,8 @@ use futures::TryStreamExt; use ip_network::{IpNetwork, Ipv4Network, Ipv6Network}; use ip_packet::{IpPacket, IpPacketBuf}; use libc::{ - fcntl, makedev, mknod, open, EEXIST, ENOENT, F_GETFL, F_SETFL, O_NONBLOCK, O_RDWR, S_IFCHR, + fcntl, makedev, mknod, open, EEXIST, ENOENT, ESRCH, F_GETFL, F_SETFL, O_NONBLOCK, O_RDWR, + S_IFCHR, }; use netlink_packet_route::route::{RouteProtocol, RouteScope}; use netlink_packet_route::rule::RuleAction; @@ -282,6 +283,12 @@ async fn remove_route(route: &IpNetwork, idx: u32, handle: &Handle) { return; } + // "No such process" is another version of "route does not exist". + // See . + if matches!(&err, NetlinkError(err) if err.raw_code() == ESRCH) { + return; + } + tracing::warn!(error = std_dyn_err(&err), %route, "Failed to remove route"); }