]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pathd: Convert to use our internal frr_weak_random
authorDonald Sharp <sharpd@nvidia.com>
Tue, 5 Jan 2021 16:10:19 +0000 (11:10 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 5 Jan 2021 20:37:32 +0000 (15:37 -0500)
rand() should not be used, we should be using the frr_weak_random()
call instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
pathd/path_pcep_controller.c
pathd/pathd.c

index e467a79a8727544066e85eab9bfb51f0fa68492e..255503b4591b52ed136550ebb0706a3add0790e8 100644 (file)
@@ -26,6 +26,7 @@
 #include "northbound.h"
 #include "frr_pthread.h"
 #include "jhash.h"
+#include "network.h"
 
 #include "pathd/pathd.h"
 #include "pathd/path_errors.h"
@@ -1043,7 +1044,7 @@ void remove_pcc_state(struct ctrl_state *ctrl_state,
 uint32_t backoff_delay(uint32_t max, uint32_t base, uint32_t retry_count)
 {
        uint32_t a = min(max, base * (1 << retry_count));
-       uint64_t r = rand(), m = RAND_MAX;
+       uint64_t r = frr_weak_random(), m = RAND_MAX;
        uint32_t b = (a / 2) + (r * (a / 2)) / m;
        return b;
 }
index 2e2fa8671410e80f11c97502eeaf0975f52ad14d..e2c7c957280e430c39e992d466d2b2c565878b48 100644 (file)
@@ -21,6 +21,7 @@
 #include "memory.h"
 #include "log.h"
 #include "lib_errors.h"
+#include "network.h"
 
 #include "pathd/pathd.h"
 #include "pathd/path_memory.h"
@@ -480,7 +481,7 @@ struct srte_candidate *srte_candidate_add(struct srte_policy *policy,
        candidate->preference = preference;
        candidate->policy = policy;
        candidate->type = SRTE_CANDIDATE_TYPE_UNDEFINED;
-       candidate->discriminator = rand();
+       candidate->discriminator = frr_weak_random();
 
        lsp->candidate = candidate;
        candidate->lsp = lsp;