casaroli opened a new pull request, #22586: URL: https://github.com/apache/nuttx/pull/22586
## Summary Follow-up of #22145: the UDP part that its review left for a separate change, and two review nits. - `/proc/net/udp` formatted each line with only the UDP connection list locked. The line reads the read-ahead queue and walks the write queue of the connection, which recvfrom(), sendto() and the input path change under the connection lock. Now the walk takes the connection lock for each line. `udp_bind()` takes the list lock with the connection lock held (the reverse order), so the walk only tries the lock (`conn_trylock()`, new in `net/utils/utils.h`); if another thread holds it, the walk unlocks the list for one tick and finds its place again by the list id, as the TCP walk does after it waits for a device lock. - `TCP_LISTID_AFTER()` and `UDP_LISTID_AFTER()` were the same macro: now `NET_LISTID_AFTER()` in `net/utils/utils.h`. - The `txsz` column of the `/proc/net/udp` header had the condition `CONFIG_NET_SEND_BUFSIZE > 0`, the lines `CONFIG_NET_UDP_WRITE_BUFFERS`. The header now uses the condition of the lines. ## Impact With `CONFIG_NET_UDP_WRITE_BUFFERS` and `CONFIG_NET_SEND_BUFSIZE` 0 (the default), the `/proc/net/udp` header now shows `txsz`, so the header and the lines have the same columns. A read of `/proc/net/udp` can wait one tick for each connection that another thread holds locked. No API, ABI or Kconfig change. The same in all build modes and on all architectures. ## Testing New case `test_udp_procfs_columns` in `cmocka_net_udp` (apache/nuttx-apps#NNNN): it binds a UDP socket, reads `/proc/net/udp` and checks that each line has the columns of the header. qemu-armv8a:nsh (flat, CI image gcc 12.3, QEMU TCG) with TCP and UDP write buffers, procfs and net statistics (`CONFIG_NET_SEND_BUFSIZE` 0, the default): | | master | this PR | |---|---|---| | `cmocka_net_udp` | `test_udp_procfs_columns` FAILED (`6 != 5`: 6 values in a line, 5 columns in the header) | 26 passed, 1 skipped | | UDP traffic, `bind()`/`close()` churn and reads of `/proc/net/udp` at the same time, 8 runs of 10 s | ends | ends (17000 to 52000 reads of the file in each run with readers) | Builds with `-Werror` in the CI image: qemu-armv8a:netnsh and rv-virt:netnsh with procfs, statistics, write buffers and `cmocka_net_udp` (rv-virt also with UDP write buffers and `CONFIG_NET_SEND_BUFSIZE=0`); rv-virt:knetnsh64 (kernel) and qemu-armv8a:knsh (kernel, TCP, UDP, IPv6) with procfs and statistics; qemu-armv8a:netnsh without UDP write buffers and IPv6, and without statistics; qemu-armv8a:nsh, rv-virt:nsh64. qemu-intel64:citest_smp (x86_64, CMake) with `cmocka_net_udp`: build only. -- 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]
