From 3a3d42392020c0115a8e8c5555cff981fa5f3dc3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 28 Aug 2013 14:13:44 +0200 Subject: Cancel the session establishment earlier when the address can't be claimed by the peer There is no reason to run through all the session establishment just to cancel it a moment later. --- src/protocol_ec25519_fhmqvc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c index 711fdee..fb556f2 100644 --- a/src/protocol_ec25519_fhmqvc.c +++ b/src/protocol_ec25519_fhmqvc.c @@ -392,6 +392,12 @@ static bool establish(fastd_context_t *ctx, fastd_peer_t *peer, const fastd_meth pr_verbose(ctx, "%I authorized as %P", remote_addr, peer); + if (!fastd_peer_claim_address(ctx, peer, sock, local_addr, remote_addr)) { + pr_warn(ctx, "can't set address %I which is used by a fixed peer", remote_addr); + fastd_peer_reset(ctx, peer); + return false; + } + if (is_session_valid(ctx, &peer->protocol_state->session) && !is_session_valid(ctx, &peer->protocol_state->old_session)) { if (peer->protocol_state->old_session.method) peer->protocol_state->old_session.method->session_free(ctx, peer->protocol_state->old_session.method_state); @@ -420,12 +426,6 @@ static bool establish(fastd_context_t *ctx, fastd_peer_t *peer, const fastd_meth fastd_peer_seen(ctx, peer); - if (!fastd_peer_claim_address(ctx, peer, sock, local_addr, remote_addr)) { - pr_warn(ctx, "can't set address %I which is used by a fixed peer", remote_addr); - fastd_peer_reset(ctx, peer); - return false; - } - fastd_peer_set_established(ctx, peer); pr_verbose(ctx, "new session with %P established using method `%s'.", peer, method->name); -- cgit v1.2.3