[PATCH 18/28] batctl: netlink: consume until acks even on errors
Sven Eckelmann <[email protected]> Sun, 21 Jun 2026 16:24:08 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
THe sys_simple_nlquery() function is used on a shared socket. The data
until the ack must therefore _always_ be consumed to avoid receive
confusions when another command is started on the same socket.
Fixes: 0b81e8fbaed5 ("batctl: Consume genl ACKs after setting reads")
Signed-off-by: Sven Eckelmann <[email protected]>
---
netlink.c | 8 +-------
sys.c | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/netlink.c b/netlink.c
index be92a9c..3a1c3a5 100644
--- a/netlink.c
+++ b/netlink.c
@@ -466,7 +466,6 @@ char *netlink_get_info(struct state *state, uint8_t nl_cmd, const char *header)
};
struct nl_msg *msg;
struct nl_cb *cb;
- int ret;
msg = nlmsg_alloc();
if (!msg)
@@ -488,12 +487,7 @@ char *netlink_get_info(struct state *state, uint8_t nl_cmd, const char *header)
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, info_callback, &opts);
nl_cb_err(cb, NL_CB_CUSTOM, netlink_print_error, NULL);
- ret = nl_recvmsgs(state->sock, cb);
- if (ret < 0) {
- nl_cb_put(cb);
- return opts.remaining_header;
- }
-
+ nl_recvmsgs(state->sock, cb);
nl_wait_for_ack(state->sock);
nl_cb_put(cb);
diff --git a/sys.c b/sys.c
index 35a026e..3018c09 100644
--- a/sys.c
+++ b/sys.c
@@ -110,7 +110,7 @@ int sys_simple_nlquery(struct state *state, enum batadv_nl_commands nl_cmd,
if (callback) {
ret = nl_recvmsgs(state->sock, state->cb);
if (ret < 0)
- return ret;
+ result = ret;
}
nl_wait_for_ack(state->sock);
--
2.47.3