diff options
author | Eric Leblond <eric@regit.org> | 2017-08-24 17:07:37 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-08-24 19:20:31 +0200 |
commit | 5823568c8d605dbf4b258a807ed14a1c8367399e (patch) | |
tree | becad01873a8bf945e989dd97073626e8a9b3979 /src/mnl.c | |
parent | d4344bd829c00523b80f09bebf2a70c588b64c2a (diff) |
mnl: fix error handling in mnl_batch_talk
If one of the command is failing we should return an error.
Pablo says: "This is not a real issue since nft_netlink() returns an
error in case the list of errors is not empty. But we can indeed
simplify things by removing that explicit assignment in nft_netlink() so
mnl_batch_talk() consistently reports when if an error has happened.
Signee-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/mnl.c')
-rw-r--r-- | src/mnl.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -249,6 +249,7 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list) .tv_sec = 0, .tv_usec = 0 }; + int err = 0; ret = mnl_nft_socket_sendmsg(ctx); if (ret == -1) @@ -271,8 +272,10 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list) ret = mnl_cb_run(rcv_buf, ret, 0, portid, &netlink_echo_callback, ctx); /* Continue on error, make sure we get all acknowledgments */ - if (ret == -1) + if (ret == -1) { mnl_err_list_node_add(err_list, errno, nlh->nlmsg_seq); + err = -1; + } ret = select(fd+1, &readfds, NULL, NULL, &tv); if (ret == -1) @@ -281,7 +284,7 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list) FD_ZERO(&readfds); FD_SET(fd, &readfds); } - return ret; + return err; } int mnl_nft_rule_batch_add(struct nftnl_rule *nlr, struct nftnl_batch *batch, |