]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - net/netfilter/nfnetlink_log.c
[NET]: Wrap hard_header_parse
[mirror_ubuntu-zesty-kernel.git] / net / netfilter / nfnetlink_log.c
index e185a5b55913ce8b37af7de85b5e9a9f8b46f2e1..332e0f7f6f9eb0085e43e39fbc0fa08e0b770e43 100644 (file)
@@ -58,7 +58,6 @@ struct nfulnl_instance {
 
        unsigned int qlen;              /* number of nlmsgs in skb */
        struct sk_buff *skb;            /* pre-allocatd skb */
-       struct nlmsghdr *lastnlh;       /* netlink header of last msg in skb */
        struct timer_list timer;
        int peer_pid;                   /* PID of the peer process */
 
@@ -345,10 +344,12 @@ static struct sk_buff *nfulnl_alloc_skb(unsigned int inst_size,
 static int
 __nfulnl_send(struct nfulnl_instance *inst)
 {
-       int status;
+       int status = -1;
 
        if (inst->qlen > 1)
-               inst->lastnlh->nlmsg_type = NLMSG_DONE;
+               NLMSG_PUT(inst->skb, 0, 0,
+                         NLMSG_DONE,
+                         sizeof(struct nfgenmsg));
 
        status = nfnetlink_unicast(inst->skb, inst->peer_pid, MSG_DONTWAIT);
        if (status < 0) {
@@ -358,8 +359,8 @@ __nfulnl_send(struct nfulnl_instance *inst)
 
        inst->qlen = 0;
        inst->skb = NULL;
-       inst->lastnlh = NULL;
 
+nlmsg_failure:
        return status;
 }
 
@@ -480,12 +481,13 @@ __build_packet_message(struct nfulnl_instance *inst,
                NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint);
        }
 
-       if (indev && skb->dev && skb->dev->hard_header_parse) {
+       if (indev && skb->dev) {
                struct nfulnl_msg_packet_hw phw;
-               int len = skb->dev->hard_header_parse((struct sk_buff *)skb,
-                                                   phw.hw_addr);
-               phw.hw_addrlen = htons(len);
-               NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
+               int len = dev_parse_header(skb, phw.hw_addr);
+               if (len > 0) {
+                       phw.hw_addrlen = htons(len);
+                       NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
+               }
        }
 
        if (skb->tstamp.tv64) {
@@ -538,7 +540,6 @@ __build_packet_message(struct nfulnl_instance *inst,
        }
 
        nlh->nlmsg_len = inst->skb->tail - old_tail;
-       inst->lastnlh = nlh;
        return 0;
 
 nlmsg_failure:
@@ -644,7 +645,8 @@ nfulnl_log_packet(unsigned int pf,
        }
 
        if (inst->qlen >= qthreshold ||
-           (inst->skb && size > skb_tailroom(inst->skb))) {
+           (inst->skb && size >
+            skb_tailroom(inst->skb) - sizeof(struct nfgenmsg))) {
                /* either the queue len is too high or we don't have
                 * enough room in the skb left. flush to userspace. */
                UDEBUG("flushing old skb\n");
@@ -705,7 +707,8 @@ nfulnl_rcv_nl_event(struct notifier_block *this,
 
                        hlist_for_each_entry_safe(inst, tmp, t2, head, hlist) {
                                UDEBUG("node = %p\n", inst);
-                               if (n->pid == inst->peer_pid)
+                               if ((n->net == &init_net) &&
+                                   (n->pid == inst->peer_pid))
                                        __instance_destroy(inst);
                        }
                }