summaryrefslogtreecommitdiffstats
path: root/src/protocol_ec25519_fhmqvc.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-28 14:13:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-28 14:13:44 +0200
commit3a3d42392020c0115a8e8c5555cff981fa5f3dc3 (patch)
tree9b586e912050ebb43f73e47b3182c976c896ec11 /src/protocol_ec25519_fhmqvc.c
parent738639cf711c254bcafbb869837a87ea46413c5a (diff)
downloadfastd-3a3d42392020c0115a8e8c5555cff981fa5f3dc3.tar
fastd-3a3d42392020c0115a8e8c5555cff981fa5f3dc3.zip
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.
Diffstat (limited to 'src/protocol_ec25519_fhmqvc.c')
-rw-r--r--src/protocol_ec25519_fhmqvc.c12
1 files 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);