From f99661a4ca5bacff47239ce7978b9c9948917c54 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 2 Jan 2011 15:02:23 +0100 Subject: [PATCH] Always send MTU probes at least once every PingInterval. Before, if MTU probes failed, tinc would stop sending probes until the next time keys were regenerated (by default, once every hour). Now it continues to send them every PingInterval, so it recovers faster from temporary failures. --- src/net_packet.c | 20 +++++++++++++++----- src/protocol_key.c | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/net_packet.c b/src/net_packet.c index 9e5ef465..aef55342 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -85,16 +85,21 @@ void send_mtu_probe(node_t *n) { } if(n->mtuprobes > 32) { + if(!n->minmtu) { + n->mtuprobes = 31; + timeout = pinginterval; + goto end; + } + ifdebug(TRAFFIC) logger(LOG_INFO, "%s (%s) did not respond to UDP ping, restarting PMTU discovery", n->name, n->hostname); n->mtuprobes = 1; n->minmtu = 0; n->maxmtu = MTU; } - if(n->mtuprobes >= 10 && !n->minmtu) { + if(n->mtuprobes >= 10 && n->mtuprobes < 32 && !n->minmtu) { ifdebug(TRAFFIC) logger(LOG_INFO, "No response to MTU probes from %s (%s)", n->name, n->hostname); - n->mtuprobes = 0; - return; + n->mtuprobes = 31; } if(n->mtuprobes == 30 || (n->mtuprobes < 30 && n->minmtu >= n->maxmtu)) { @@ -148,12 +153,17 @@ void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { packet->data[0] = 1; send_udppacket(n, packet); } else { + if(n->mtuprobes > 30) { + if(n->minmtu) + n->mtuprobes = 30; + else + n->mtuprobes = 1; + } + if(len > n->maxmtu) len = n->maxmtu; if(n->minmtu < len) n->minmtu = len; - if(n->mtuprobes > 30) - n->mtuprobes = 30; } } diff --git a/src/protocol_key.c b/src/protocol_key.c index fbd7cabb..e2e4be5d 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -310,7 +310,7 @@ bool ans_key_h(connection_t *c) { update_node_udp(from, &sa); } - if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuprobes) + if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuevent) send_mtu_probe(from); return true; -- 2.20.1