English
ours-sys
libs/sys — a workspace crate with unsafe: the system calls that neither rustix nor socket2 offers. It has its own [lints] without forbid (see unsafe). Only the calls themselves are unsafe; what the kernel wrote — addresses, control messages, option values — is read by safe code over bytes.
setsockopt(fd, level, name, &[u8]),getsockopt(fd, level, name, &mut [u8])— options by number with the value in the bytes the kernel takes:TCP_FASTOPEN[_CONNECT],IP_BIND_ADDRESS_NO_PORT,SO_RCVLOWAT,IP[V6]_RECVORIGDSTADDR,IP_PKTINFO,IPV6_RECVPKTINFO,UDP_GRO,SO_ZEROCOPY,TCP_BRUTAL_PARAMS.recvmsg(fd, buf, &mut Control<N>, flags)— one datagram with its control messages;Messageholds the length, the source, the filled part of the control buffer and the flags (MSG_TRUNC,MSG_CTRUNC).recvmmsg(fd, bufs, controls, out, flags)— up toMAX_BATCH(64) datagrams. The headers, the source addresses and the iovecs are on the stack and are built anew on every call, so a short address or control length of one call does not carry over to the next; nothing is allocated.Control<N>— a control buffer aligned ascmsghdris (the kernel writes headers in place); the caller keeps it and reuses it.socket_addr(bytes)—sockaddr_in/sockaddr_in6from bytes (a source,IP[V6]_ORIGDSTADDR).thread_cpu_time(tid)—clock_gettimeon another thread's CPU clock, as glibc'spthread_getcpuclockidbuilds it (/proc/<tid>/schedstatis missing on kernels withoutCONFIG_SCHED_INFO, WSL among them).
Control messages themselves are parsed and built in ours-net-sys (cmsg.rs), in safe code. Sending with a control message is socket2's safe sendmsg.