casaroli opened a new pull request, #21767: URL: https://github.com/apache/nuttx/pull/21767
depends-on: apache/nuttx/pull/21737 ## Summary Two fixes of the atomic datagram frame of local sockets (`local_send_frame()`, `PIPEIOC_ATOMICWRITE`, from 6b50d0c8de4), one commit each: - net/local: Select FS_UIO for datagram sockets. The atomic mode is in the writev method of the pipe driver only. Without `CONFIG_FS_UIO`, `file_writev()` writes each segment with the write method, so a frame is not atomic and a reader can get a header without its data. `FS_UIO` is a hidden option that only `SERIAL` selects. Now `NET_LOCAL_DGRAM` selects it. - net/local: Send a datagram of more than six iovecs. `local_send_frame()` put the preamble, the path and the payload into an array of 8 iovecs on the stack, so a `sendmsg()` of a datagram with more than 6 iovecs failed with `EMSGSIZE`, also when the datagram was small. POSIX allows up to `IOV_MAX` iovecs. Now such a frame is copied into one buffer from `kmm_malloc()`, which the receive buffer of the peer limits (the size check comes first and adds the segments one at a time, so a sum that overflows cannot pass it). A frame of 6 iovecs or fewer is sent as before, with no copy. ## Impact Local datagram sockets only. The same code in flat, protected and kernel builds; no architecture code. - `sendmsg()` of a datagram with more than 6 iovecs works. Such a send costs one heap buffer of the frame size and one copy. - `NET_LOCAL_DGRAM` selects `FS_UIO`: a configuration without `SERIAL` gets `fs_uio.c` and the writev paths of the VFS. - No documentation page describes Unix domain sockets; no change. ## Testing Test: `send_iov` in `cmocka_net_local_dgram` (a `sendmsg()` of one datagram in 12 parts, two of them empty, to a bound socket); it follows in a nuttx-apps PR. Also the other send cases of `cmocka_net_local_dgram` (`send`, `sendto_null`, `poll_sendto`, `poll_closesend`, `poll_sendmsg`, `reg_sendrecv`, `send_intr`) and ostest. qemu-armv8a (arm64, HVF, 1 CPU), make, each case alone, knsh (kernel build) and nsh (flat build): | | master 512dee83099 | this PR | |---|---|---| | `send_iov`, knsh and nsh | FAIL: `sendmsg()` returns -1 (`EMSGSIZE`) | PASS | | the other 7 send cases, knsh and nsh | PASS | PASS | | ostest, knsh and nsh | status 0 | status 0 | Kconfig: qemu-armv8a:nsh with `NET_LOCAL_DGRAM` and `SERIAL` off has no `FS_UIO` on master, and `FS_UIO=y` with this PR. Builds with `EXTRAFLAGS="-Wno-cpp -Werror"`, with `NET`, `NET_LOCAL`, `NETDEV_LATEINIT`, `NET_SOCKOPTS`, `PIPES`: qemu-armv8a:nsh (flat) with stream, datagram and `NET_LOCAL_SCM`, and with datagram only; mps2-an500:knsh (protected, armv7-m) and rv-virt:knsh64 (kernel, riscv64) with stream, datagram and `NET_LOCAL_SCM`: all OK, no warning. Compilers: aarch64-none-elf GCC 14.2, arm-none-eabi GCC 15.3, riscv-none-elf GCC 14.3. `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
