summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-19 00:10:48 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-19 00:21:38 +0200
commit35a18b1dea21f006b38694dcf5c99f817411ad4d (patch)
treec6922a55085eba524ad9a997816429c6437b7430 /src/fastd.c
parent21ade840c989e9fcebef63e2999f5c31843c47b6 (diff)
downloadfastd-35a18b1dea21f006b38694dcf5c99f817411ad4d.tar
fastd-35a18b1dea21f006b38694dcf5c99f817411ad4d.zip
Create peer structures for disabled peers as well
We have a 1:1 association between peers and peer configs now.
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 0be82c4..9be4290 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -206,16 +206,11 @@ static inline void on_post_down(void) {
*/
static void init_peers(void) {
fastd_peer_config_t *peer_conf;
- for (peer_conf = ctx.peer_configs; peer_conf; peer_conf = peer_conf->next)
- conf.protocol->peer_configure(peer_conf);
-
for (peer_conf = ctx.peer_configs; peer_conf; peer_conf = peer_conf->next) {
- bool enable = conf.protocol->peer_check(peer_conf);
+ conf.protocol->peer_configure(peer_conf);
- if (enable && peer_conf->config_state == CONFIG_DISABLED)
+ if (peer_conf->config_state == CONFIG_NEW)
fastd_peer_add(peer_conf);
-
- peer_conf->config_state = enable ? CONFIG_STATIC : CONFIG_DISABLED;
}
size_t i;
@@ -229,10 +224,13 @@ static void init_peers(void) {
}
}
else {
- if (peer->config->config_state == CONFIG_DISABLED) {
- pr_info("previously enabled peer %P disabled, deleting.", peer);
- fastd_peer_delete(peer);
- continue;
+ fastd_peer_config_state_t state = conf.protocol->peer_check(peer->config) ? CONFIG_STATIC : CONFIG_DISABLED;
+ if (state != peer->config->config_state) {
+ if (peer->config->config_state != CONFIG_NEW)
+ pr_info("peer %P is %s now.", peer, (state == CONFIG_DISABLED) ? "disabled" : "enabled");
+
+ peer->config->config_state = state;
+ fastd_peer_reset(peer);
}
}
@@ -258,6 +256,9 @@ static void dump_state(void) {
for (i = 0; i < VECTOR_LEN(ctx.peers); i++) {
fastd_peer_t *peer = VECTOR_INDEX(ctx.peers, i);
+ if (!fastd_peer_is_enabled(peer))
+ continue;
+
if (!fastd_peer_is_established(peer)) {
pr_info("peer %P not connected, address: %I", peer, &peer->address);
continue;