ALSA: hda - Add support for Thinkpad Edge conexant chip
[safe/jmp/linux-2.6] / net / netfilter / xt_RATEEST.c
index da7946e..d16d55d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/jhash.h>
 #include <linux/rtnetlink.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <net/gen_stats.h>
 #include <net/netlink.h>
 
@@ -23,6 +24,7 @@ static DEFINE_MUTEX(xt_rateest_mutex);
 #define RATEEST_HSIZE  16
 static struct hlist_head rateest_hash[RATEEST_HSIZE] __read_mostly;
 static unsigned int jhash_rnd __read_mostly;
+static bool rnd_inited __read_mostly;
 
 static unsigned int xt_rateest_hash(const char *name)
 {
@@ -71,15 +73,10 @@ void xt_rateest_put(struct xt_rateest *est)
 EXPORT_SYMBOL_GPL(xt_rateest_put);
 
 static unsigned int
-xt_rateest_tg(struct sk_buff *skb,
-             const struct net_device *in,
-             const struct net_device *out,
-             unsigned int hooknum,
-             const struct xt_target *target,
-             const void *targinfo)
+xt_rateest_tg(struct sk_buff *skb, const struct xt_target_param *par)
 {
-       const struct xt_rateest_target_info *info = targinfo;
-       struct gnet_stats_basic *stats = &info->est->bstats;
+       const struct xt_rateest_target_info *info = par->targinfo;
+       struct gnet_stats_basic_packed *stats = &info->est->bstats;
 
        spin_lock_bh(&info->est->lock);
        stats->bytes += skb->len;
@@ -89,20 +86,20 @@ xt_rateest_tg(struct sk_buff *skb,
        return XT_CONTINUE;
 }
 
-static bool
-xt_rateest_tg_checkentry(const char *tablename,
-                        const void *entry,
-                        const struct xt_target *target,
-                        void *targinfo,
-                        unsigned int hook_mask)
+static bool xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
 {
-       struct xt_rateest_target_info *info = targinfo;
+       struct xt_rateest_target_info *info = par->targinfo;
        struct xt_rateest *est;
        struct {
                struct nlattr           opt;
                struct gnet_estimator   est;
        } cfg;
 
+       if (unlikely(!rnd_inited)) {
+               get_random_bytes(&jhash_rnd, sizeof(jhash_rnd));
+               rnd_inited = true;
+       }
+
        est = xt_rateest_lookup(info->name);
        if (est) {
                /*
@@ -149,10 +146,9 @@ err1:
        return false;
 }
 
-static void xt_rateest_tg_destroy(const struct xt_target *target,
-                                 void *targinfo)
+static void xt_rateest_tg_destroy(const struct xt_tgdtor_param *par)
 {
-       struct xt_rateest_target_info *info = targinfo;
+       struct xt_rateest_target_info *info = par->targinfo;
 
        xt_rateest_put(info->est);
 }
@@ -175,7 +171,6 @@ static int __init xt_rateest_tg_init(void)
        for (i = 0; i < ARRAY_SIZE(rateest_hash); i++)
                INIT_HLIST_HEAD(&rateest_hash[i]);
 
-       get_random_bytes(&jhash_rnd, sizeof(jhash_rnd));
        return xt_register_target(&xt_rateest_tg_reg);
 }