diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-07-21 22:20:49 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-07-23 20:55:45 +0100 |
commit | 812866daab20dbb9242d7b3a7f417f6d0e1d8a0e (patch) | |
tree | e1c46e87d74000766d043e3d2b07731b8104b4d0 /src/host/layer23/src/mobile/gsm48_mm.c | |
parent | fd33dcc2023dad960157023b7d5de586612dc5f5 (diff) |
Move from libc random() to osmo_get_rand_id (2nd attempt)
When starting multiple mobile in the same second, the libc random number
generator will be seeded to exactly the same value.
The random bits inside the RACH request(s) will be exactly the same
across multiple mobile and when the channel fails they all pick the same
randomized back-off timing.
Use stronger random numbers and replace all calls to random(2) with
osmo_get_rand_id. Add a fallback to try random().
[v2: Add helper to make sure the result is int and between 0 and
RAND_MAX]
Change-Id: Icdd4be88c62bba1e9d954568e48f0c12a67ac182
Diffstat (limited to 'src/host/layer23/src/mobile/gsm48_mm.c')
-rw-r--r-- | src/host/layer23/src/mobile/gsm48_mm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c index a7af1f5c..02d861e8 100644 --- a/src/host/layer23/src/mobile/gsm48_mm.c +++ b/src/host/layer23/src/mobile/gsm48_mm.c @@ -41,6 +41,7 @@ #include <osmocom/bb/mobile/app_mobile.h> #include <osmocom/bb/mobile/primitives.h> #include <osmocom/bb/mobile/vty.h> +#include <osmocom/bb/common/utils.h> extern void *l23_ctx; @@ -2099,7 +2100,7 @@ static int gsm48_mm_sysinfo(struct osmocom_ms *ms, struct msgb *msg) mm->t3212.timeout.tv_sec = current_time.tv_sec + (t % s->t3212); } else { - uint32_t rand = random(); + uint32_t rand = layer23_random(); LOGP(DMM, LOGL_INFO, "New T3212 while timer is not " "running (value %d)\n", s->t3212); |