[PATCH 08/12] batctl: netlink: detect receive errors in query_rtnl_link

Sven Eckelmann <[email protected]> Wed, 08 Jul 2026 22:00:14 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
query_rtnl_link() ignores the return value of nl_recvmsgs(). Once
nl_send_auto_complete() succeeds, the local err stays 0 no matter what
happens while receiving the RTM_GETLINK dump, so a failed or truncated dump
is reported as success.

Set err to -EIO on an receive error to let the caller handle it as actual
error.

Fixes: 45548f578683 ("batctl: Use rtnl to query list of softif devices")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 functions.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/functions.c b/functions.c
index a3f6639..f3ad560 100644
--- a/functions.c
+++ b/functions.c
@@ -496,7 +496,9 @@ int query_rtnl_link(int ifindex, nl_recvmsg_msg_cb_t func, void *arg)
 	if (ret < 0)
 		goto err_free_msg;
 
-	nl_recvmsgs(sock, cb);
+	ret = nl_recvmsgs(sock, cb);
+	if (ret < 0)
+		err = -EIO;
 
 err_free_msg:
 	nlmsg_free(msg);

-- 
2.47.3