|WARNING| [v2] eal: allow setting random number generator seed
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Sat Sep 12 18:44:53 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/169439
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-12
# DPDK Patch Review
## PATCH: eal: allow setting random number generator seed
### Summary
This patch adds support for overriding the automatic random seed via the `DPDK_RANDOM_SEED` environment variable. The implementation reads the environment variable during `eal_rand_init()` and uses `strtoull()` to parse it.
---
## Errors
None found.
---
## Warnings
### 1. Missing release notes update
**Issue:** This patch adds new user-visible functionality (environment variable support) but does not include a release notes update.
**Why it matters:** Users need to be informed about new features and environment variables that affect behavior.
**Suggested fix:** Add an entry to the current release notes file under a "New Features" section:
```rst
* **Added ability to set random seed via environment variable.**
The random number generator seed can now be overridden by setting
the ``DPDK_RANDOM_SEED`` environment variable, useful for reproducible
testing. The variable accepts values in decimal, hexadecimal (0x prefix),
or octal (0 prefix) format.
```
### 2. getenv() in lib/eal/common/
**Issue:** `getenv()` is called in `lib/eal/common/rte_random.c`.
**Context:** While `getenv()` is generally discouraged outside of EAL init paths, this usage is acceptable because:
- It occurs during `eal_rand_init()`, which is part of the EAL initialization sequence
- The environment variable is read once at startup, not during runtime
- This is consistent with other EAL environment variable handling
**This is actually acceptable**, but document for awareness: the guidelines flag `getenv()` in `lib/` directories, but allow it in EAL init contexts. This usage falls into the permitted category.
---
## Info
### 1. Error message formatting consistency
**Observation:** The error message uses `rte_exit(EXIT_FAILURE, "invalid DPDK_RANDOM_SEED: %s\n", env);`
**Consider:** For consistency with other EAL error messages, you might include more specific guidance:
```c
rte_exit(EXIT_FAILURE,
"DPDK_RANDOM_SEED must be a valid 64-bit unsigned integer: %s\n", env);
```
This makes it clearer what format is expected (though the current message is acceptable).
### 2. Documentation completeness
**Observation:** The header comment update clearly documents the new functionality.
**Good practice confirmed:** The comment properly explains:
- When the override is useful (testing)
- How to use it (environment variable name)
- That it affects the initial seed only
---
## Summary
The patch is **correct** and follows DPDK coding standards. The only actionable item is:
- **Warning:** Add release notes entry for the new environment variable feature
The `getenv()` usage, while flagged by the general rule, is appropriate in this EAL initialization context. The code is clean, has proper error handling, and the documentation is clear.
More information about the test-report
mailing list