From: Guus Sliepen Date: Fri, 11 Dec 2009 21:31:27 +0000 (+0100) Subject: Merge branch 'master' into 1.1 X-Git-Tag: release-1.1pre1~99 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d6c50eb73ad49bd2eac67214995dff76b7a20661;p=oweals%2Ftinc.git Merge branch 'master' into 1.1 Conflicts: src/subnet.c --- d6c50eb73ad49bd2eac67214995dff76b7a20661 diff --cc src/route.c index 758801b,1642389..3c0cf5b --- a/src/route.c +++ b/src/route.c @@@ -102,46 -99,12 +102,46 @@@ static void swap_mac_addresses(vpn_pack memcpy(&packet->data[6], &tmp, sizeof tmp); } +static void age_subnets(int fd, short events, void *data) { + subnet_t *s; + connection_t *c; + splay_node_t *node, *next, *node2; + bool left = false; + time_t now = time(NULL); + + for(node = myself->subnet_tree->head; node; node = next) { + next = node->next; + s = node->data; + if(s->expires && s->expires < now) { + ifdebug(TRAFFIC) { + char netstr[MAXNETSTR]; + if(net2str(netstr, sizeof netstr, s)) + logger(LOG_INFO, "Subnet %s expired", netstr); + } + + for(node2 = connection_tree->head; node2; node2 = node2->next) { + c = node2->data; + if(c->status.active) + send_del_subnet(c, s); + } + + subnet_del(myself, s); + } else { + if(s->expires) + left = true; + } + } + + if(left) + event_add(&age_subnets_event, &(struct timeval){10, 0}); +} + static void learn_mac(mac_t *address) { subnet_t *subnet; - avl_node_t *node; + splay_node_t *node; connection_t *c; - subnet = lookup_subnet_mac(address); + subnet = lookup_subnet_mac(myself, address); /* If we don't know this MAC address yet, store it */ diff --cc src/subnet.c index 0669b8a,bc66fec..8bc8fce --- a/src/subnet.c +++ b/src/subnet.c @@@ -327,12 -326,12 +327,12 @@@ bool net2str(char *netstr, int len, con /* Subnet lookup routines */ subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet) { - return avl_search(owner->subnet_tree, subnet); + return splay_search(owner->subnet_tree, subnet); } - subnet_t *lookup_subnet_mac(const mac_t *address) { - subnet_t *p, *r = NULL, subnet = {0}; + subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { + subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached @@@ -374,8 -371,8 +372,8 @@@ } subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { - subnet_t *p, *r = NULL, subnet = {0}; + subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached @@@ -418,8 -410,8 +411,8 @@@ } subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { - subnet_t *p, *r = NULL, subnet = {0}; + subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached diff --cc src/subnet.h index 466eb20,b2124a0..df48f60 --- a/src/subnet.h +++ b/src/subnet.h @@@ -77,10 -77,10 +77,10 @@@ extern void subnet_update(struct node_ extern bool net2str(char *, int, const subnet_t *); extern bool str2net(subnet_t *, const char *); extern subnet_t *lookup_subnet(const struct node_t *, const subnet_t *); - extern subnet_t *lookup_subnet_mac(const mac_t *); + extern subnet_t *lookup_subnet_mac(const struct node_t *, const mac_t *); extern subnet_t *lookup_subnet_ipv4(const ipv4_t *); extern subnet_t *lookup_subnet_ipv6(const ipv6_t *); -extern void dump_subnets(void); +extern bool dump_subnets(struct connection_t *); extern void subnet_cache_flush(void); #endif /* __TINC_SUBNET_H__ */