Skip to content

Commit f4495ba

Browse files
shemmingerdavid-marchand
authored andcommitted
examples/l2fwd-keepalive: use a better random generator
There is a better way than using rand() to compute a random interval. Signed-off-by: Stephen Hemminger <[email protected]>
1 parent 59c1eb3 commit f4495ba

File tree

1 file changed

+1
-1
lines changed
  • examples/l2fwd-keepalive

1 file changed

+1
-1
lines changed

examples/l2fwd-keepalive/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ l2fwd_main_loop(void)
220220
}
221221

222222
uint64_t tsc_initial = rte_rdtsc();
223-
uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz();
223+
uint64_t tsc_lifetime = rte_rand_max(8 * rte_get_tsc_hz());
224224

225225
while (!terminate_signal_received) {
226226
/* Keepalive heartbeat. 8< */

0 commit comments

Comments
 (0)