From 0cecc5d5286d7f0ba558e0bc0220e2533dc570df Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Fri, 3 Nov 2023 11:40:07 +0100 Subject: [PATCH] Add error log if set route or addr on TUN fails Signed-off-by: Lee Smet --- src/tun/linux.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tun/linux.rs b/src/tun/linux.rs index 495c922..d2fd678 100644 --- a/src/tun/linux.rs +++ b/src/tun/linux.rs @@ -37,8 +37,14 @@ pub async fn new( let tun_index = link_index_by_name(handle.clone(), name.to_string()).await?; - add_address(handle.clone(), tun_index, node_subnet).await?; - add_route(handle.clone(), tun_index, route_subnet).await?; + if let Err(e) = add_address(handle.clone(), tun_index, node_subnet).await { + error!("Failed to add address {node_subnet} to TUN interface: {e}"); + return Err(e); + } + if let Err(e) = add_route(handle.clone(), tun_index, route_subnet).await { + error!("Failed to add route for {route_subnet} to TUN interface: {e}"); + return Err(e); + } // We are done with our netlink connection, abort the task so we can properly clean up. netlink_task_handle.abort();