summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-11-05 10:11:17 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-11-05 10:11:17 +0100
commit0c2f5da1650a295c29001e50384ec2f605055aed (patch)
treea40f81576efd9b8d2a9944fdb6c754f83eb4685a /src/peer.c
parent51aa24d4a2825a050a6c048d69c24a10d98d4993 (diff)
downloadfastd-0c2f5da1650a295c29001e50384ec2f605055aed.tar
fastd-0c2f5da1650a295c29001e50384ec2f605055aed.zip
Fix some more bugs in fastd_peer_claim_address
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/peer.c b/src/peer.c
index 47e863e..97c21ed 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -326,22 +326,25 @@ bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, fastd_so
else {
fastd_peer *peer;
for (peer = ctx->peers; peer; peer = peer->next) {
- if (fastd_peer_address_equal(&peer->address, addr)) {
- if (peer == new_peer)
- break;
-
- if (fastd_peer_is_floating(peer) || fastd_peer_is_dynamic(peer)) {
- if (fastd_peer_is_established(peer))
- fastd_peer_reset(ctx, peer);
-
- memset(&peer->address, 0, sizeof(fastd_peer_address));
- break;
- }
- else {
- memset(&new_peer->address, 0, sizeof(fastd_peer_address));
- return false;
- }
+ if (!fastd_peer_address_equal(&peer->address, addr))
+ continue;
+
+ if (peer == new_peer)
+ break;
+
+ if (!fastd_peer_is_floating(peer)) {
+ if (fastd_peer_is_established(new_peer))
+ fastd_peer_reset(ctx, new_peer);
+
+ memset(&new_peer->address, 0, sizeof(fastd_peer_address));
+ return false;
}
+
+ if (fastd_peer_is_established(peer))
+ fastd_peer_reset(ctx, peer);
+
+ memset(&peer->address, 0, sizeof(fastd_peer_address));
+ break;
}
}