diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-22 20:41:03 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-23 20:28:22 +0200 |
commit | a72315d2bad47d99a18376290dd62336ca94ed95 (patch) | |
tree | f0c194f4ac38b1363b58fc33cd83c2b547b52bcb /include/netlink.h | |
parent | e391b72b611403d184bbb26e3d076d543c7ea7c6 (diff) |
src: add rule batching support
This patch allows nft to put all rule update messages into one
single batch that is sent to the kernel if `-f' option is used.
In order to provide fine grain error reporting, I decided to
to correlate the netlink message sequence number with the
correspoding command sequence number, which is the same. Thus,
nft can identify what rules trigger problems inside a batch
and report them accordingly.
Moreover, to avoid playing buffer size games at batch building
stage, ie. guess what is the final size of the batch for this
ruleset update will be, this patch collects batch pages that
are converted to iovec to ensure linearization when the batch
is sent to the kernel. This reduces the amount of unnecessary
memory usage that is allocated for the batch.
This patch uses the libmnl nlmsg batching infrastructure and it
requires the kernel patch entitled (netfilter: nfnetlink: add batch
support and use it from nf_tables).
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/netlink.h')
-rw-r--r-- | include/netlink.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/netlink.h b/include/netlink.h index bdff7f44..85e84343 100644 --- a/include/netlink.h +++ b/include/netlink.h @@ -19,12 +19,14 @@ * @list: list of parsed rules/chains/tables * @set: current set * @data: pointer to pass data to callback + * @seqnum: sequence number */ struct netlink_ctx { struct list_head *msgs; struct list_head list; struct set *set; const void *data; + uint32_t seqnum; }; extern struct nft_table *alloc_nft_table(const struct handle *h); @@ -69,6 +71,14 @@ extern int netlink_add_rule(struct netlink_ctx *ctx, const struct handle *h, const struct rule *rule, uint32_t flags); extern int netlink_delete_rule(struct netlink_ctx *ctx, const struct handle *h, const struct location *loc); +extern int netlink_add_rule_list(struct netlink_ctx *ctx, const struct handle *h, + struct list_head *rule_list); +extern int netlink_add_rule_batch(struct netlink_ctx *ctx, + const struct handle *h, + const struct rule *rule, uint32_t flags); +extern int netlink_del_rule_batch(struct netlink_ctx *ctx, + const struct handle *h, + const struct location *loc); extern int netlink_add_chain(struct netlink_ctx *ctx, const struct handle *h, const struct location *loc, @@ -122,4 +132,8 @@ extern void netlink_dump_rule(struct nft_rule *nlr); extern void netlink_dump_expr(struct nft_rule_expr *nle); extern void netlink_dump_set(struct nft_set *nls); +extern int netlink_batch_send(struct list_head *err_list); +extern int netlink_io_error(struct netlink_ctx *ctx, + const struct location *loc, const char *fmt, ...); + #endif /* NFTABLES_NETLINK_H */ |