From 9719dbe335af4c6add39d739f78a68040b62d8a3 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 23 Feb 2022 21:14:26 +0100 Subject: lib: Add initial flow liveness monitoring This adds flow liveness monitoring for flows, with a fixed timeout of 120s. I will make it configurable at flow allocation later on (timeout needs to be communicated to the peer). If one peer dies, or doesn't call any IPC calls (flow_write/flow_read/fevent) it will stop sending keepalives and the other peer's read/writes will error on an -EFLOWDOWN after the timeout expires. Packets without a payload (0 length packets) are interpreted as keepalive packets for the flow. They can be sent from any application, but they will not trigger a message read at the receiver side (0 as a return value on flow_read indicates a previous partial read has completed at exactly the buffer size). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/crypt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lib/crypt.c') diff --git a/src/lib/crypt.c b/src/lib/crypt.c index 070f5113..043eae13 100644 --- a/src/lib/crypt.c +++ b/src/lib/crypt.c @@ -217,6 +217,9 @@ static int openssl_encrypt(struct flow * f, in = shm_du_buff_head(sdb); in_sz = shm_du_buff_tail(sdb) - in; + if (in_sz == 0) + return 0; + if (random_buffer(iv, IVSZ) < 0) goto fail_iv; -- cgit v1.2.3