Skip to contentSkip to conversation

nfnetlink_queue: use proper net to allocate skb

PATCH Applied Gao feng 2 participants 4 messages Sep 23, 2013 – Sep 27, 2013

Subsystems (2)
lore
Share & tools
lore

Gao feng

author
#0 lore raw

PATCH 1/2 nfnetlink_queue: use proper net to allocate skb

Use proper net struct to allocate skb,otherwise
netlink mmap will be of no effect.

---
 net/netfilter/nfnetlink_queue_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/netfilter/nfnetlink_queue_core.c +4 -3
index ae2e5c1..678106d 100644
@@ -298,7 +298,8 @@ nfqnl_put_packet_info(struct sk_buff *nlskb, struct sk_buff *packet,
 }
 
 static struct sk_buff *
-nfqnl_build_packet_message(struct nfqnl_instance *queue,
+nfqnl_build_packet_message(struct net *net,
+			   struct nfqnl_instance *queue,
 			   struct nf_queue_entry *entry,
 			   __be32 **packet_id_ptr)
 {
@@ -372,7 +373,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
 	if (queue->flags & NFQA_CFG_F_CONNTRACK)
 		ct = nfqnl_ct_get(entskb, &size, &ctinfo);
 
-	skb = nfnetlink_alloc_skb(&init_net, size, queue->peer_portid,
+	skb = nfnetlink_alloc_skb(net, size, queue->peer_portid,
 				  GFP_ATOMIC);
 	if (!skb)
 		return NULL;
@@ -525,7 +526,7 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
 	__be32 *packet_id_ptr;
 	int failopen = 0;
 
-	nskb = nfqnl_build_packet_message(queue, entry, &packet_id_ptr);
+	nskb = nfqnl_build_packet_message(net, queue, entry, &packet_id_ptr);
 	if (nskb == NULL) {
 		err = -ENOMEM;
 		goto err_out;
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 2/2 nfnetlink_log: use proper net to allocate skb

Use proper net struct to allocate skb, otherwise
netlink mmap will be of no effect.

---
 net/netfilter/nfnetlink_log.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
net/netfilter/nfnetlink_log.c +9 -5
index d92cc31..71e39d2 100644
@@ -318,8 +318,10 @@ nfulnl_set_flags(struct nfulnl_instance *inst, u_int16_t flags)
 	return 0;
 }
 
-static struct sk_buff *
-nfulnl_alloc_skb(u32 peer_portid, unsigned int inst_size, unsigned int pkt_size)
+static struct sk_buff * nfulnl_alloc_skb(struct net *net,
+					 u32 peer_portid,
+					 unsigned int inst_size,
+					 unsigned int pkt_size)
 {
 	struct sk_buff *skb;
 	unsigned int n;
@@ -328,13 +330,13 @@ nfulnl_alloc_skb(u32 peer_portid, 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 = nfnetlink_alloc_skb(&init_net, n, peer_portid, GFP_ATOMIC);
+	skb = nfnetlink_alloc_skb(net, n, peer_portid, GFP_ATOMIC);
 	if (!skb) {
 		if (n > pkt_size) {
 			/* try to allocate only as much as we need for current
 			 * packet */
 
-			skb = nfnetlink_alloc_skb(&init_net, pkt_size,
+			skb = nfnetlink_alloc_skb(net, pkt_size,
 						  peer_portid, GFP_ATOMIC);
 			if (!skb)
 				pr_err("nfnetlink_log: can't even alloc %u bytes\n",
@@ -702,7 +704,9 @@ nfulnl_log_packet(struct net *net,
 	}
 
 	if (!inst->skb) {
-		inst->skb = nfulnl_alloc_skb(inst->peer_portid, inst->nlbufsiz,
+		inst->skb = nfulnl_alloc_skb(net,
+					     inst->peer_portid,
+					     inst->nlbufsiz,
 					     size);
 		if (!inst->skb)
 			goto alloc_failure;
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH 2/2] nfnetlink_log: use proper net to allocate skb

Quoted 2 lines · Gao feng

Use proper net struct to allocate skb, otherwise
netlink mmap will be of no effect.

Also applied, thanks Gao.