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 --- include/mnl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/mnl.h') diff --git a/include/mnl.h b/include/mnl.h index ece7ee7f..f25dd533 100644 --- a/include/mnl.h +++ b/include/mnl.h @@ -53,16 +53,24 @@ int mnl_nft_table_get(struct mnl_socket *nf_sock, struct nft_table *nlt, int mnl_nft_set_add(struct mnl_socket *nf_sock, struct nft_set *nls, unsigned int flags); +int mnl_nft_set_batch_add(struct mnl_socket *nf_sock, struct nft_set *nls, + unsigned int flags, uint32_t seq); int mnl_nft_set_delete(struct mnl_socket *nf_sock, struct nft_set *nls, unsigned int flags); +int mnl_nft_set_batch_del(struct mnl_socket *nf_sock, struct nft_set *nls, + unsigned int flags, uint32_t seq); struct nft_set_list *mnl_nft_set_dump(struct mnl_socket *nf_sock, int family, const char *table); int mnl_nft_set_get(struct mnl_socket *nf_sock, struct nft_set *nls); int mnl_nft_setelem_add(struct mnl_socket *nf_sock, struct nft_set *nls, unsigned int flags); +int mnl_nft_setelem_batch_add(struct mnl_socket *nf_sock, struct nft_set *nls, + unsigned int flags, uint32_t seq); int mnl_nft_setelem_delete(struct mnl_socket *nf_sock, struct nft_set *nls, unsigned int flags); +int mnl_nft_setelem_batch_del(struct mnl_socket *nf_sock, struct nft_set *nls, + unsigned int flags, uint32_t seq); int mnl_nft_setelem_get(struct mnl_socket *nf_sock, struct nft_set *nls); struct nft_ruleset *mnl_nft_ruleset_dump(struct mnl_socket *nf_sock, @@ -70,4 +78,7 @@ struct nft_ruleset *mnl_nft_ruleset_dump(struct mnl_socket *nf_sock, int mnl_nft_event_listener(struct mnl_socket *nf_sock, int (*cb)(const struct nlmsghdr *nlh, void *data), void *cb_data); + +bool mnl_batch_supported(struct mnl_socket *nf_sock); + #endif /* _NFTABLES_MNL_H_ */ -- cgit v1.2.3