Repository : ssh://git@diktynna/batctl
On branch : master
commit 0b81e8fbaed54b9b2f68cc98b9133674287f5bd0 Author: Sven Eckelmann sven@narfation.org Date: Mon May 10 21:41:44 2021 +0200
batctl: Consume genl ACKs after setting reads
The kernel is sending an ACK after an successful read request via the batadv genl socket. This ack must be consumed manually after the actual message was processed. Otherwise, the next user of the socket can get confused by the unexpected ACK in the socket queue.
Signed-off-by: Sven Eckelmann sven@narfation.org
0b81e8fbaed54b9b2f68cc98b9133674287f5bd0 sys.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sys.c b/sys.c index 6dd8c10..f1dc275 100644 --- a/sys.c +++ b/sys.c @@ -107,7 +107,13 @@ int sys_simple_nlquery(struct state *state, enum batadv_nl_commands nl_cmd, nl_send_auto_complete(state->sock, msg); nlmsg_free(msg);
- nl_recvmsgs(state->sock, state->cb); + if (callback) { + ret = nl_recvmsgs(state->sock, state->cb); + if (ret < 0) + return ret; + } + + nl_wait_for_ack(state->sock);
return result; }