From e64b07d7a4e45330359a4950f3dd2fabaa2fcfd8 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 31 Jul 2024 16:48:48 +0200 Subject: [PATCH] internet_checksum.run: don't use bad trafgen seeds --- repos/os/run/internet_checksum.run | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/repos/os/run/internet_checksum.run b/repos/os/run/internet_checksum.run index 8801c98e5b..2187b3de27 100644 --- a/repos/os/run/internet_checksum.run +++ b/repos/os/run/internet_checksum.run @@ -17,13 +17,21 @@ proc exit {{code 0}} { build { core init lib/ld lib/vfs test/internet_checksum server/lx_fs } create_boot_directory -set seed "" +proc gen_seed { } { + set min_seed 0 + set max_seed [expr 2**32] + return [expr int($min_seed + floor(rand() * $max_seed))] +} + +set seed 0 if {[info exists ::env(SEED)]} { set seed $::env(SEED) } else { - set min_seed 0 - set max_seed [expr 2**32] - set seed [expr int($min_seed + floor(rand() * $max_seed))] + # in some cases trafgen generates bad checksums in encapsulated packets + set bad_seeds [list 0 875727356 ] + while {[lsearch -exact $bad_seeds $seed] != -1} { + set seed [gen_seed] + } } puts "\nUse script with SEED=$seed in order to get reproducible results\n"