From: Stephen Hemminger <stephen@networkplumber.org>
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
Date: Fri, 11 Sep 2026 15:58:45 -0700 [thread overview]
Message-ID: <20260911225845.3168061-1-stephen@networkplumber.org> (raw)
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
next reply other threads:[~2026-09-11 22:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:58 Stephen Hemminger [this message]
2026-09-12 6:26 ` [RFC] eal: allow setting random number generator seed 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 ` [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=20260911225845.3168061-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=mattias.ronnblom@ericsson.com \
/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.