gluon-radv-filterd: Fix integer underflow with low TQs
The TQ of the best router can be lower than the hysteresis_thresh. The check could cause an integer underflow which then causes an election which is not necessary. This can be avoided by reordering the check slightly and only substracting values which will not cause underflows. Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
c9f661740c
commit
8251de682a
@ -538,7 +538,14 @@ static bool election_required(void)
|
||||
if (!G.best_router)
|
||||
return true;
|
||||
|
||||
return G.best_router->tq < G.max_tq - G.hysteresis_thresh;
|
||||
/* should never happen. G.max_tq also contains G.best_router->tq */
|
||||
if (G.max_tq < G.best_router->tq)
|
||||
return false;
|
||||
|
||||
if ((G.max_tq - G.best_router->tq) <= G.hysteresis_thresh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void update_ebtables(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user