From baf23ebb6333deee1f7b67f83e7a125c21f2d535 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 03:05:57 +0100 Subject: Don't reset peers twice on start in TUN mode --- src/config.c | 17 ++++++++++++----- src/config.h | 2 +- src/fastd.c | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/config.c b/src/config.c index 2deacd6..1fff240 100644 --- a/src/config.c +++ b/src/config.c @@ -592,7 +592,7 @@ static void peer_dirs_read_peer_group(fastd_peer_group_t *group) { } /** Initializes the configured peers */ -void fastd_configure_peers(void) { +static void configure_peers(bool dirs_only) { ctx.has_floating = false; ssize_t i; @@ -621,13 +621,20 @@ void fastd_configure_peers(void) { peer->config_state = CONFIG_STATIC; - if (!fastd_peer_is_established(peer)) - fastd_peer_reset(peer); + if (!fastd_peer_is_established(peer)) { + if (peer->config_source_dir || !dirs_only) + fastd_peer_reset(peer); + } } } +/** Initialized the peers not configured through peer directories */ +void fastd_configure_peers(void) { + configure_peers(false); +} + /** Refreshes the peer configurations from the configured peer dirs */ -void fastd_config_load_peer_dirs(void) { +void fastd_config_load_peer_dirs(bool dirs_only) { size_t i; for (i = 0; i < VECTOR_LEN(ctx.peers); i++) { fastd_peer_t *peer = VECTOR_INDEX(ctx.peers, i); @@ -643,7 +650,7 @@ void fastd_config_load_peer_dirs(void) { } peer_dirs_read_peer_group(conf.peer_group); - fastd_configure_peers(); + configure_peers(dirs_only); } /** Frees all resources used by the global configuration */ diff --git a/src/config.h b/src/config.h index 8c87e5a..60be363 100644 --- a/src/config.h +++ b/src/config.h @@ -62,5 +62,5 @@ void fastd_config_add_peer_dir(fastd_peer_group_t *group, const char *dir); void fastd_configure(int argc, char *const argv[]); void fastd_configure_peers(void); void fastd_config_check(void); -void fastd_config_load_peer_dirs(void); +void fastd_config_load_peer_dirs(bool dirs_only); diff --git a/src/fastd.c b/src/fastd.c index ecef0fb..8ce10c8 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -535,7 +535,7 @@ static inline void init(int argc, char *argv[]) { else if (conf.drop_caps == DROP_CAPS_OFF) set_user(); - fastd_config_load_peer_dirs(); + fastd_config_load_peer_dirs(true); } @@ -582,7 +582,7 @@ static inline void handle_signals(void) { pr_info("reconfigure triggered"); - fastd_config_load_peer_dirs(); + fastd_config_load_peer_dirs(false); } if (sig_reset) { -- cgit v1.2.3