[PATCH 12/12] batctl: netlink: use kernel-style error codes for nl_recvmsgs

Sven Eckelmann <[email protected]> Wed, 08 Jul 2026 22:00:18 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
When nl_recvmsgs() fails, it doesn't return a kernel/errno style error
codes. It is instead using negative NLE_* return codes. Since the rest of
the batctl code uses kernel style codes, just handle it as EIO error.

Signed-off-by: Sven Eckelmann <[email protected]>
---
 functions.c | 2 +-
 netlink.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/functions.c b/functions.c
index 213ba83..ba5ef83 100644
--- a/functions.c
+++ b/functions.c
@@ -565,7 +565,7 @@ int netlink_simple_request(struct nl_msg *msg)
 	err = 0;
 	ret = nl_recvmsgs(sock, cb);
 	if (ret < 0)
-		err = ret;
+		err = -EIO;
 
 err_free_cb:
 	nl_cb_put(cb);
diff --git a/netlink.c b/netlink.c
index 6e0d35a..fb6fdae 100644
--- a/netlink.c
+++ b/netlink.c
@@ -677,7 +677,8 @@ int netlink_query_common(struct state *state,
 
 	ret = nl_recvmsgs(state->sock, cb);
 	if (ret < 0) {
-		query_opts->err = ret;
+		if (query_opts->err == 0)
+			query_opts->err = -EIO;
 		goto err_free_cb;
 	}
 

-- 
2.47.3