diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-17 15:35:15 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-18 01:57:43 +0200 |
commit | 5920b3eb38a6cfd1c9b87106aa7403171408f0bd (patch) | |
tree | fe6c96488ab537bebfeb07f658b4d500ba20c446 /bfdd/bfd.c | |
parent | Merge pull request #6248 from donaldsharp/zebra_snmp (diff) | |
download | frr-5920b3eb38a6cfd1c9b87106aa7403171408f0bd.tar.xz frr-5920b3eb38a6cfd1c9b87106aa7403171408f0bd.zip |
*: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.
Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/bfd.c')
-rw-r--r-- | bfdd/bfd.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bfdd/bfd.c b/bfdd/bfd.c index 49cb586db..f9e572db4 100644 --- a/bfdd/bfd.c +++ b/bfdd/bfd.c @@ -28,6 +28,7 @@ #include <zebra.h> #include "lib/jhash.h" +#include "lib/network.h" #include "bfd.h" @@ -236,8 +237,8 @@ static uint32_t ptm_bfd_gen_ID(void) * random session identification numbers. */ do { - session_id = ((random() << 16) & 0xFFFF0000) - | (random() & 0x0000FFFF); + session_id = ((frr_weak_random() << 16) & 0xFFFF0000) + | (frr_weak_random() & 0x0000FFFF); } while (session_id == 0 || bfd_id_lookup(session_id) != NULL); return session_id; @@ -258,7 +259,7 @@ void ptm_bfd_start_xmt_timer(struct bfd_session *bfd, bool is_echo) * between 75% and 90%. */ maxpercent = (bfd->detect_mult == 1) ? 16 : 26; - jitter = (xmt_TO * (75 + (random() % maxpercent))) / 100; + jitter = (xmt_TO * (75 + (frr_weak_random() % maxpercent))) / 100; /* XXX remove that division above */ if (is_echo) |