From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>, <dev@dpdk.org>
Cc: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: RE: [RFC] eal: allow setting random number generator seed
Date: Sat, 12 Sep 2026 08:26:54 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65A3F@smartserver.smartshare.dk> (raw)
In-Reply-To: <20260911225845.3168061-1-stephen@networkplumber.org>
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, 12 September 2026 00.59
>
> 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
Might be useful.
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
next prev parent reply other threads:[~2026-09-12 6:27 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 [this message]
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 ` [RFC] " Marat Khalili
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=98CBD80474FA8B44BF855DF32C47DC35F65A3F@smartserver.smartshare.dk \
--to=mb@smartsharesystems.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.