[PATCH 2/5] batctl: tpmeter: abort result wait on receive errors
Sven Eckelmann <[email protected]> Tue, 07 Jul 2026 21:17:01 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
tp_recv_result() loops on nl_recvmsgs() until the tp_meter result
notification arrives, but never checks its return value. When the receive
fails (receive queue overrun and drops notification, socket failed
completely, ...), the loop just calls nl_recvmsgs() again and blocks
forever in recvmsg() waiting for a message that will never arrive.
Leave the receive loop on errors instead; the existing checks below then
report the failure to the caller.
Fixes: f109b3473f86 ("batctl: introduce throughput meter support")
Signed-off-by: Sven Eckelmann <[email protected]>
---
throughputmeter.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/throughputmeter.c b/throughputmeter.c
index 10f4f24..fd4165c 100644
--- a/throughputmeter.c
+++ b/throughputmeter.c
@@ -198,6 +198,7 @@ static int tp_recv_result(struct nl_sock *sock, struct tp_result *result)
{
struct nl_cb *cb;
int err = 0;
+ int ret;
cb = nl_cb_alloc(NL_CB_DEFAULT);
nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
@@ -205,8 +206,11 @@ static int tp_recv_result(struct nl_sock *sock, struct tp_result *result)
result);
nl_cb_err(cb, NL_CB_CUSTOM, tpmeter_nl_print_error, result);
- while (result->error == 0 && !result->found)
- nl_recvmsgs(sock, cb);
+ while (result->error == 0 && !result->found) {
+ ret = nl_recvmsgs(sock, cb);
+ if (ret < 0)
+ break;
+ }
nl_cb_put(cb);
--
2.47.3