diff options
-rw-r--r-- | vlib-api/vlibapi/api_shared.c | 1 | ||||
-rw-r--r-- | vnet/vnet/ip/ip6_neighbor.c | 9 | ||||
-rw-r--r-- | vppinfra/vppinfra/random.h | 17 |
3 files changed, 12 insertions, 15 deletions
diff --git a/vlib-api/vlibapi/api_shared.c b/vlib-api/vlibapi/api_shared.c index c133922cabd..511f693849d 100644 --- a/vlib-api/vlibapi/api_shared.c +++ b/vlib-api/vlibapi/api_shared.c @@ -896,6 +896,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, || (am->msg_endian_handlers[msg_id] == 0)) { vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id); + munmap (hp, file_size); return; } endian_fp = am->msg_endian_handlers[msg_id]; diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c index 5585c95824f..cebe09a9557 100644 --- a/vnet/vnet/ip/ip6_neighbor.c +++ b/vnet/vnet/ip/ip6_neighbor.c @@ -1881,11 +1881,10 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, a->min_delay_between_radv = MIN_DELAY_BETWEEN_RAS; a->max_delay_between_radv = MAX_DELAY_BETWEEN_RAS; a->max_rtr_default_lifetime = MAX_DEF_RTR_LIFETIME; - a->seed = random_default_seed(); - - /* for generating random interface ids */ - a->randomizer = 0x1119194911191949ULL; - a->randomizer = random_u64 ((u32 *)&a->randomizer); + a->seed = (u32) clib_cpu_time_now(); + (void) random_u32 (&a->seed); + a->randomizer = clib_cpu_time_now(); + (void) random_u64 (&a->randomizer); a->initial_adverts_count = MAX_INITIAL_RTR_ADVERTISEMENTS ; a->initial_adverts_sent = a->initial_adverts_count-1; diff --git a/vppinfra/vppinfra/random.h b/vppinfra/vppinfra/random.h index fad05898350..5c139d05490 100644 --- a/vppinfra/vppinfra/random.h +++ b/vppinfra/vppinfra/random.h @@ -119,17 +119,14 @@ random_default_seed (void) #endif /** \brief 64-bit random number generator - - created via two calls to random_u32(). Quick and dirty. -*/ + * Again, constants courtesy of Donald Knuth. + * + */ always_inline u64 -random_u64 (u32 * seed) +random_u64 (u64 * seed) { - u64 result; - - result = (u64) random_u32 (seed) << 32; - result |= random_u32 (seed); - return result; + *seed = 6364136223846793005ULL * *seed + 1442695040888963407ULL; + return *seed; } /** \brief machine word size random number generator */ @@ -138,7 +135,7 @@ always_inline uword random_uword (u32 * seed) { if (sizeof (uword) == sizeof (u64)) - return random_u64 (seed); + return random_u64 ((u64 *) seed); else return random_u32 (seed); } |