From: Marat Khalili <marat.khalili@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: RE: [RFC] eal: allow setting random number generator seed
Date: Mon, 14 Sep 2026 09:05:37 +0000 [thread overview]
Message-ID: <5458e4f73262413ba38c2708fbaf6980@huawei.com> (raw)
In-Reply-To: <20260911225845.3168061-1-stephen@networkplumber.org>
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday 11 September 2026 23:59
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> Subject: [RFC] eal: allow setting random number generator seed
>
> Many performance tests use rte_rand() and the random number
> can perturb the results. Add an ability to overide the automatic
> random seed on DPDK startup.
>
> This is not a security problem since rte_rand() is documented
> as not being cryptographically secure.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> lib/eal/common/rte_random.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c
> index 576a32a46c..cdad60049b 100644
> --- a/lib/eal/common/rte_random.c
> +++ b/lib/eal/common/rte_random.c
> @@ -247,7 +247,18 @@ eal_rand_init(void)
>
> RTE_LCORE_VAR_ALLOC(rand_state);
>
> - seed = __rte_random_initial_seed();
> + const char *env = getenv("DPDK_RANDOM_SEED");
> + if (env != NULL && *env != '\0') {
> + char *end;
> +
> + errno = 0;
> + seed = strtoull(env, &end, 0);
> + if (errno != 0 || *end != '\0')
> + rte_exit(EXIT_FAILURE,
> + "invalid DPDK_RANDOM_SEED: %s\n", env);
> + } else {
> + seed = __rte_random_initial_seed();
> + }
>
> rte_srand(seed);
> }
> --
> 2.53.0
Lgtm, although as a minor nit `env` is maybe not the best name here.
Regardless,
Acked-by: Marat Khalili <marat.khalili@huawei.com>
prev parent reply other threads:[~2026-09-14 9:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:58 [RFC] eal: allow setting random number generator seed Stephen Hemminger
2026-09-12 6:26 ` Morten Brørup
2026-09-12 16:16 ` [PATCH v2] " Stephen Hemminger
2026-09-14 11:29 ` Mattias Rönnblom
2026-09-14 12:04 ` Konstantin Ananyev
2026-09-14 16:47 ` Stephen Hemminger
2026-09-14 16:46 ` Stephen Hemminger
2026-09-14 9:05 ` Marat Khalili [this message]
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=5458e4f73262413ba38c2708fbaf6980@huawei.com \
--to=marat.khalili@huawei.com \
--cc=dev@dpdk.org \
--cc=mattias.ronnblom@ericsson.com \
--cc=stephen@networkplumber.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.