Move responsibility for local discovery to UDP discovery.
authorEtienne Dechamps <etienne@edechamps.fr>
Mon, 29 Dec 2014 15:40:55 +0000 (15:40 +0000)
committerEtienne Dechamps <etienne@edechamps.fr>
Thu, 1 Jan 2015 17:40:15 +0000 (17:40 +0000)
Since UDP discovery is the place where UDP feasibility is checked, it
makes sense to test for local connectivity as well. This was previously
done as part of PMTU discovery.

doc/tinc.conf.5.in
doc/tinc.texi
src/net_packet.c

index 48c3df508d3d5120d2351d342c4a7e3a101d2a03..b7a619eea93ec410db3ceef43b534582ec99e474 100644 (file)
@@ -358,7 +358,7 @@ This will allow direct communication using LAN addresses, even if both peers are
 and they only ConnectTo a third node outside the NAT,
 which normally would prevent the peers from learning each other's LAN address.
 .Pp
-Currently, local discovery is implemented by sending some packets to the local address of the node during path MTU discovery. This will not work with old nodes that don't transmit their local address.
+Currently, local discovery is implemented by sending some packets to the local address of the node during UDP discovery. This will not work with old nodes that don't transmit their local address.
 .It Va MACExpire Li = Ar seconds Pq 600
 This option controls the amount of time MAC addresses are kept before they are removed.
 This only has effect when
index c940eddb48816ef126bb1f72e55a7b8f638e41b0..dc797fb71248f20c152be6637ddc48218bb62e9b 100644 (file)
@@ -1081,8 +1081,8 @@ This will allow direct communication using LAN addresses, even if both peers are
 and they only ConnectTo a third node outside the NAT,
 which normally would prevent the peers from learning each other's LAN address.
 
-Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery.
-This feature may not work in all possible situations.
+Currently, local discovery is implemented by sending some packets to the local address of the node during UDP discovery.
+This will not work with old nodes that don't transmit their local address.
 
 @cindex LocalDiscoveryAddress
 @item LocalDiscoveryAddress <@var{address}>
index 131f52ec3b4b1680193bcb8d08462ab50cd26e1a..7833fd87b65ec2047e0dd4c3bf350cf3c5c46cda 100644 (file)
@@ -146,14 +146,6 @@ static void send_mtu_probe_handler(void *data) {
                send_udp_probe_packet(n, MAX(len, 64));
        }
 
-       /* In case local discovery is enabled, another packet is added to each batch,
-          which will be broadcast to the local network. */
-       if(localdiscovery && n->mtuprobes <= 10 && n->prevedge) {
-               n->status.send_locally = true;
-               send_udp_probe_packet(n, 16);
-               n->status.send_locally = false;
-       }
-
        n->probe_counter = 0;
        gettimeofday(&n->probe_time, NULL);
 
@@ -969,6 +961,12 @@ static void try_udp(node_t* n) {
        if(ping_tx_elapsed.tv_sec >= udp_discovery_interval) {
                send_udp_probe_packet(n, MAX(n->minmtu, 16));
                n->udp_ping_sent = now;
+
+               if(localdiscovery && !n->status.udp_confirmed && n->prevedge) {
+                       n->status.send_locally = true;
+                       send_udp_probe_packet(n, 16);
+                       n->status.send_locally = false;
+               }
        }
 }