Reload Subnets when getting a HUP signal and StrictSubnets is used.
This commit is contained in:
parent
d1cc637470
commit
9f53ab209d
4 changed files with 35 additions and 3 deletions
25
src/net.c
25
src/net.c
|
@ -489,6 +489,31 @@ int main_loop(void) {
|
||||||
|
|
||||||
last_config_check = now;
|
last_config_check = now;
|
||||||
|
|
||||||
|
/* If StrictSubnet is set, expire deleted Subnets and read new ones in */
|
||||||
|
|
||||||
|
if(strictsubnets) {
|
||||||
|
subnet_t *subnet;
|
||||||
|
|
||||||
|
for(node = subnet_tree->head; node; node = node->next) {
|
||||||
|
subnet = node->data;
|
||||||
|
subnet->expires = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
load_all_subnets();
|
||||||
|
|
||||||
|
for(node = subnet_tree->head; node; node = next) {
|
||||||
|
next = node->next;
|
||||||
|
subnet = node->data;
|
||||||
|
if(subnet->expires == 1) {
|
||||||
|
send_del_subnet(broadcast, subnet);
|
||||||
|
subnet_del(subnet->owner, subnet);
|
||||||
|
} else if(subnet->expires == -1) {
|
||||||
|
send_add_subnet(broadcast, subnet);
|
||||||
|
subnet->expires = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to make outgoing connections */
|
/* Try to make outgoing connections */
|
||||||
|
|
||||||
try_outgoing_connections();
|
try_outgoing_connections();
|
||||||
|
|
|
@ -139,6 +139,7 @@ extern void terminate_connection(struct connection_t *, bool);
|
||||||
extern void flush_queue(struct node_t *);
|
extern void flush_queue(struct node_t *);
|
||||||
extern bool read_rsa_public_key(struct connection_t *);
|
extern bool read_rsa_public_key(struct connection_t *);
|
||||||
extern void send_mtu_probe(struct node_t *);
|
extern void send_mtu_probe(struct node_t *);
|
||||||
|
extern void load_all_subnets();
|
||||||
|
|
||||||
#ifndef HAVE_MINGW
|
#ifndef HAVE_MINGW
|
||||||
#define closesocket(s) close(s)
|
#define closesocket(s) close(s)
|
||||||
|
|
|
@ -204,14 +204,14 @@ bool read_rsa_private_key(void) {
|
||||||
/*
|
/*
|
||||||
Read Subnets from all host config files
|
Read Subnets from all host config files
|
||||||
*/
|
*/
|
||||||
static void load_all_subnets(void) {
|
void load_all_subnets(void) {
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char *dname;
|
char *dname;
|
||||||
char *fname;
|
char *fname;
|
||||||
avl_tree_t *config_tree;
|
avl_tree_t *config_tree;
|
||||||
config_t *cfg;
|
config_t *cfg;
|
||||||
subnet_t *s;
|
subnet_t *s, *s2;
|
||||||
node_t *n;
|
node_t *n;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
|
@ -251,7 +251,11 @@ static void load_all_subnets(void) {
|
||||||
if(!get_config_subnet(cfg, &s))
|
if(!get_config_subnet(cfg, &s))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
subnet_add(n, s);
|
if((s2 = lookup_subnet(n, s))) {
|
||||||
|
s2->expires = -1;
|
||||||
|
} else {
|
||||||
|
subnet_add(n, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_configuration(&config_tree);
|
exit_configuration(&config_tree);
|
||||||
|
|
|
@ -64,6 +64,8 @@ typedef struct subnet_t {
|
||||||
|
|
||||||
#define MAXNETSTR 64
|
#define MAXNETSTR 64
|
||||||
|
|
||||||
|
extern avl_tree_t *subnet_tree;
|
||||||
|
|
||||||
extern int subnet_compare(const struct subnet_t *, const struct subnet_t *);
|
extern int subnet_compare(const struct subnet_t *, const struct subnet_t *);
|
||||||
extern subnet_t *new_subnet(void) __attribute__ ((__malloc__));
|
extern subnet_t *new_subnet(void) __attribute__ ((__malloc__));
|
||||||
extern void free_subnet(subnet_t *);
|
extern void free_subnet(subnet_t *);
|
||||||
|
|
Loading…
Reference in a new issue