From patchwork Tue Sep 30 17:35:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 395054 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2C9D61400A8 for ; Wed, 1 Oct 2014 03:34:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbaI3Reu (ORCPT ); Tue, 30 Sep 2014 13:34:50 -0400 Received: from mail.us.es ([193.147.175.20]:53329 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636AbaI3Reu (ORCPT ); Tue, 30 Sep 2014 13:34:50 -0400 Received: (qmail 16414 invoked from network); 30 Sep 2014 19:34:49 +0200 Received: from unknown (HELO us.es) (192.168.2.13) by us.es with SMTP; 30 Sep 2014 19:34:49 +0200 Received: (qmail 4856 invoked by uid 507); 30 Sep 2014 17:34:49 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus3 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.4/19455. spamassassin: 3.3.2. Clear:RC:1(127.0.0.1):SA:0(-99.6/7.5):. Processed in 14.159248 secs); 30 Sep 2014 17:34:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on antivirus3 X-Spam-Level: X-Spam-Status: No, score=-99.6 required=7.5 tests=BAYES_50,RCVD_IN_BRBL, RCVD_IN_BRBL_LASTEXT,RCVD_IN_PBL,RCVD_IN_RP_RNBL,RCVD_IN_SORBS_DUL, RDNS_DYNAMIC, SMTPAUTH_US, USER_IN_WHITELIST autolearn=disabled version=3.3.2 X-Spam-ASN: AS12715 87.221.0.0/16 X-Envelope-From: pablo@netfilter.org Received: from unknown (HELO antivirus3) (127.0.0.1) by us.es with SMTP; 30 Sep 2014 17:34:35 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus3 (F-Secure/fsigk_smtp/412/antivirus3); Tue, 30 Sep 2014 19:34:35 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus3) Received: (qmail 28964 invoked from network); 30 Sep 2014 19:34:34 +0200 Received: from 152.88.221.87.dynamic.jazztel.es (HELO localhost.localdomain) (pneira@us.es@87.221.88.152) by mail.us.es with SMTP; 30 Sep 2014 19:34:34 +0200 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH iptables-compat 1/2] iptables-compat: nft: use nft_batch_begin and nft_batch_end from libnftnl Date: Tue, 30 Sep 2014 19:35:45 +0200 Message-Id: <1412098546-8952-1-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 1.7.10.4 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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(-) diff --git a/iptables/nft.c b/iptables/nft.c index e3b07e0..8c91e99 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 {