netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH nft] mnl: use nft_batch_begin and nft_batch_end from libnftnl
Date: Tue, 30 Sep 2014 19:34:37 +0200	[thread overview]
Message-ID: <1412098477-8811-1-git-send-email-pablo@netfilter.org> (raw)

Use the existing functions in libnftnl to begin and end a batch.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/mnl.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/src/mnl.c b/src/mnl.c
index b01e91c..bc8b7ea 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -192,33 +192,20 @@ static void nft_batch_continue(void)
 		nft_batch_page_add();
 }
 
-static uint32_t mnl_batch_put(int type)
+uint32_t mnl_batch_begin(void)
 {
-	struct nlmsghdr *nlh;
-	struct nfgenmsg *nfg;
-
-	nlh = mnl_nlmsg_put_header(nft_nlmsg_batch_current());
-	nlh->nlmsg_type = type;
-	nlh->nlmsg_flags = NLM_F_REQUEST;
-	nlh->nlmsg_seq = mnl_seqnum_alloc();
+	uint32_t seq = mnl_seqnum_alloc();
 
-	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(nft_nlmsg_batch_current(), seq);
 	nft_batch_continue();
 
-	return nlh->nlmsg_seq;
-}
-
-uint32_t mnl_batch_begin(void)
-{
-	return mnl_batch_put(NFNL_MSG_BATCH_BEGIN);
+	return seq;
 }
 
 void mnl_batch_end(void)
 {
-	mnl_batch_put(NFNL_MSG_BATCH_END);
+	nft_batch_end(nft_nlmsg_batch_current(), mnl_seqnum_alloc());
+	nft_batch_continue();
 }
 
 bool mnl_batch_ready(void)
-- 
1.7.10.4


                 reply	other threads:[~2014-09-30 17:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412098477-8811-1-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).