From 1f932f08a17c55f1689a432433f9f2a0cf6f014f Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 30 Sep 2014 17:52:15 +0200 Subject: iptables-compat: nft: use nft_batch_begin and nft_batch_end from libnftnl Use the existing functions in libnftnl to begin and end a batch. Signed-off-by: Pablo Neira Ayuso --- iptables/nft.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'iptables/nft.c') diff --git a/iptables/nft.c b/iptables/nft.c index e3b07e03..8c91e998 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -240,34 +240,18 @@ static int mnl_nft_batch_talk(struct nft_handle *h) return err ? -1 : 0; } -static void mnl_nft_batch_put(struct mnl_nlmsg_batch *batch, int type, - uint32_t seq) +static void mnl_nft_batch_begin(struct mnl_nlmsg_batch *batch, uint32_t seq) { - struct nlmsghdr *nlh; - struct nfgenmsg *nfg; - - nlh = mnl_nlmsg_put_header(mnl_nlmsg_batch_current(batch)); - nlh->nlmsg_type = type; - nlh->nlmsg_flags = NLM_F_REQUEST; - nlh->nlmsg_seq = seq; - - nfg = mnl_nlmsg_put_extra_header(nlh, sizeof(*nfg)); - nfg->nfgen_family = AF_INET; - nfg->version = NFNETLINK_V0; - nfg->res_id = NFNL_SUBSYS_NFTABLES; - + nft_batch_begin(mnl_nlmsg_batch_current(batch), seq); if (!mnl_nlmsg_batch_next(batch)) mnl_nft_batch_page_add(batch); } -static void mnl_nft_batch_begin(struct mnl_nlmsg_batch *batch, uint32_t seq) -{ - mnl_nft_batch_put(batch, NFNL_MSG_BATCH_BEGIN, seq); -} - static void mnl_nft_batch_end(struct mnl_nlmsg_batch *batch, uint32_t seq) { - mnl_nft_batch_put(batch, NFNL_MSG_BATCH_END, seq); + nft_batch_end(mnl_nlmsg_batch_current(batch), seq); + if (!mnl_nlmsg_batch_next(batch)) + mnl_nft_batch_page_add(batch); } enum obj_update_type { -- cgit v1.2.3