]> git.meshlink.io Git - meshlink/commitdiff
Always send MTU probes at least once every PingInterval.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 2 Jan 2011 14:02:23 +0000 (15:02 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 2 Jan 2011 14:02:23 +0000 (15:02 +0100)
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
src/protocol_key.c

index 9e5ef4654b3cc0ce007374cefe36724d67159986..aef55342353cac99096822d10d41c728f34c503e 100644 (file)
@@ -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;
        }
 }
 
index fbd7cabb8babafdd89fd09ac16a4fa46254bc8f8..e2e4be5db8ec8e90b0e61006c19d4d6a28c8b872 100644 (file)
@@ -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;