Session 33: TUN interface lifecycle management

- Add TUN interface detection on startup, delete existing before create
- Add proper interface deletion on shutdown via netlink
- Add TUN packet reader in separate thread with DEBUG logging
- Add graceful shutdown handling for expected "Bad address" error
- Add take_tun_device() to Node for reader ownership transfer
- Add shutdown_tun_interface() public function for cleanup by name
- Add tokio signal feature for Ctrl+C handling
This commit is contained in:
Johnathan Corgan
2026-01-30 04:57:35 +00:00
parent bfdc532058
commit db8aa5825d
6 changed files with 194 additions and 12 deletions
+8
View File
@@ -329,6 +329,14 @@ impl Node {
self.tun_device.as_mut()
}
/// Take ownership of the TUN device.
///
/// This removes the TUN device from the node, transferring ownership
/// to the caller. Useful for moving the device into a reader task.
pub fn take_tun_device(&mut self) -> Option<TunDevice> {
self.tun_device.take()
}
/// Initialize the TUN interface.
///
/// Creates and configures the TUN device based on the node's configuration.