CV-Bowen opened a new pull request, #22223:
URL: https://github.com/apache/nuttx/pull/22223
## Summary
Fixes to the usrsock rpmsg client/server (`drivers/usrsock/usrsock_rpmsg*.c`)
and SIOCGIFCONF support over it:
- `net/usrsock/usrsock_ioctl: fix nxstyle errors`: two missing blank lines
already reported on master in a file this series touches. No functional
change.
- `run ioctls from the work queue`: the server called `psock_ioctl()` from
the rpmsg endpoint callback. A network ioctl can block, and meanwhile no
other usrsock request on the channel is handled. The ioctl now runs on
the high priority work queue; the work item lives at the tail of the tx
buffer the reply is sent in.
- `release the tx buffer when the copy fails`: `usrsock_request()` leaked
the tx buffer when `usrsock_iovec_get()` failed.
- `do not hold s_lock around psock_poll()`: `usrsock_rpmsg_poll_setup()`
took `conn->s_lock` and then the netdev lock inside `psock_poll()`, the
reverse of the order the network stack uses (netdev lock, then s_lock,
e.g. `devif_poll()` -> `udp_callback()`/`tcp_poll()` on hpwork), so the
two could deadlock. Without the lock a concurrent teardown from the poll
callback can make `psock_poll(..., false)` return `-EINVAL`; that case
is treated as already torn down.
- `drop the always true reqid >= 0 check`: `reqid` is `uint32_t`.
- `forward SIOCGIFCONF over usrsock rpmsg`: only the `struct ifconf`
itself reached the server; its `ifc_buf` is a pointer into the client's
memory. The client now sends the buffer contents after the struct (like
the `WL_IS80211POINTERCMD` commands), the server points `ifc_buf` at
them, and returns the list length, limited to the client's `ifc_len`.
## Impact
- `ioctl()` on a usrsock socket backed by rpmsg runs on HPWORK on the
server (`CONFIG_SCHED_HPWORK`, already required by the poll path).
- `SIOCGIFCONF` on a usrsock rpmsg socket now returns the server's
interface list. Before, the server wrote the list through the client's
pointer value in its own address space.
- No API or Kconfig change. Both ends of the usrsock rpmsg link must run
the new code for SIOCGIFCONF; other requests are unchanged on the wire.
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
Every commit builds with 0 warnings on sim:rpserver, sim:rpproxy (both
use usrsock rpmsg: proxy is the client, server the network stack),
qemu-armv8a:rpserver and qemu-armv8a:rpproxy.
sim:rpserver + sim:rpproxy, unchanged configs plus a test-only proxy app
(not in this PR) that calls `SIOCGIFCONF` with an 8 entry buffer and
`SIOCGIFADDR` for `lo` on an `AF_INET` socket (i.e. through usrsock to
the server):
| | master | this PR |
|---|---|---|
| test app on the proxy (3 runs) | the server sim process dies, proxy
console gone | `SIOCGIFCONF ret=36 ... [0] lo 127.0.0.1`, `SIOCGIFADDR lo ret=0
addr=127.0.0.1` |
| proxy `ping -c 3 127.0.0.1` (server loopback via usrsock) | 3/3 | 3/3 |
| proxy `iperf -c 127.0.0.1 -u -p 5002 -t 3` | 1.17 Mbits/sec | 1.17
Mbits/sec |
| proxy `iperf -c 127.0.0.1 -t 3` (TCP) | `tcp client send error, error
code: 12` | same |
The TCP iperf failure (ENOMEM on send) happens on master as well and is
not changed by this series.
<details><summary>this PR, test app on the proxy</summary>
```
proxy> p134ifc
p134ifc: SIOCGIFCONF ret=36 ifc_len=36 entries=1
p134ifc: [0] lo 127.0.0.1
p134ifc: SIOCGIFADDR lo ret=0 addr=127.0.0.1
```
</details>
<details><summary>master, test app on the proxy</summary>
```
cu /dev/ttyproxy
proxy> p134ifc
(the server sim process exits; no further output)
```
</details>
Not tested: the s_lock/netdev lock deadlock (no reproducer on sim), the
`-EINVAL` teardown race, an ioctl that blocks for long on the server,
wireless pointer ioctls, and usrsock rpmsg on qemu-armv8a (its rp configs
do not enable usrsock).
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
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]