summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/gsm322.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2018-07-07 21:51:09 +0100
committerHolger Freyther <holger@freyther.de>2018-07-11 21:13:11 +0000
commit6d49b049ee304f1ea0e4801df61e69713b01f0f8 (patch)
tree3ffca58aced050916dc0f4d6c62c7a6354aa53b9 /src/host/layer23/src/mobile/gsm322.c
parentc36dc296321af23b171903fd0ad3cf8d7e552ab2 (diff)
Move from libc random() to osmo_get_rand_id
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(). Change-Id: Ie0cc64663cd4b90c027b79545dc5d3ac9d87b9dd
Diffstat (limited to 'src/host/layer23/src/mobile/gsm322.c')
-rw-r--r--src/host/layer23/src/mobile/gsm322.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c
index c3485b6a..ce25cd57 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -959,7 +959,9 @@ static int gsm322_sort_list(struct osmocom_ms *ms)
entries++;
}
while(entries) {
- move = random() % entries;
+ if (osmo_get_rand_id((uint8_t *) &move, sizeof(move)) != 0)
+ move = random();
+ move = move % entries;
i = 0;
llist_for_each_entry(temp, &temp_list, entry) {
if (rxlev2dbm(temp->rxlev) > -85) {