From 337636fc670eaed5c7146f99af8719018f63fe3b Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 19 May 2014 12:18:04 +0200 Subject: src: add set netlink message to the batch This patch moves the netlink set messages to the batch that contains the rules. This helps to speed up rule-set restoration time by changing the operational. To achieve this, an internal set ID which is unique to the batch is allocated as suggested by Patrick. To retain backward compatibility, nft initially guesses if the kernel supports set in batches. Otherwise, it falls back to the previous (slowier) operational. Signed-off-by: Pablo Neira Ayuso --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 9d505776..a446bc68 100644 --- a/src/main.c +++ b/src/main.c @@ -170,6 +170,7 @@ static int nft_netlink(struct parser_state *state, struct list_head *msgs) struct mnl_err *err, *tmp; LIST_HEAD(err_list); uint32_t batch_seqnum; + bool batch_supported = netlink_batch_supported(); int ret = 0; batch_seqnum = mnl_batch_begin(); @@ -177,6 +178,7 @@ static int nft_netlink(struct parser_state *state, struct list_head *msgs) memset(&ctx, 0, sizeof(ctx)); ctx.msgs = msgs; ctx.seqnum = cmd->seqnum = mnl_seqnum_alloc(); + ctx.batch_supported = batch_supported; init_list_head(&ctx.list); ret = do_command(&ctx, cmd); if (ret < 0) -- cgit v1.2.3