Commit 233ca7ce52 for frr
commit 233ca7ce5250810ce3662d274f1247b9a6abe6aa
Author: Dave Seddon <dave.seddon.ca@gmail.com>
Date: Sat Nov 28 22:10:26 2026 -0800
pimd: fix the Candidate-BSR address delay
RFC 5059 gives the address part of BS_Rand_Override for a lower
priority candidate as 2 - (myAddr / 2^31), a delay of 0 to 2 seconds
that is shorter for higher addresses.
The divisor was written as (float)(1 << 31), which is -2^31, so the
delay was 2 + (myAddr / 2^31): 2 to 4 seconds, and longer for higher
addresses. For 192.168.0.1 that is 3.5 seconds instead of 0.5.
Use an unsigned constant.
Fixes: 2d0812373c3c ("pimd: Candidate-BSR support")
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index c887e1157b..72daa72922 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -1916,7 +1916,7 @@ static void pim_cand_bsr_pending(struct bsm_scope *scope)
} else {
prio_delay = 2. * log2(1 + best_prio - scope->cand_bsr_prio);
addr_delay = 2 - (ntohl(scope->bsr_addrsel.run_addr.s_addr) /
- (float)(1 << 31));
+ (float)(1U << 31));
}
#else
if (scope->cand_bsr_prio == best_prio) {
@@ -1927,7 +1927,7 @@ static void pim_cand_bsr_pending(struct bsm_scope *scope)
prio_delay = 2. * log2(1 + best_prio - scope->cand_bsr_prio);
addr_delay = 2 -
(ntohl(scope->bsr_addrsel.run_addr.s6_addr32[0]) /
- (float)(1 << 31));
+ (float)(1U << 31));
}
#endif