Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / net / netfilter / nfnetlink_log.c
index 8e7bf641e0964a3df76b9ffead203a090d123cab..faf1e9300d8adc358fa857ff4296892351060193 100644 (file)
@@ -3,6 +3,7 @@
  * nfetlink.
  *
  * (C) 2005 by Harald Welte <laforge@netfilter.org>
+ * (C) 2006-2012 Patrick McHardy <kaber@trash.net>
  *
  * Based on the old ipv4-only ipt_ULOG.c:
  * (C) 2000-2004 by Harald Welte <laforge@netfilter.org>
@@ -19,7 +20,7 @@
 #include <linux/ipv6.h>
 #include <linux/netdevice.h>
 #include <linux/netfilter.h>
-#include <linux/netlink.h>
+#include <net/netlink.h>
 #include <linux/netfilter/nfnetlink.h>
 #include <linux/netfilter/nfnetlink_log.h>
 #include <linux/spinlock.h>
@@ -318,7 +319,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_portid, unsigned int inst_size, unsigned int pkt_size)
 {
        struct sk_buff *skb;
        unsigned int n;
@@ -327,13 +328,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_portid, 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_portid, GFP_ATOMIC);
                        if (!skb)
                                pr_err("nfnetlink_log: can't even alloc %u bytes\n",
                                       pkt_size);
@@ -632,7 +634,7 @@ nfulnl_log_packet(u_int8_t pf,
        /* FIXME: do we want to make the size calculation conditional based on
         * what is actually present?  way more branches and checks, but more
         * memory efficient... */
-       size =    NLMSG_SPACE(sizeof(struct nfgenmsg))
+       size =    nlmsg_total_size(sizeof(struct nfgenmsg))
                + nla_total_size(sizeof(struct nfulnl_msg_packet_hdr))
                + nla_total_size(sizeof(u_int32_t))     /* ifindex */
                + nla_total_size(sizeof(u_int32_t))     /* ifindex */
@@ -696,7 +698,8 @@ 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_portid, inst->nlbufsiz,
+                                            size);
                if (!inst->skb)
                        goto alloc_failure;
        }
@@ -824,7 +827,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
 
                        inst = instance_create(net, group_num,
                                               NETLINK_CB(skb).portid,
-                                              sk_user_ns(NETLINK_CB(skb).ssk));
+                                              sk_user_ns(NETLINK_CB(skb).sk));
                        if (IS_ERR(inst)) {
                                ret = PTR_ERR(inst);
                                goto out;