Always keep UDP mappings alive for nodes that also have a meta-connection.

This is necessary for assisting with UDP hole punching. But we don't
need to know the PMTU for this, so only send UDP probes.
This commit is contained in:
Guus Sliepen 2015-01-11 13:31:01 +01:00
parent 545ecb3396
commit eb7a0db18e
3 changed files with 19 additions and 7 deletions

View file

@ -154,6 +154,7 @@ static void timeout_handler(void *data) {
if(c->last_ping_time + pingtimeout <= now.tv_sec) {
if(c->edge) {
try_tx(c->node, false);
if(c->status.pinged) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)now.tv_sec - c->last_ping_time);
} else if(c->last_ping_time + pinginterval <= now.tv_sec) {
@ -170,6 +171,7 @@ static void timeout_handler(void *data) {
}
terminate_connection(c, c->edge);
}
}
timeout_set(data, &(struct timeval){pingtimeout, rand() % 100000});

View file

@ -214,6 +214,7 @@ extern void retry(void);
extern int reload_configuration(void);
extern void load_all_subnets(void);
extern void load_all_nodes(void);
extern void try_tx(struct node_t *n, bool);
#ifndef HAVE_MINGW
#define closesocket(s) close(s)

View file

@ -1087,7 +1087,7 @@ static void try_mtu(node_t *n) {
idle.
*/
static void try_tx_sptps(node_t *n) {
static void try_tx_sptps(node_t *n, bool mtu) {
/* If n is a TCP-only neighbor, we'll only use "cleartext" PACKET
messages anyway, so there's no need for SPTPS at all. */
@ -1110,13 +1110,14 @@ static void try_tx_sptps(node_t *n) {
/* If we do have a relay, try everything with that one instead. */
if(via != n)
return try_tx_sptps(via);
return try_tx_sptps(via, mtu);
try_udp(n);
try_mtu(n);
if(mtu)
try_mtu(n);
}
static void try_tx_legacy(node_t *n) {
static void try_tx_legacy(node_t *n, bool mtu) {
/* Does he have our key? If not, send one. */
if(!n->status.validkey_in)
@ -1133,7 +1134,15 @@ static void try_tx_legacy(node_t *n) {
}
try_udp(n);
try_mtu(n);
if(mtu)
try_mtu(n);
}
void try_tx(node_t *n, bool mtu) {
if(n->status.sptps)
try_tx_sptps(n, mtu);
else
try_tx_legacy(n, mtu);
}
void send_packet(node_t *n, vpn_packet_t *packet) {
@ -1166,7 +1175,7 @@ void send_packet(node_t *n, vpn_packet_t *packet) {
if(n->status.sptps) {
send_sptps_packet(n, packet);
try_tx_sptps(n);
try_tx_sptps(n, true);
return;
}
@ -1186,7 +1195,7 @@ void send_packet(node_t *n, vpn_packet_t *packet) {
}
send_udppacket(via, packet);
try_tx_legacy(via);
try_tx_legacy(via, true);
}
void broadcast_packet(const node_t *from, vpn_packet_t *packet) {