X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=45989518ac8b3f6d9b58edcd6d59d4d59d40a056;hb=fa432426df7e2e364e310ab4bac28e60f732a3c9;hp=abd83a9d3abf0c81458a17d5992afe0bd708e743;hpb=a95e182d9ca54960383bfe3950b2b798e1f24f9e;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index abd83a9d..45989518 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -958,6 +958,7 @@ static length_t choose_initial_maxmtu(node_t *n) { mtu -= SPTPS_DATAGRAM_OVERHEAD; if((n->options >> 24) >= 4) mtu -= sizeof(node_id_t) + sizeof(node_id_t); +#ifndef DISABLE_LEGACY } else { mtu -= digest_length(n->outdigest); @@ -977,6 +978,7 @@ static length_t choose_initial_maxmtu(node_t *n) { } mtu -= 4; // seqno +#endif } if (mtu < 512) { @@ -1123,23 +1125,31 @@ static void try_tx_sptps(node_t *n, bool mtu) { try_sptps(n); - /* Do we need to relay packets? */ + /* Do we need to statically relay packets? */ node_t *via = (n->via == myself) ? n->nexthop : n->via; - /* If the relay doesn't support SPTPS, everything goes via TCP anyway. */ + /* If the static relay doesn't support SPTPS, everything goes via TCP anyway. */ if((via->options >> 24) < 4) return; - /* If we do have a relay, try everything with that one instead. */ + /* If we do have a static relay, try everything with that one instead. */ if(via != n) return try_tx_sptps(via, mtu); + /* Otherwise, try to establish UDP connectivity. */ + try_udp(n); if(mtu) try_mtu(n); + + /* If we don't have UDP connectivity (yet), we need to use a dynamic relay (nexthop) + while we try to establish direct connectivity. */ + + if(!n->status.udp_confirmed && n != n->nexthop && (n->nexthop->options >> 24) >= 4) + try_tx_sptps(n->nexthop, mtu); } static void try_tx_legacy(node_t *n, bool mtu) { @@ -1386,6 +1396,7 @@ skip_harder: if(to != myself) { send_sptps_data_priv(to, n, 0, DATA(&pkt), pkt.len - 2 * sizeof(node_id_t)); + try_tx_sptps(n, true); return; } } else {