Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / net / netfilter / nfnetlink_acct.c
index dbd0803b18273bbf3b37e7f0f5bfae87d5acfc2d..70eb2f6a3b015d365788ae0e625294f97c383d5c 100644 (file)
@@ -162,15 +162,18 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
                pkts = atomic64_read(&acct->pkts);
                bytes = atomic64_read(&acct->bytes);
        }
-       if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) ||
-           nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) ||
+       if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts),
+                        NFACCT_PAD) ||
+           nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes),
+                        NFACCT_PAD) ||
            nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt))))
                goto nla_put_failure;
        if (acct->flags & NFACCT_F_QUOTA) {
                u64 *quota = (u64 *)acct->data;
 
                if (nla_put_be32(skb, NFACCT_FLAGS, htonl(old_flags)) ||
-                   nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota)))
+                   nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota),
+                                NFACCT_PAD))
                        goto nla_put_failure;
        }
        nlmsg_end(skb, nlh);
@@ -323,14 +326,14 @@ static int nfnl_acct_try_del(struct nf_acct *cur)
 {
        int ret = 0;
 
-       /* we want to avoid races with nfnl_acct_find_get. */
-       if (atomic_dec_and_test(&cur->refcnt)) {
+       /* We want to avoid races with nfnl_acct_put. So only when the current
+        * refcnt is 1, we decrease it to 0.
+        */
+       if (atomic_cmpxchg(&cur->refcnt, 1, 0) == 1) {
                /* We are protected by nfnl mutex. */
                list_del_rcu(&cur->head);
                kfree_rcu(cur, rcu_head);
        } else {
-               /* still in use, restore reference counter. */
-               atomic_inc(&cur->refcnt);
                ret = -EBUSY;
        }
        return ret;
@@ -440,7 +443,7 @@ void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct)
 }
 EXPORT_SYMBOL_GPL(nfnl_acct_update);
 
-static void nfnl_overquota_report(struct nf_acct *nfacct)
+static void nfnl_overquota_report(struct net *net, struct nf_acct *nfacct)
 {
        int ret;
        struct sk_buff *skb;
@@ -455,11 +458,12 @@ static void nfnl_overquota_report(struct nf_acct *nfacct)
                kfree_skb(skb);
                return;
        }
-       netlink_broadcast(init_net.nfnl, skb, 0, NFNLGRP_ACCT_QUOTA,
+       netlink_broadcast(net->nfnl, skb, 0, NFNLGRP_ACCT_QUOTA,
                          GFP_ATOMIC);
 }
 
-int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
+int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb,
+                       struct nf_acct *nfacct)
 {
        u64 now;
        u64 *quota;
@@ -477,7 +481,7 @@ int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
 
        if (now >= *quota &&
            !test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) {
-               nfnl_overquota_report(nfacct);
+               nfnl_overquota_report(net, nfacct);
        }
 
        return ret;
This page took 0.037102 seconds and 5 git commands to generate.