From: Guus Sliepen Date: Sun, 11 Jan 2015 15:10:58 +0000 (+0100) Subject: Keep track of the largest UDP packet size received from a node. X-Git-Tag: release-1.1pre12~211 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=f0afde0467443969eb408090d6b8ee542768ee33;p=tinc Keep track of the largest UDP packet size received from a node. --- diff --git a/src/graph.c b/src/graph.c index 7bace2ed..49161c16 100644 --- a/src/graph.c +++ b/src/graph.c @@ -238,6 +238,7 @@ static void check_reachability(void) { n->status.udp_confirmed = false; n->maxmtu = MTU; + n->maxrecentlen = 0; n->minmtu = 0; n->mtuprobes = 0; diff --git a/src/net_packet.c b/src/net_packet.c index b2c6f902..96f8f10e 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -95,6 +95,7 @@ static void udp_probe_timeout_handler(void *data) { logger(DEBUG_TRAFFIC, LOG_INFO, "Too much time has elapsed since last UDP ping response from %s (%s), stopping UDP communication", n->name, n->hostname); n->status.udp_confirmed = false; + n->maxrecentlen = 0; n->mtuprobes = 0; n->minmtu = 0; n->maxmtu = MTU; @@ -387,6 +388,9 @@ static bool receive_udppacket(node_t *n, vpn_packet_t *inpkt) { origlen -= MTU/64 + 20; } + if(inpkt->len > n->maxrecentlen) + n->maxrecentlen = inpkt->len; + inpkt->priority = 0; if(!DATA(inpkt)[12] && !DATA(inpkt)[13]) @@ -962,6 +966,7 @@ static void try_mtu(node_t *n) { return; if(udp_discovery && !n->status.udp_confirmed) { + n->maxrecentlen = 0; n->mtuprobes = 0; n->minmtu = 0; n->maxmtu = MTU; diff --git a/src/node.c b/src/node.c index 6623f467..fb4b7eb4 100644 --- a/src/node.c +++ b/src/node.c @@ -179,6 +179,7 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) { /* invalidate UDP information - note that this is a security feature as well to make sure we can't be tricked into flooding any random address with UDP packets */ n->status.udp_confirmed = false; + n->maxrecentlen = 0; n->mtuprobes = 0; n->minmtu = 0; n->maxmtu = MTU; diff --git a/src/node.h b/src/node.h index aadb0b5f..03bd0208 100644 --- a/src/node.h +++ b/src/node.h @@ -93,6 +93,8 @@ typedef struct node_t { struct timeval mtu_ping_sent; /* Last time a MTU probe was sent */ + length_t maxrecentlen; /* Maximum size of recently received packets */ + length_t mtu; /* Maximum size of packets to send to this node */ length_t minmtu; /* Probed minimum MTU */ length_t maxmtu; /* Probed maximum MTU */