From a9fdd76fa32e5aeedd82f3fe1c3df0d5ec62c7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 10 Jan 2020 09:56:13 +0000 Subject: [PATCH] Code cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mud.c b/mud.c index a4eb7aa..1cba9ee 100644 --- a/mud.c +++ b/mud.c @@ -1426,6 +1426,22 @@ mud_cleanup_path(struct mud *mud, uint64_t now, struct mud_path *path) return path->state <= MUD_DOWN; } +static int +mud_path_is_ok(struct mud *mud, struct mud_path *path) +{ + if (!path->mtu.ok) + return 0; + + if (path->tx.loss > mud->loss_limit) + return 0; + + if (mud->peer.set) + return 1; + + return !mud_timeout(mud->last_recv_time, path->rx.time, + MUD_MSG_SENT_MAX * path->conf.msg_timeout); +} + int mud_update(struct mud *mud) { @@ -1461,11 +1477,7 @@ mud_update(struct mud *mud) } else { path->msg.sent = MUD_MSG_SENT_MAX; } - } else if (path->mtu.ok && - (path->tx.loss <= mud->loss_limit) && - (mud->peer.set || - !mud_timeout(mud->last_recv_time, path->rx.time, - MUD_MSG_SENT_MAX * path->conf.msg_timeout))) { + } else if (mud_path_is_ok(mud, path)) { if (path->state != MUD_BACKUP) mud->backup = 0; rate += path->tx.rate;