From 2c5eb574f9a17aa543b3f19de2478dc8b85f86c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Wed, 14 Mar 2018 18:47:43 +0000 Subject: [PATCH] Add a specific timer for mtu probing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 35 ++++++++++++++++++++--------------- mud.h | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mud.c b/mud.c index b97f302..9a32996 100644 --- a/mud.c +++ b/mud.c @@ -1273,6 +1273,25 @@ mud_recv(struct mud *mud, void *data, size_t size) return ret; } +static void +mud_probe_mtu(struct mud *mud, struct mud_path *path, uint64_t now) +{ + if ((!path->rtt) || + (!mud_timeout(now, path->mtu.time, path->rtt)) || + (path->mtu.probe == path->r_rms + 1) || + (path->r_rms == MUD_PACKET_MAX_SIZE)) + return; + + if (path->mtu.probe > path->mtu.ok) { + path->mtu.probe = (path->mtu.probe + path->mtu.ok) >> 1; + } else { + path->mtu.probe = (MUD_PACKET_MAX_SIZE + path->mtu.ok + 1) >> 1; + } + + mud_packet_send(mud, mud_fake, path, now, 0); + path->mtu.time = now; +} + static void mud_update(struct mud *mud, uint64_t now) { @@ -1302,21 +1321,7 @@ mud_update(struct mud *mud, uint64_t now) path->conf.send_time = now; } - if ((!path->rtt) || - (!mud_timeout(now, path->send_max_time, path->rtt))) - continue; - - if ((path->mtu.probe == path->r_rms + 1) || - (path->r_rms == MUD_PACKET_MAX_SIZE)) - continue; - - if (path->mtu.probe > path->mtu.ok) { - path->mtu.probe = (path->mtu.probe + path->mtu.ok) >> 1; - } else { - path->mtu.probe = (MUD_PACKET_MAX_SIZE + path->mtu.ok + 1) >> 1; - } - - mud_packet_send(mud, mud_fake, path, now, 0); + mud_probe_mtu(mud, path, now); } } diff --git a/mud.h b/mud.h index fdeb9b9..84103be 100644 --- a/mud.h +++ b/mud.h @@ -39,6 +39,7 @@ struct mud_path { struct { size_t ok; size_t probe; + uint64_t time; } mtu; };