From: Etienne Dechamps Date: Mon, 29 Dec 2014 15:40:55 +0000 (+0000) Subject: Move responsibility for local discovery to UDP discovery. X-Git-Tag: release-1.1pre12~243 X-Git-Url: https://www.tinc-vpn.org/git/browse?a=commitdiff_plain;ds=sidebyside;h=88026f27715774a7647c109ba5594068f0ba56af;p=tinc Move responsibility for local discovery to UDP discovery. 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. --- diff --git a/doc/tinc.conf.5.in b/doc/tinc.conf.5.in index 48c3df50..b7a619ee 100644 --- a/doc/tinc.conf.5.in +++ b/doc/tinc.conf.5.in @@ -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 diff --git a/doc/tinc.texi b/doc/tinc.texi index c940eddb..dc797fb7 100644 --- a/doc/tinc.texi +++ b/doc/tinc.texi @@ -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}> diff --git a/src/net_packet.c b/src/net_packet.c index 131f52ec..7833fd87 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -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; + } } }