]> git.meshlink.io Git - meshlink/commitdiff
Merge branch 'master' into 1.1
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 11 Dec 2009 21:31:27 +0000 (22:31 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 11 Dec 2009 21:31:27 +0000 (22:31 +0100)
Conflicts:
src/subnet.c

1  2 
src/graph.c
src/route.c
src/subnet.c
src/subnet.h

diff --cc src/graph.c
Simple merge
diff --cc src/route.c
index 758801be80bbd38582b08d5a39724b453652a6db,16423892fa58c479c987d520a26fa6dae1d7afd3..3c0cf5b5b3a0d7aedc02807da006d46f26dbcc1a
@@@ -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 0669b8a0bceaf649ce39a7ae8c5338962f7c2e41,bc66fecccdf69ab2d1dfaa5151f1484254adab96..8bc8fce89efdc5040f6ba1c04c27b6d157d7c917
@@@ -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
  }
  
  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
  }
  
  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 466eb20c1806f11fc9cfbea3bdbec0eedb346e09,b2124a0ef87037a00d00b9daed4cbf411c3b1270..df48f60eda8268cc989cb9591bf47b4c72076c8f
@@@ -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__ */