netfilter: nf_conntrack: use SLAB_DESTROY_BY_RCU and get rid of call_rcu()
[pandora-kernel.git] / net / netfilter / nf_conntrack_helper.c
index 9e4b74b..30b8e90 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/rculist.h>
+#include <linux/rtnetlink.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
@@ -141,6 +142,7 @@ int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
 
        BUG_ON(me->expect_policy == NULL);
        BUG_ON(me->expect_class_max >= NF_CT_MAX_EXPECT_CLASSES);
+       BUG_ON(strlen(me->name) > NF_CT_HELPER_NAME_LEN - 1);
 
        mutex_lock(&nf_ct_helper_mutex);
        hlist_add_head_rcu(&me->hnode, &nf_ct_helper_hash[h]);
@@ -157,6 +159,7 @@ static void __nf_conntrack_helper_unregister(struct nf_conntrack_helper *me,
        struct nf_conntrack_tuple_hash *h;
        struct nf_conntrack_expect *exp;
        const struct hlist_node *n, *next;
+       const struct hlist_nulls_node *nn;
        unsigned int i;
 
        /* Get rid of expectations */
@@ -173,10 +176,10 @@ static void __nf_conntrack_helper_unregister(struct nf_conntrack_helper *me,
        }
 
        /* Get rid of expecteds, set helpers to NULL. */
-       hlist_for_each_entry(h, n, &net->ct.unconfirmed, hnode)
+       hlist_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode)
                unhelp(h, me);
        for (i = 0; i < nf_conntrack_htable_size; i++) {
-               hlist_for_each_entry(h, n, &net->ct.hash[i], hnode)
+               hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
                        unhelp(h, me);
        }
 }
@@ -195,10 +198,12 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
         */
        synchronize_rcu();
 
+       rtnl_lock();
        spin_lock_bh(&nf_conntrack_lock);
        for_each_net(net)
                __nf_conntrack_helper_unregister(me, net);
        spin_unlock_bh(&nf_conntrack_lock);
+       rtnl_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
 
@@ -214,7 +219,7 @@ int nf_conntrack_helper_init(void)
 
        nf_ct_helper_hsize = 1; /* gets rounded up to use one page */
        nf_ct_helper_hash = nf_ct_alloc_hashtable(&nf_ct_helper_hsize,
-                                                 &nf_ct_helper_vmalloc);
+                                                 &nf_ct_helper_vmalloc, 0);
        if (!nf_ct_helper_hash)
                return -ENOMEM;