From b869651768330460a8f06885f89ef33aa6665bc1 Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Thu, 9 Jul 2026 00:55:24 +0300 Subject: [PATCH] review: fix TcpScheme missing from initial event array CRITICAL: main.rs all[] initial event array was missing TcpScheme. This meant TCP scheme events that arrived before the event loop started processing would be delayed until the event queue fired. In practice, TCP connections could stall at startup. Note: main.rs also already subscribed TcpScheme - only the initial array was incomplete, not the event queue subscription. ALSO FIXED: - scheme/socket.rs handle_block: read/write timeout was swapped. Op::Read was using write_timeout and Op::Write was using read_timeout (SO_RCVTIMEO/SO_SNDTIMEO semantics). - netcfg/mod.rs route/rm: now accepts 'default' keyword same as route/add does. Writing 'default' to route/rm deletes the 0.0.0.0/0 default route, consistent with parse_route behavior. All 29 existing tests still pass. --- netstack/src/main.rs | 2 +- netstack/src/scheme/netcfg/mod.rs | 15 ++++++++------- netstack/src/scheme/socket.rs | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/netstack/src/main.rs b/netstack/src/main.rs index b0d654cd80..4b1ea55f3b 100644 --- a/netstack/src/main.rs +++ b/netstack/src/main.rs @@ -194,7 +194,7 @@ fn run(daemon: daemon::Daemon) -> Result<()> { let all = { use EventSource::*; - [Network, Time, IpScheme, UdpScheme, IcmpScheme, NetcfgScheme, NetfilterScheme, TunScheme].map(Ok) + [Network, Time, IpScheme, UdpScheme, TcpScheme, IcmpScheme, NetcfgScheme, NetfilterScheme, TunScheme].map(Ok) }; for event_res in all diff --git a/netstack/src/scheme/netcfg/mod.rs b/netstack/src/scheme/netcfg/mod.rs index 3bc3bc3b29..edfeb4c44e 100644 --- a/netstack/src/scheme/netcfg/mod.rs +++ b/netstack/src/scheme/netcfg/mod.rs @@ -339,13 +339,14 @@ fn mk_root_node( wo [iface, notifier, route_table] (Option, None) |cur_value, line| { if cur_value.is_none() { - match line.parse() { - Ok(cidr) => { - *cur_value = Some(cidr); - Ok(()) - } - Err(_) => Err(SyscallError::new(syscall::EINVAL)) - } + let cidr = if line.trim() == "default" { + gateway_cidr() + } else { + line.parse::() + .map_err(|_| SyscallError::new(syscall::EINVAL))? + }; + *cur_value = Some(cidr); + Ok(()) } else { Err(SyscallError::new(syscall::EINVAL)) } diff --git a/netstack/src/scheme/socket.rs b/netstack/src/scheme/socket.rs index 8028710c4d..dfdd3372b8 100644 --- a/netstack/src/scheme/socket.rs +++ b/netstack/src/scheme/socket.rs @@ -329,8 +329,8 @@ where }?; let mut timeout = match op { - Op::Read(_) => write_timeout, - Op::Write(_) => read_timeout, + Op::Read(_) => read_timeout, + Op::Write(_) => write_timeout, _ => None, };