summaryrefslogtreecommitdiff
path: root/net/netfilter/nft_meta.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-12-18 12:05:19 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2019-12-26 17:41:34 +0100
commit6b2faee0ca91b63bd5a3b2087d4f25c76b983961 (patch)
tree88b941e882a3624869a46ce53eb8e184fc41975d /net/netfilter/nft_meta.c
parent8724e819cc9a8fab4c18e791cb0bd602fb294971 (diff)
netfilter: nft_meta: place prandom handling in a helper
Move this out of the main eval loop, the numgen expression provides a better alternative to meta random. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/nft_meta.c')
-rw-r--r--net/netfilter/nft_meta.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 022f1473ddd1..ac6fc95387dc 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -266,6 +266,13 @@ static bool nft_meta_get_eval_ifname(enum nft_meta_keys key, u32 *dest,
return true;
}
+static noinline u32 nft_prandom_u32(void)
+{
+ struct rnd_state *state = this_cpu_ptr(&nft_prandom_state);
+
+ return prandom_u32_state(state);
+}
+
void nft_meta_get_eval(const struct nft_expr *expr,
struct nft_regs *regs,
const struct nft_pktinfo *pkt)
@@ -344,11 +351,9 @@ void nft_meta_get_eval(const struct nft_expr *expr,
goto err;
break;
#endif
- case NFT_META_PRANDOM: {
- struct rnd_state *state = this_cpu_ptr(&nft_prandom_state);
- *dest = prandom_u32_state(state);
+ case NFT_META_PRANDOM:
+ *dest = nft_prandom_u32();
break;
- }
#ifdef CONFIG_XFRM
case NFT_META_SECPATH:
nft_reg_store8(dest, secpath_exists(skb));