From efc2019a31cd5039b0738cd0291e36e8deb590ed Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 04:51:40 +0100 Subject: peer: don't create interfaces for disabled peers --- src/peer.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/peer.c b/src/peer.c index 9964559..9654c15 100644 --- a/src/peer.c +++ b/src/peer.c @@ -313,6 +313,15 @@ static void reset_peer(fastd_peer_t *peer) { peer->address.sa.sa_family = AF_UNSPEC; peer->local_address.sa.sa_family = AF_UNSPEC; peer->state = STATE_INACTIVE; + + if (!conf.iface_persist || peer->config_state == CONFIG_DISABLED) { + if (peer->iface && peer->iface->peer) { + fastd_on_down(peer->iface); + fastd_iface_close(peer->iface); + } + + peer->iface = NULL; + } } /** @@ -379,6 +388,10 @@ static void setup_peer(fastd_peer_t *peer) { peer->verify_valid_timeout = ctx.now; #endif + if (!fastd_peer_is_enabled(peer)) + /* Keep the peer in STATE_INACTIVE */ + return; + if (ctx.iface) { peer->iface = ctx.iface; } @@ -397,10 +410,6 @@ static void setup_peer(fastd_peer_t *peer) { exit(1); } - if (!fastd_peer_is_enabled(peer)) - /* Keep the peer in STATE_INACTIVE */ - return; - fastd_remote_t *next_remote = fastd_peer_get_next_remote(peer); if (next_remote) { next_remote->current_address = 0; -- cgit v1.2.3