The netlink error codes from tp_meter_start() and tp_recv_result() are
returned unmodified as command result, which main() passes to exit(). A
failure like -EOPNOTSUPP therefore turns into the meaningless exit status
instead of EXIT_FAILURE.

Report EXIT_FAILURE after printing the error.

Fixes: f109b3473f86 ("batctl: introduce throughput meter support")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 throughputmeter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/throughputmeter.c b/throughputmeter.c
index 98a9490..10f4f24 100644
--- a/throughputmeter.c
+++ b/throughputmeter.c
@@ -383,6 +383,7 @@ static int throughputmeter(struct state *state, int argc, 
char **argv)
        ret = tp_meter_start(state, dst_mac, time, &cookie);
        if (ret < 0) {
                printf("Failed to send tp_meter request to kernel: %d\n", ret);
+               ret = EXIT_FAILURE;
                goto out;
        }
 
@@ -390,6 +391,7 @@ static int throughputmeter(struct state *state, int argc, 
char **argv)
        ret = tp_recv_result(listen_sock, &result);
        if (ret < 0) {
                printf("Failed to recv tp_meter result from kernel: %d\n", ret);
+               ret = EXIT_FAILURE;
                goto out;
        }
 

-- 
2.47.3

Reply via email to