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.
This commit is contained in:
Red Bear OS
2026-07-09 00:55:24 +03:00
parent 0f5a4f59f4
commit b869651768
3 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -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
+8 -7
View File
@@ -339,13 +339,14 @@ fn mk_root_node(
wo [iface, notifier, route_table] (Option<IpCidr>, 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::<IpCidr>()
.map_err(|_| SyscallError::new(syscall::EINVAL))?
};
*cur_value = Some(cidr);
Ok(())
} else {
Err(SyscallError::new(syscall::EINVAL))
}
+2 -2
View File
@@ -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,
};