diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-05-29 19:04:26 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-05-29 19:26:03 +0200 |
commit | 4cb962e4e447dd9ebd13177fca040dd1ff9b8632 (patch) | |
tree | b212c19a8fa2441c3937d6d2422ed2c73ff80456 /src/main.c | |
parent | 73ee6f7f4d76c442fb7a3ba3087061b4eef604e3 (diff) |
src: remove global nftnl_batch structure in mnl layer
The underlying mnl layer uses a global nftnl_batch structure. Instead,
pass pointer as parameter to the functions that need this. The netlink
layer stores a reference to this structure in struct netlink_ctx.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -180,6 +180,7 @@ static const struct input_descriptor indesc_cmdline = { static int nft_netlink(struct parser_state *state, struct list_head *msgs) { + struct nftnl_batch *batch; struct netlink_ctx ctx; struct cmd *cmd; struct mnl_err *err, *tmp; @@ -188,25 +189,26 @@ static int nft_netlink(struct parser_state *state, struct list_head *msgs) bool batch_supported = netlink_batch_supported(); int ret = 0; - mnl_batch_init(); + batch = mnl_batch_init(); - batch_seqnum = mnl_batch_begin(); + batch_seqnum = mnl_batch_begin(batch); list_for_each_entry(cmd, &state->cmds, list) { memset(&ctx, 0, sizeof(ctx)); ctx.msgs = msgs; ctx.seqnum = cmd->seqnum = mnl_seqnum_alloc(); + ctx.batch = batch; ctx.batch_supported = batch_supported; init_list_head(&ctx.list); ret = do_command(&ctx, cmd); if (ret < 0) goto out; } - mnl_batch_end(); + mnl_batch_end(batch); - if (!mnl_batch_ready()) + if (!mnl_batch_ready(batch)) goto out; - ret = netlink_batch_send(&err_list); + ret = netlink_batch_send(&ctx, &err_list); list_for_each_entry_safe(err, tmp, &err_list, head) { list_for_each_entry(cmd, &state->cmds, list) { @@ -225,7 +227,7 @@ static int nft_netlink(struct parser_state *state, struct list_head *msgs) } } out: - mnl_batch_reset(); + mnl_batch_reset(batch); return ret; } |