gluon-radv-filterd: Move election prereq checks into function
The check of prerequisitions is rather long and becomes unreadable. Having it in an extra function makes the code slightly more structured and better readable. Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
a6298493f7
commit
c9f661740c
@ -533,6 +533,14 @@ static int fork_execvp_timeout(struct timespec *timeout, const char *file, const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool election_required(void)
|
||||||
|
{
|
||||||
|
if (!G.best_router)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return G.best_router->tq < G.max_tq - G.hysteresis_thresh;
|
||||||
|
}
|
||||||
|
|
||||||
static void update_ebtables(void) {
|
static void update_ebtables(void) {
|
||||||
struct timespec timeout = {
|
struct timespec timeout = {
|
||||||
.tv_nsec = EBTABLES_TIMEOUT,
|
.tv_nsec = EBTABLES_TIMEOUT,
|
||||||
@ -540,7 +548,7 @@ static void update_ebtables(void) {
|
|||||||
char mac[F_MAC_LEN + 1];
|
char mac[F_MAC_LEN + 1];
|
||||||
struct router *router;
|
struct router *router;
|
||||||
|
|
||||||
if (G.best_router && G.best_router->tq >= G.max_tq - G.hysteresis_thresh) {
|
if (!election_required()) {
|
||||||
DEBUG_MSG(F_MAC " is still good enough with TQ=%d (max_tq=%d), not executing ebtables",
|
DEBUG_MSG(F_MAC " is still good enough with TQ=%d (max_tq=%d), not executing ebtables",
|
||||||
F_MAC_VAR(G.best_router->src),
|
F_MAC_VAR(G.best_router->src),
|
||||||
G.best_router->tq,
|
G.best_router->tq,
|
||||||
|
Loading…
Reference in New Issue
Block a user