This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 4bf476be5c497c2170c5b40b73cf7fb448635963 Author: daichuan <[email protected]> AuthorDate: Mon Nov 9 18:31:32 2026 +0800 net/usrsock: forward SIOCGIFCONF over usrsock rpmsg SIOCGIFCONF passes a struct ifconf whose ifc_buf points to the caller's buffer, so only the struct itself reached the server and the interface list was lost. - Client: send the ifc_buf contents (ifc_len bytes) after the ifconf, like the WL_IS80211POINTERCMD commands. - Server: point ifc_buf at the space right behind the ifconf in the reply buffer, restore the client's pointer after the ioctl, and return the list length, limited to the client's ifc_len, so the client copies it back into its ifc_buf. netdev_ipv4_ifconf() keeps counting entries that did not fit, and the client rejects a length larger than its buffer. Signed-off-by: daichuan <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/usrsock/usrsock_rpmsg_server.c | 29 ++++++++++++++++++++++++++++- net/usrsock/usrsock_ioctl.c | 9 ++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/usrsock/usrsock_rpmsg_server.c b/drivers/usrsock/usrsock_rpmsg_server.c index a7c69978a27..245bd2ee99b 100644 --- a/drivers/usrsock/usrsock_rpmsg_server.c +++ b/drivers/usrsock/usrsock_rpmsg_server.c @@ -32,6 +32,7 @@ #include <poll.h> #include <string.h> +#include <net/if.h> #include <sys/ioctl.h> #include <nuttx/kmalloc.h> @@ -928,6 +929,19 @@ static void usrsock_rpmsg_worker(FAR void *arg) if (req.usockid >= 0 && req.usockid < CONFIG_NET_USRSOCK_RPMSG_SERVER_NSOCKS) { + FAR struct ifconf *ifc = (FAR struct ifconf *)(ack + 1); + FAR void *ifcu_buf = ifc->ifc_buf; + size_t ifc_len = ifc->ifc_len; + + if (req.cmd == SIOCGIFCONF && ifcu_buf) + { + /* The list is returned behind the ifconf, in the space left in + * this TX buffer before the work struct at its tail. + */ + + ifc->ifc_buf = (FAR char *)(ifc + 1); + } + #ifdef CONFIG_NETDEV_WIRELESS_IOCTL FAR struct iwreq *wlack = (FAR struct iwreq *)(ack + 1); FAR void *pointer = wlack->u.data.pointer; @@ -941,8 +955,21 @@ static void usrsock_rpmsg_worker(FAR void *arg) ret = psock_ioctl(&priv->socks[req.usockid], req.cmd, (unsigned long)(ack + 1)); + if (req.cmd == SIOCGIFCONF && ifcu_buf) + { + /* netdev_ipv4_ifconf() keeps counting entries that did not fit, + * and the client rejects a result larger than its buffer. + */ + + if (ret >= 0) + { + ret = MIN(ifc->ifc_len, ifc_len); + } + + ifc->ifc_buf = ifcu_buf; + } #ifdef CONFIG_NETDEV_WIRELESS_IOCTL - if (WL_IS80211POINTERCMD(req.cmd) && pointer) + else if (WL_IS80211POINTERCMD(req.cmd) && pointer) { if (ret >= 0) { diff --git a/net/usrsock/usrsock_ioctl.c b/net/usrsock/usrsock_ioctl.c index 93e8478c1cd..faf07e0c337 100644 --- a/net/usrsock/usrsock_ioctl.c +++ b/net/usrsock/usrsock_ioctl.c @@ -221,8 +221,15 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg_) inbufs[0].iov_base = arg; inbufs[0].iov_len = arglen; + if (cmd == SIOCGIFCONF) + { + FAR struct ifconf *ifc = arg; + + inbufs[1].iov_base = ifc->ifc_buf; + inbufs[1].iov_len = ifc->ifc_len; + } #ifdef CONFIG_NETDEV_WIRELESS_IOCTL - if (WL_IS80211POINTERCMD(cmd)) + else if (WL_IS80211POINTERCMD(cmd)) { FAR struct iwreq *wlreq = arg;
