[PATCH 07/12] batctl: netlink: report send errors in netlink_simple_request

Sven Eckelmann <[email protected]> Wed, 08 Jul 2026 22:00:13 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
netlink_simple_request() initializes err to 0 and only lets
ack_errno_handler() update it while receiving. When nl_send_auto_complete()
fails, the function jumps to the cleanup path with err still set to 0 and
reports success even though the request never reached the kernel. Callers
like the interface create/destroy handling then exit without any error
indication.

Set err to -EIO on the send error path to let the caller handle it as
actual error.

Fixes: dd2bbe182780 ("batctl: Add command to create/destroy batman-adv interface")
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 00dbd3d..a3f6639 100644
--- a/functions.c
+++ b/functions.c
@@ -552,8 +552,10 @@ int netlink_simple_request(struct nl_msg *msg)
 	nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, NULL);
 
 	ret = nl_send_auto_complete(sock, msg);
-	if (ret < 0)
+	if (ret < 0) {
+		err = -EIO;
 		goto err_free_cb;
+	}
 
 	// ack_errno_handler sets err on errors
 	err = 0;

-- 
2.47.3