netstack+drivers: TCP write_buf return, dhcpd iface arg, virtio DMA sync, ip fpath

- tcp/scheme/tcp.rs: write_buf now returns the actual bytes from
  send_slice() instead of buf.len(). Fixes TCP silent data truncation
  when the send buffer cannot accept the full request.
- netstack/scheme/ip.rs: fpath() uses .expect() with a message in place
  of .unwrap() for clearer diagnostics on buffer write failure.
- dhcpd/main.rs: parse the first non-flag positional argument as the
  interface name. Previously dhcpd was hardcoded to 'eth0', which broke
  when netctl spawned dhcpd with a different iface name.
- drivers/common/dma.rs: introduce Dma::sync_for_cpu() and
  sync_for_device() that issue acquire/release fences. Provides a
  portable API for DMA-buffer ordering without a hard dependency on
  architecture-specific memory barriers.
- drivers/net/virtio-netd/scheme.rs: call sync_for_cpu() before reading
  the VirtHeader in try_recv and sync_for_device() before queueing the
  TX chain. Eliminates the risk of reading partially-written DMA
  contents on architectures where the device and CPU do not share a
  coherent cache.
This commit is contained in:
Red Bear OS
2026-07-26 16:26:58 +09:00
parent 8c7f6172a2
commit 9e5f915d42
5 changed files with 30 additions and 7 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ impl<'a> SchemeSocket for RawSocket<'a> {
fn fpath(&self, _file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize> {
FpathWriter::with(buf, "ip", |w| {
write!(w, "{}", self.ip_protocol()).unwrap();
write!(w, "{}", self.ip_protocol()).expect("write ip protocol to fpath");
Ok(())
})
}
+1 -2
View File
@@ -191,8 +191,7 @@ impl<'a> SchemeSocket for TcpSocket<'a> {
} else if !self.is_active() {
Err(SyscallError::new(syscall::ENOTCONN))
} else if self.can_send() {
self.send_slice(buf).map_err(|_| SyscallError::new(syscall::EIO))?;
Ok(buf.len())
Ok(self.send_slice(buf).map_err(|_| SyscallError::new(syscall::EIO))?)
} else if file.flags & syscall::O_NONBLOCK == syscall::O_NONBLOCK {
Err(SyscallError::new(syscall::EAGAIN))
} else {