From: Patrick McHardy <kaber@trash.net>
To: Florian.Westphal@Sophos.com
Cc: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: [PATCH 09/11] nfnetlink: add support for memory mapped netlink
Date: Mon, 20 Aug 2012 08:18:50 +0200 [thread overview]
Message-ID: <1345443532-3707-10-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1345443532-3707-1-git-send-email-kaber@trash.net>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/linux/netfilter/nfnetlink.h | 2 ++
net/netfilter/nfnetlink.c | 7 +++++++
net/netfilter/nfnetlink_log.c | 9 +++++----
net/netfilter/nfnetlink_queue_core.c | 2 +-
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 18341cd..447d1a7 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -81,6 +81,8 @@ extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);
extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
extern int nfnetlink_has_listeners(struct net *net, unsigned int group);
+extern struct sk_buff *nfnetlink_alloc_skb(struct net *net, unsigned int size,
+ u32 dst_pid, gfp_t gfp_mask);
extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group,
int echo, gfp_t flags);
extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error);
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index a265033..d0aa9fc 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -111,6 +111,13 @@ int nfnetlink_has_listeners(struct net *net, unsigned int group)
}
EXPORT_SYMBOL_GPL(nfnetlink_has_listeners);
+struct sk_buff *nfnetlink_alloc_skb(struct net *net, unsigned int size,
+ u32 dst_pid, gfp_t gfp_mask)
+{
+ return netlink_alloc_skb(net->nfnl, size, dst_pid, gfp_mask);
+}
+EXPORT_SYMBOL_GPL(nfnetlink_alloc_skb);
+
int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid,
unsigned int group, int echo, gfp_t flags)
{
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 169ab59..6232ca8 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -296,7 +296,7 @@ nfulnl_set_flags(struct nfulnl_instance *inst, u_int16_t flags)
}
static struct sk_buff *
-nfulnl_alloc_skb(unsigned int inst_size, unsigned int pkt_size)
+nfulnl_alloc_skb(u32 peer_pid, unsigned int inst_size, unsigned int pkt_size)
{
struct sk_buff *skb;
unsigned int n;
@@ -305,13 +305,14 @@ nfulnl_alloc_skb(unsigned int inst_size, unsigned int pkt_size)
* message. WARNING: has to be <= 128k due to slab restrictions */
n = max(inst_size, pkt_size);
- skb = alloc_skb(n, GFP_ATOMIC);
+ skb = nfnetlink_alloc_skb(&init_net, n, peer_pid, GFP_ATOMIC);
if (!skb) {
if (n > pkt_size) {
/* try to allocate only as much as we need for current
* packet */
- skb = alloc_skb(pkt_size, GFP_ATOMIC);
+ skb = nfnetlink_alloc_skb(&init_net, pkt_size, peer_pid,
+ GFP_ATOMIC);
if (!skb)
pr_err("nfnetlink_log: can't even alloc %u bytes\n",
pkt_size);
@@ -658,7 +659,7 @@ nfulnl_log_packet(u_int8_t pf,
}
if (!inst->skb) {
- inst->skb = nfulnl_alloc_skb(inst->nlbufsiz, size);
+ inst->skb = nfulnl_alloc_skb(inst->peer_pid, inst->nlbufsiz, size);
if (!inst->skb)
goto alloc_failure;
}
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index c0496a5..6983b2e 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -272,7 +272,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
if (queue->flags & NFQA_CFG_F_CONNTRACK)
ct = nfqnl_ct_get(entskb, &size, &ctinfo);
- skb = alloc_skb(size, GFP_ATOMIC);
+ skb = nfnetlink_alloc_skb(&init_net, size, queue->peer_pid, GFP_ATOMIC);
if (!skb)
return NULL;
--
1.7.7.6
next prev parent reply other threads:[~2012-08-20 6:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-20 6:18 [PATCH 00/11] netlink: memory mapped I/O Patrick McHardy
2012-08-20 6:18 ` [PATCH 01/11] netlink: add symbolic value for congested state Patrick McHardy
2012-08-20 6:18 ` [PATCH 02/11] net: add function to allocate skbuff head without data area Patrick McHardy
2012-08-20 6:39 ` Eric Dumazet
2012-08-20 6:41 ` Patrick McHardy
2012-08-20 6:18 ` [PATCH 03/11] netlink: don't orphan skb in netlink_trim() Patrick McHardy
2012-08-20 6:18 ` [PATCH 04/11] netlink: add netlink_skb_set_owner_r() Patrick McHardy
2012-08-20 6:18 ` [PATCH 05/11] netlink: mmaped netlink: ring setup Patrick McHardy
2012-08-20 6:18 ` [PATCH 06/11] netlink: add mmap'ed netlink helper functions Patrick McHardy
2012-08-20 6:18 ` [PATCH 07/11] netlink: implement memory mapped sendmsg() Patrick McHardy
2012-08-20 6:18 ` [PATCH 08/11] netlink: implement memory mapped recvmsg() Patrick McHardy
2012-08-20 6:18 ` Patrick McHardy [this message]
2012-08-20 6:18 ` [PATCH 10/11] netlink: add flow control for memory mapped I/O Patrick McHardy
2012-08-20 6:18 ` [PATCH 11/11] netlink: add documentation " Patrick McHardy
2012-08-20 10:32 ` Jan Engelhardt
2012-08-22 22:19 ` Patrick McHardy
2012-08-22 9:29 ` [PATCH 00/11] netlink: " David Miller
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=1345443532-3707-10-git-send-email-kaber@trash.net \
--to=kaber@trash.net \
--cc=Florian.Westphal@Sophos.com \
--cc=netdev@vger.kernel.org \
--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).