netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] netfilter: meta: add PRANDOM support
Date: Tue, 16 Feb 2016 13:48:58 +0100	[thread overview]
Message-ID: <56C31ABA.1050801@iogearbox.net> (raw)
In-Reply-To: <1455624554-16005-1-git-send-email-fw@strlen.de>

Hi Florian,

On 02/16/2016 01:09 PM, Florian Westphal wrote:
> Can be used to randomly match a packet, e.g. for statistical traffic
> sampling.
>
> See commit 3ad0040573b0c00f8848
> ("bpf: split state from prandom_u32() and consolidate {c, e}BPF prngs")
> for more info why this doesn't use prandom_u32 directly.
>
> Unlike bpf nft_meta can be built as a module, so add an EXPORT_SYMBOL
> for prandom_seed_full_state too.
>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Florian Westphal <fw@strlen.de>
[...]
> @@ -241,6 +248,7 @@ int nft_meta_get_init(const struct nft_ctx *ctx,
>   {
>   	struct nft_meta *priv = nft_expr_priv(expr);
>   	unsigned int len;
> +	static bool prand_inited __read_mostly;
>
>   	priv->key = ntohl(nla_get_be32(tb[NFTA_META_KEY]));
>   	switch (priv->key) {
> @@ -277,6 +285,13 @@ int nft_meta_get_init(const struct nft_ctx *ctx,
>   	case NFT_META_OIFNAME:
>   		len = IFNAMSIZ;
>   		break;
> +	case NFT_META_PRANDOM:
> +		if (!prand_inited) {
> +			prandom_seed_full_state(&nft_prandom_state);
> +			prand_inited = true;
> +		}

Should this be: prandom_init_once() ?

> +		len = sizeof(u32);
> +		break;
>   	default:
>   		return -EOPNOTSUPP;
>   	}
>

Thanks,
Daniel

  reply	other threads:[~2016-02-16 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 12:09 [PATCH nf-next] netfilter: meta: add PRANDOM support Florian Westphal
2016-02-16 12:48 ` Daniel Borkmann [this message]
2016-02-16 13:19   ` Florian Westphal
2016-02-16 13:56     ` Daniel Borkmann
2016-02-16 14:09       ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C31ABA.1050801@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).