summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-28 14:46:03 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-28 15:45:35 +0200
commit1b9709bae3718efc397fc824fb8a0ec5fac31bd1 (patch)
tree98702daa2fc021215571ba1e7ab49a6ec4aac82d /src
parent3a3d42392020c0115a8e8c5555cff981fa5f3dc3 (diff)
downloadfastd-1b9709bae3718efc397fc824fb8a0ec5fac31bd1.tar
fastd-1b9709bae3718efc397fc824fb8a0ec5fac31bd1.zip
ec25519: reset peers as soon as their current session times out
Diffstat (limited to 'src')
-rw-r--r--src/protocol_ec25519_fhmqvc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index fb556f2..a420e8d 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -755,8 +755,17 @@ static void protocol_handshake_handle(fastd_context_t *ctx, fastd_socket_t *sock
}
}
+static inline bool check_session(fastd_context_t *ctx, fastd_peer_t *peer) {
+ if (is_session_valid(ctx, &peer->protocol_state->session))
+ return true;
+
+ pr_verbose(ctx, "active session with %P timed out", peer);
+ fastd_peer_reset(ctx, peer);
+ return false;
+}
+
static void protocol_handle_recv(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_t buffer) {
- if (!peer->protocol_state || !is_session_valid(ctx, &peer->protocol_state->session))
+ if (!peer->protocol_state || !check_session(ctx, peer))
goto fail;
fastd_buffer_t recv_buffer;
@@ -822,7 +831,7 @@ static void session_send(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_
}
static void protocol_send(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_t buffer) {
- if (!peer->protocol_state || !fastd_peer_is_established(peer) || !is_session_valid(ctx, &peer->protocol_state->session)) {
+ if (!peer->protocol_state || !fastd_peer_is_established(peer) || !check_session(ctx, peer)) {
fastd_buffer_free(buffer);
return;
}