When a dump is terminated with a non-zero error code in its NLMSG_DONE
message, "Error received" is printed but it is missed to update the global
error state (last_err). netlink_print_common() therefore returns 0 and the
command exits EXIT_SUCCESS despite the error just printed.

Fixes: 854835788001 ("batctl: Move routing_algo specific code it command source 
file")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 netlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/netlink.c b/netlink.c
index dd0275e..e8b41cf 100644
--- a/netlink.c
+++ b/netlink.c
@@ -316,8 +316,10 @@ int netlink_stop_callback(struct nl_msg *msg, void *arg 
__maybe_unused)
        struct nlmsghdr *nlh = nlmsg_hdr(msg);
        int *error = nlmsg_data(nlh);
 
-       if (*error)
+       if (*error) {
                fprintf(stderr, "Error received: %s\n", strerror(-*error));
+               last_err = *error;
+       }
 
        return NL_STOP;
 }

-- 
2.47.3

Reply via email to