diff options
author | Sven Eckelmann <sven@narfation.org> | 2020-04-13 21:23:29 +0200 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2020-04-21 10:07:31 +0200 |
commit | 26893e7e928e1790852b072edb9bff3c1309e111 (patch) | |
tree | d52f2653a1ea2c3ae24f44106156630c4db7263c /net/batman-adv/bat_iv_ogm.c | |
parent | 9204a4f876b229505f4ab947124d1160b80bbb4c (diff) | |
download | linux-26893e7e928e1790852b072edb9bff3c1309e111.tar.gz linux-26893e7e928e1790852b072edb9bff3c1309e111.tar.bz2 linux-26893e7e928e1790852b072edb9bff3c1309e111.zip |
batman-adv: Utilize prandom_u32_max for random [0, max) values
The kernel provides a function to create random values from 0 - (max-1)
since commit f337db64af05 ("random32: add prandom_u32_max and convert open
coded users"). Simply use this function to replace code sections which use
prandom_u32 and a handcrafted method to map it to the correct range.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index a7c8dd7ae513..e87f19c82e8d 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -280,7 +280,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv) unsigned int msecs; msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER; - msecs += prandom_u32() % (2 * BATADV_JITTER); + msecs += prandom_u32_max(2 * BATADV_JITTER); return jiffies + msecs_to_jiffies(msecs); } @@ -288,7 +288,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv) /* when do we schedule a ogm packet to be sent */ static unsigned long batadv_iv_ogm_fwd_send_time(void) { - return jiffies + msecs_to_jiffies(prandom_u32() % (BATADV_JITTER / 2)); + return jiffies + msecs_to_jiffies(prandom_u32_max(BATADV_JITTER / 2)); } /* apply hop penalty for a normal link */ |