From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: phil@nwl.cc, eric@regit.org
Subject: [PATCH nft 5/6] mnl: pass struct netlink_ctx to mnl_nft_socket_sendmsg()
Date: Tue, 22 Aug 2017 19:05:10 +0200 [thread overview]
Message-ID: <1503421511-17814-6-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1503421511-17814-1-git-send-email-pablo@netfilter.org>
Reduce function footprint.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/mnl.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/mnl.c b/src/mnl.c
index 4f9c30c25d8f..e51c3294f76d 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -210,13 +210,12 @@ static void mnl_set_sndbuffer(const struct mnl_socket *nl,
nlbuffsiz = newbuffsiz;
}
-static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl,
- struct nftnl_batch *batch)
+static ssize_t mnl_nft_socket_sendmsg(const struct netlink_ctx *ctx)
{
static const struct sockaddr_nl snl = {
.nl_family = AF_NETLINK
};
- uint32_t iov_len = nftnl_batch_iovec_len(batch);
+ uint32_t iov_len = nftnl_batch_iovec_len(ctx->batch);
struct iovec iov[iov_len];
struct msghdr msg = {
.msg_name = (struct sockaddr *) &snl,
@@ -226,8 +225,8 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl,
};
uint32_t i;
- mnl_set_sndbuffer(nl, batch);
- nftnl_batch_iovec(batch, iov, iov_len);
+ mnl_set_sndbuffer(ctx->nf_sock, ctx->batch);
+ nftnl_batch_iovec(ctx->batch, iov, iov_len);
for (i = 0; i < iov_len; i++) {
if (debug_level & DEBUG_MNL) {
@@ -237,7 +236,7 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl,
}
}
- return sendmsg(mnl_socket_get_fd(nl), &msg, 0);
+ return sendmsg(mnl_socket_get_fd(ctx->nf_sock), &msg, 0);
}
int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list)
@@ -251,7 +250,7 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list)
.tv_usec = 0
};
- ret = mnl_nft_socket_sendmsg(nl, ctx->batch);
+ ret = mnl_nft_socket_sendmsg(ctx);
if (ret == -1)
return -1;
--
2.1.4
next prev parent reply other threads:[~2017-08-22 17:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 17:05 [PATCH nft 0/6] Remove more global variables Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 1/6] src: add include_paths to struct nft_ctx Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 2/6] src: add maximum number of parser errors " Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 3/6] src: remove ifdef DEBUG pollution Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 4/6] src: add struct mnl_ctx Pablo Neira Ayuso
2017-08-22 17:05 ` Pablo Neira Ayuso [this message]
2017-08-22 17:05 ` [PATCH nft 6/6] src: add debugging mask to context structure Pablo Neira Ayuso
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=1503421511-17814-6-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=eric@regit.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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).