]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - net/netfilter/xt_RATEEST.c
netfilter: xtables: change xt_target.checkentry return type
[mirror_ubuntu-jammy-kernel.git] / net / netfilter / xt_RATEEST.c
index d80b8192e0d423a2f66ec27ea06efbcaf174d681..9743e50be8ef78e895baf747dc3d789c82c5fa89 100644 (file)
@@ -23,6 +23,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)
 {
@@ -84,7 +85,7 @@ xt_rateest_tg(struct sk_buff *skb, const struct xt_target_param *par)
        return XT_CONTINUE;
 }
 
-static bool xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
+static int xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
 {
        struct xt_rateest_target_info *info = par->targinfo;
        struct xt_rateest *est;
@@ -93,6 +94,11 @@ static bool xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
                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) {
                /*
@@ -164,7 +170,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);
 }