casaroli opened a new pull request, #22426: URL: https://github.com/apache/nuttx/pull/22426
## Summary Two fixes for raw packet sockets (`AF_PACKET`), one per commit: - Commit 1: `sendto()` and `sendmsg()` with a `struct sockaddr_ll` on a `SOCK_RAW` packet socket failed with `EAFNOSUPPORT` (`pkt_sendmsg_is_valid()`). A socket that is not bound can only send with an address, and many programs give the address also on a bound socket (as on Linux). Now the address is accepted: a length smaller than `struct sockaddr_ll` gives `EINVAL`, and `sll_ifindex` selects the network device (`ENODEV` if there is none), as for `SOCK_DGRAM`. The frame of a raw socket holds its link layer header, so the address only selects the device. A send without an address does not change. - Commit 2: `pkt_recvmsg()` waited with no timeout and did not read `SO_RCVTIMEO`. A `recv()` on an idle packet socket with a receive timeout waited until a frame or a signal came. Now it waits with the receive timeout of the socket, as UDP and ICMP do, and returns `EAGAIN` on a timeout. ## Impact `net/pkt` only. `sendto()` with an address on a raw packet socket now works instead of `EAFNOSUPPORT`; `SO_RCVTIMEO` now applies to packet sockets. No API, ABI or Kconfig change. Common network code: the same in flat, protected and kernel builds and on all architectures. ## Testing `qemu-armv8a:netnsh_smp` (flat), QEMU user network, a test program on `eth0`: | Case | Before | After | |---|---|---| | `sendto()` of an ARP request with a `sockaddr_ll` (raw socket) | -1 `EAFNOSUPPORT` | 60, the ARP reply of 10.0.2.2 comes | | `sendto()` with an address length of 4 | -1 `EAFNOSUPPORT` | -1 `EINVAL` | | `recv()` with `SO_RCVTIMEO` 1 s on an idle packet socket | still waiting at 5 s (a `SIGALRM` ends it: `EINTR`) | -1 `EAGAIN` after 1007 ms | Builds with `-Werror` (CI image): `qemu-armv8a:netnsh_smp` (flat), `qemu-armv8a:knsh` with networking and virtio-net added (kernel), `rv-virt:netnsh64` (flat), `rv-virt:knetnsh64` (kernel), each with packet sockets, netlink route and netfilter, and the DNS client enabled. No new warnings (the only warning is the RWX linker warning of `rv-virt:netnsh64`, also on master). checkpatch (`-c -u -m -g`) passes. The kernel builds use `CONFIG_NET_PKT_WRITE_BUFFERS=y` (buffered send), the flat builds the unbuffered send. -- 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]
