diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 20 | ||||
-rw-r--r-- | src/config.y | 8 | ||||
-rw-r--r-- | src/fastd.c | 4 | ||||
-rw-r--r-- | src/fastd.h | 4 | ||||
-rw-r--r-- | src/options.c | 4 | ||||
-rw-r--r-- | src/protocols/ec25519_fhmqvc/handshake.c | 2 |
6 files changed, 22 insertions, 20 deletions
diff --git a/src/config.c b/src/config.c index 18ef34c..daa2606 100644 --- a/src/config.c +++ b/src/config.c @@ -382,7 +382,7 @@ static void assess_peers(void) { conf.has_floating = false; fastd_peer_config_t *peer; - for (peer = conf.peers; peer; peer = peer->next) { + for (peer = ctx.peer_configs; peer; peer = peer->next) { if (fastd_peer_config_is_floating(peer)) conf.has_floating = true; } @@ -531,7 +531,7 @@ static void config_check_base(void) { if (conf.peer_group->children) exit_error("config error: in TUN mode peer groups can't be used"); - if (conf.peers && conf.peers->next) + if (ctx.peer_configs && ctx.peer_configs->next) exit_error("config error: in TUN mode exactly one peer must be configured"); } @@ -551,11 +551,11 @@ void fastd_config_check(void) { config_check_base(); if (conf.mode == MODE_TUN) { - if (!conf.peers) + if (!ctx.peer_configs) exit_error("config error: in TUN mode exactly one peer must be configured"); } - if (!conf.peers && !has_peer_group_peer_dirs(conf.peer_group)) + if (!ctx.peer_configs && !has_peer_group_peer_dirs(conf.peer_group)) exit_error("config error: neither fixed peers nor peer dirs have been configured"); if (!conf.method_list) { @@ -573,7 +573,7 @@ void fastd_config_verify(void) { configure_methods(); fastd_peer_config_t *peer; - for (peer = conf.peers; peer; peer = peer->next) + for (peer = ctx.peer_configs; peer; peer = peer->next) conf.protocol->peer_verify(peer); } @@ -649,18 +649,18 @@ void fastd_config_load_peer_dirs(void) { fastd_peer_config_t *new_peers = NULL; peer_dirs_read_peer_group(&new_peers, conf.peer_group); - peer_dirs_handle_old_peers(&conf.peers, &new_peers); - peer_dirs_handle_new_peers(&conf.peers, new_peers); + peer_dirs_handle_old_peers(&ctx.peer_configs, &new_peers); + peer_dirs_handle_new_peers(&ctx.peer_configs, new_peers); assess_peers(); } /** Frees all resources used by the global configuration */ void fastd_config_release(void) { - while (conf.peers) { - fastd_peer_config_t *peer = conf.peers, *next = peer->next; + while (ctx.peer_configs) { + fastd_peer_config_t *peer = ctx.peer_configs, *next = peer->next; fastd_peer_config_free(peer); - conf.peers = next; + ctx.peer_configs = next; } while (conf.bind_addrs) { diff --git a/src/config.y b/src/config.y index 3d4e96c..3513216 100644 --- a/src/config.y +++ b/src/config.y @@ -424,9 +424,9 @@ on_verify: sync_def_async TOK_STRING { peer: TOK_STRING { fastd_peer_config_t *peer = fastd_peer_config_new(state->peer_group); peer->name = fastd_strdup($1->str); - peer->next = conf.peers; + peer->next = ctx.peer_configs; - conf.peers = peer; + ctx.peer_configs = peer; state->peer = peer; } ; @@ -547,8 +547,8 @@ include: TOK_PEER TOK_STRING maybe_as { if (!fastd_config_read($2->str, state->peer_group, peer, state->depth)) YYERROR; - peer->next = conf.peers; - conf.peers = peer; + peer->next = ctx.peer_configs; + ctx.peer_configs = peer; } | TOK_PEERS TOK_FROM TOK_STRING { fastd_config_add_peer_dir(state->peer_group, $3->str); diff --git a/src/fastd.c b/src/fastd.c index e63b204..5d24b9b 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -206,10 +206,10 @@ static inline void on_post_down(void) { */ static void init_peers(void) { fastd_peer_config_t *peer_conf; - for (peer_conf = conf.peers; peer_conf; peer_conf = peer_conf->next) + for (peer_conf = ctx.peer_configs; peer_conf; peer_conf = peer_conf->next) conf.protocol->peer_configure(peer_conf); - for (peer_conf = conf.peers; peer_conf; peer_conf = peer_conf->next) { + for (peer_conf = ctx.peer_configs; peer_conf; peer_conf = peer_conf->next) { bool enable = conf.protocol->peer_check(peer_conf); if (enable && !peer_conf->enabled) diff --git a/src/fastd.h b/src/fastd.h index 7050f05..554a982 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -205,7 +205,6 @@ struct fastd_config { char *secret; /**< The configured secret key */ fastd_peer_group_t *peer_group; /**< The root peer group configuration */ - fastd_peer_config_t *peers; /**< The configured peers */ bool has_floating; /**< Specifies if any of the configured peers have floating remotes */ @@ -242,8 +241,11 @@ struct fastd_context { struct timespec now; /**< The current monotonous timestamp */ + fastd_peer_config_t *peer_configs; /**< The configured peers */ + uint64_t next_peer_id; /**< An monotonously increasing ID peers are identified with in some components */ VECTOR(fastd_peer_t*) peers; /**< The currectly active peers */ + #ifdef WITH_VERIFY fastd_sem_t verify_limit; /**< Keeps track of the number of verifier threads */ #endif diff --git a/src/options.c b/src/options.c index c3c9844..bce724e 100644 --- a/src/options.c +++ b/src/options.c @@ -122,8 +122,8 @@ static void option_config_peer(const char *arg) { if(!fastd_config_read(arg, conf.peer_group, peer, 0)) exit(1); - peer->next = conf.peers; - conf.peers = peer; + peer->next = ctx.peer_configs; + ctx.peer_configs = peer; } diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c index 9a1c8de..68c37d2 100644 --- a/src/protocols/ec25519_fhmqvc/handshake.c +++ b/src/protocols/ec25519_fhmqvc/handshake.c @@ -486,7 +486,7 @@ static size_t key_count(const unsigned char key[PUBLICKEYBYTES]) { size_t ret = 0; fastd_peer_config_t *p; - for (p = conf.peers; p; p = p->next) { + for (p = ctx.peer_configs; p; p = p->next) { if (!p->protocol_config) continue; |