Merge pull request #16995 from benpicco/backport/2021.10/dhcpv6_client/bug/fix-retrans-calc
dhcpv6_client: keep integers in retransmission calculations signed [backport 2021.10]
This commit is contained in:
commit
67249d4e40
@ -473,6 +473,8 @@ static inline uint32_t _irt_ms(uint16_t irt, bool greater_irt)
|
|||||||
if (greater_irt && (factor < 0)) {
|
if (greater_irt && (factor < 0)) {
|
||||||
factor = -factor;
|
factor = -factor;
|
||||||
}
|
}
|
||||||
|
/* random factor is also in ms, but it is supposed to be without unit,
|
||||||
|
* so we need to divide by ms */
|
||||||
irt_ms += (factor * irt_ms) / MS_PER_SEC;
|
irt_ms += (factor * irt_ms) / MS_PER_SEC;
|
||||||
return irt_ms;
|
return irt_ms;
|
||||||
}
|
}
|
||||||
@ -480,12 +482,18 @@ static inline uint32_t _irt_ms(uint16_t irt, bool greater_irt)
|
|||||||
static inline uint32_t _sub_rt_ms(uint32_t rt_prev_ms, uint16_t mrt)
|
static inline uint32_t _sub_rt_ms(uint32_t rt_prev_ms, uint16_t mrt)
|
||||||
{
|
{
|
||||||
uint32_t sub_rt_ms = (2 * rt_prev_ms) +
|
uint32_t sub_rt_ms = (2 * rt_prev_ms) +
|
||||||
((get_rand_ms_factor() * rt_prev_ms) / MS_PER_SEC);
|
/* random factor is also in ms, but it is supposed to
|
||||||
|
* be without unit, so we need to divide by ms */
|
||||||
|
((int32_t)(get_rand_ms_factor() * rt_prev_ms) /
|
||||||
|
(int32_t)MS_PER_SEC);
|
||||||
|
|
||||||
if (sub_rt_ms > (mrt * MS_PER_SEC)) {
|
if (sub_rt_ms > (mrt * MS_PER_SEC)) {
|
||||||
uint32_t mrt_ms = mrt * MS_PER_SEC;
|
uint32_t mrt_ms = mrt * MS_PER_SEC;
|
||||||
|
|
||||||
sub_rt_ms = mrt_ms + ((get_rand_ms_factor() * mrt_ms) / MS_PER_SEC);
|
/* random factor is also in ms, but it is supposed to be without unit,
|
||||||
|
* so we need to divide by ms */
|
||||||
|
sub_rt_ms = mrt_ms + ((int32_t)(get_rand_ms_factor() * mrt_ms) /
|
||||||
|
(int32_t)MS_PER_SEC);
|
||||||
}
|
}
|
||||||
return sub_rt_ms;
|
return sub_rt_ms;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user