- for(i = 0; i < 3; i++) {
- if(n->mtuprobes >= 30 || n->minmtu >= n->maxmtu) {
- n->mtu = n->minmtu;
- ifdebug(TRAFFIC) logger(LOG_INFO, _("Fixing MTU of %s (%s) to %d after %d probes"), n->name, n->hostname, n->mtu, n->mtuprobes);
- return;
+ if(n->mtuprobes > 32) {
+ if(!n->minmtu) {
+ n->mtuprobes = 31;
+ timeout = mesh->dev_class_traits[n->devclass].pinginterval;
+ goto end;
+ }
+
+ logger(mesh, MESHLINK_INFO, "%s did not respond to UDP ping, restarting PMTU discovery", n->name);
+ n->status.udp_confirmed = false;
+ n->mtuprobes = 1;
+ n->minmtu = 0;
+ n->maxmtu = MTU;
+
+ update_node_pmtu(mesh, n);
+ }
+
+ if(n->mtuprobes >= 10 && n->mtuprobes < 32 && !n->minmtu) {
+ logger(mesh, MESHLINK_INFO, "No response to MTU probes from %s", n->name);
+ n->mtuprobes = 31;
+ }
+
+ if(n->mtuprobes == 30 || (n->mtuprobes < 30 && n->minmtu >= n->maxmtu)) {
+ if(n->minmtu > n->maxmtu) {
+ n->minmtu = n->maxmtu;
+ update_node_pmtu(mesh, n);
+ } else {
+ n->maxmtu = n->minmtu;
+ }
+
+ n->mtu = n->minmtu;
+ logger(mesh, MESHLINK_INFO, "Fixing MTU of %s to %d after %d probes", n->name, n->mtu, n->mtuprobes);
+ n->mtuprobes = 31;
+ }
+
+ if(n->mtuprobes == 31) {
+ if(!n->minmtu && n->status.want_udp) {
+ /* Send a dummy ANS_KEY to try to update the reflexive UDP address */
+ send_request(mesh, n->nexthop->connection, NULL, "%d %s %s . -1 -1 -1 0", ANS_KEY, mesh->self->name, n->name);
+ n->status.want_udp = false;
+ }
+
+ timeout = mesh->dev_class_traits[n->devclass].pinginterval;
+ goto end;
+ } else if(n->mtuprobes == 32) {
+ timeout = mesh->dev_class_traits[n->devclass].pingtimeout;
+ }
+
+ for(int i = 0; i < 5; i++) {
+ int len;
+
+ if(i == 0) {
+ if(n->mtuprobes < 30 || n->maxmtu + 8 >= MTU) {
+ continue;
+ }
+
+ len = n->maxmtu + 8;
+ } else if(n->maxmtu <= n->minmtu) {
+ len = n->maxmtu;
+ } else {
+ len = n->minmtu + 1 + prng(mesh, n->maxmtu - n->minmtu);