Keep track of the largest UDP packet size received from a node.

This commit is contained in:
Guus Sliepen 2015-01-11 16:10:58 +01:00
parent d639415937
commit f0afde0467
4 changed files with 9 additions and 0 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 */