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:
Sven Eckelmann 2017-12-20 12:37:18 +01:00 committed by Jan-Philipp Litza
parent a6298493f7
commit c9f661740c
No known key found for this signature in database
GPG Key ID: 1FB658053CE27196

View File

@ -533,6 +533,14 @@ static int fork_execvp_timeout(struct timespec *timeout, const char *file, const
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) {
struct timespec timeout = {
.tv_nsec = EBTABLES_TIMEOUT,
@ -540,7 +548,7 @@ static void update_ebtables(void) {
char mac[F_MAC_LEN + 1];
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",
F_MAC_VAR(G.best_router->src),
G.best_router->tq,