X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Froute.c;h=dbe38dfbf2f0206a6984199fa8976b7593d5c942;hb=fb0cfccf7dc2240b576011edcf74fd5b058916cb;hp=32afa0d6e8f819ff624a6665e384cd118030eb6f;hpb=8852d4407d87cf5dcf2c212d352279015aa050c0;p=tinc diff --git a/src/route.c b/src/route.c index 32afa0d6..dbe38dfb 100644 --- a/src/route.c +++ b/src/route.c @@ -22,7 +22,7 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "connection.h" #include "ethernet.h" #include "ipv4.h" @@ -77,6 +77,7 @@ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) static bool ratelimit(int frequency) { static time_t lasttime = 0; static int count = 0; + time_t now = time(NULL); if(lasttime == now) { if(++count > frequency) @@ -101,8 +102,9 @@ static void age_subnets(int fd, short events, void *data) { subnet_t *s; connection_t *c; - avl_node_t *node, *next, *node2; + splay_node_t *node, *next, *node2; bool left = false; + time_t now = time(NULL); cp(); @@ -136,7 +138,7 @@ static void age_subnets(int fd, short events, void *data) static void learn_mac(mac_t *address) { subnet_t *subnet; - avl_node_t *node; + splay_node_t *node; connection_t *c; cp(); @@ -152,7 +154,7 @@ static void learn_mac(mac_t *address) subnet = new_subnet(); subnet->type = SUBNET_MAC; - subnet->expires = now + macexpire; + subnet->expires = time(NULL) + macexpire; subnet->net.mac.address = *address; subnet_add(myself, subnet); @@ -167,10 +169,10 @@ static void learn_mac(mac_t *address) if(!timeout_initialized(&age_subnets_event)) timeout_set(&age_subnets_event, age_subnets, NULL); event_add(&age_subnets_event, &(struct timeval){10, 0}); + } else { + if(subnet->expires) + subnet->expires = time(NULL) + macexpire; } - - if(subnet->expires) - subnet->expires = now + macexpire; } static void route_mac(node_t *source, vpn_packet_t *packet)