summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2017-08-14 17:47:21 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-08-15 14:03:41 +0200
commit0d9d04c31481c7c73b4ba64f0ad746b84c4250c5 (patch)
tree60713cea11ad785cfba3ceff19983e5394b97d2a /src/main.c
parent2caecefe812e4d614687926d259ade3106935c56 (diff)
src: make netlink sequence number non-static
Place sequence number that is allocated per-command on the struct netlink_ctx structure. This is allocated from nft_run() to correlate commands with netlink messages for error reporting. Batch support probing also shares this sequence numbers with commands. There is an inpendent cache sequence number though, this routine is called from a different path, usually from the evaluation phase. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 2e77ee0a..88839598 100644
--- a/src/main.c
+++ b/src/main.c
@@ -191,22 +191,22 @@ static int nft_netlink(struct nft_ctx *nft, struct nft_cache *cache,
struct parser_state *state, struct list_head *msgs,
struct mnl_socket *nf_sock)
{
+ uint32_t batch_seqnum, seqnum = 0;
struct nftnl_batch *batch;
struct netlink_ctx ctx;
struct cmd *cmd;
struct mnl_err *err, *tmp;
LIST_HEAD(err_list);
- uint32_t batch_seqnum;
- bool batch_supported = netlink_batch_supported(nf_sock);
+ bool batch_supported = netlink_batch_supported(nf_sock, &seqnum);
int ret = 0;
batch = mnl_batch_init();
- batch_seqnum = mnl_batch_begin(batch);
+ batch_seqnum = mnl_batch_begin(batch, mnl_seqnum_alloc(&seqnum));
list_for_each_entry(cmd, &state->cmds, list) {
memset(&ctx, 0, sizeof(ctx));
ctx.msgs = msgs;
- ctx.seqnum = cmd->seqnum = mnl_seqnum_alloc();
+ ctx.seqnum = cmd->seqnum = mnl_seqnum_alloc(&seqnum);
ctx.batch = batch;
ctx.batch_supported = batch_supported;
ctx.octx = &nft->output;
@@ -218,7 +218,7 @@ static int nft_netlink(struct nft_ctx *nft, struct nft_cache *cache,
goto out;
}
if (!nft->check)
- mnl_batch_end(batch);
+ mnl_batch_end(batch, mnl_seqnum_alloc(&seqnum));
if (!mnl_batch_ready(batch))
goto out;