X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=11fbcb1ce4ff5b0414be47d35f8e0206e9b2b4f8;hb=e9de08be0dab58a48f9a8ce3d250516cf05d6b8e;hp=295546df6068a5e63e2c4701d2d5c56d94f4a650;hpb=c78bb143030162f0c820f08c87808e157c014a07;p=tinc diff --git a/src/net.c b/src/net.c index 295546df..11fbcb1c 100644 --- a/src/net.c +++ b/src/net.c @@ -276,6 +276,16 @@ int reload_configuration(void) { return EINVAL; } + read_config_options(config_tree, NULL); + + xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, myself->name); + read_config_file(config_tree, fname); + free(fname); + + /* Parse some options that are allowed to be changed while tinc is running */ + + setup_myself_reloadable(); + /* Close connections to hosts that have a changed or deleted host config file */ for(node = connection_tree->head; node; node = next) { @@ -293,7 +303,7 @@ int reload_configuration(void) { c->outgoing = NULL; } - xasprintf(&fname, "%s/hosts/%s", confbase, c->name); + xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name); if(stat(fname, &s) || s.st_mtime > last_config_check) terminate_connection(c, c->status.active); free(fname); @@ -306,7 +316,6 @@ int reload_configuration(void) { if(strictsubnets) { subnet_t *subnet; - for(node = subnet_tree->head; node; node = node->next) { subnet = node->data; subnet->expires = 1; @@ -330,6 +339,48 @@ int reload_configuration(void) { subnet_update(subnet->owner, subnet, true); } } + } else { /* Only read our own subnets back in */ + subnet_t *subnet, *s2; + + for(node = myself->subnet_tree->head; node; node = node->next) { + subnet_t *subnet = node->data; + logger(DEBUG_ALWAYS, LOG_DEBUG, "subnet %p expires %d", subnet, (int)subnet->expires); + if(!subnet->expires) + subnet->expires = 1; + } + + config_t *cfg = lookup_config(config_tree, "Subnet"); + + while(cfg) { + if(!get_config_subnet(cfg, &subnet)) + continue; + + if((s2 = lookup_subnet(myself, subnet))) { + logger(DEBUG_ALWAYS, LOG_DEBUG, "read subnet that already exists: %p expires %d", s2, (int)s2->expires); + if(s2->expires == 1) + s2->expires = 0; + + free_subnet(subnet); + } else { + logger(DEBUG_ALWAYS, LOG_DEBUG, "read new subnet %p", subnet); + subnet_add(myself, subnet); + send_add_subnet(everyone, subnet); + subnet_update(myself, subnet, true); + } + + cfg = lookup_config_next(config_tree, cfg); + } + + for(node = myself->subnet_tree->head; node; node = next) { + next = node->next; + subnet_t *subnet = node->data; + if(subnet->expires == 1) { + logger(DEBUG_ALWAYS, LOG_DEBUG, "removed subnet %p", subnet); + send_del_subnet(everyone, subnet); + subnet_update(myself, subnet, false); + subnet_del(myself, subnet); + } + } } /* Try to make outgoing connections */ @@ -341,9 +392,10 @@ int reload_configuration(void) { void retry(void) { connection_t *c; - splay_node_t *node; + splay_node_t *node, *next; - for(node = connection_tree->head; node; node = node->next) { + for(node = connection_tree->head; node; node = next) { + next = node->next; c = node->data; if(c->outgoing && !c->node) {