From bb617311f4fc4ece5bf963d3f445e73e09a9cdaa Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 25 Feb 2024 12:00:11 +0100 Subject: lib: Rename CACEP to CEP and set conngmr timeout The Common Application Connection Establishment Protocol (CACEP) is a RINA construct associated with the Common Distributed Application Protocol (CDAP). We dropped CDAP as O7s sees connection establishment as common to all applications (though it can be a nop). The wiki already refers to this as (O7s) Connection Establishment Protocol (CEP). The connection manager will now timeout waiting for CEP messages to avoid hanging forever, configurable at build time via CONNMGR_RCV_TIMEOUT. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/CMakeLists.txt | 2 ++ src/ipcpd/common/comp.h | 2 +- src/ipcpd/common/connmgr.c | 69 +++++++++++++++++++++++++++------------------- src/ipcpd/common/connmgr.h | 2 +- src/ipcpd/config.h.in | 1 + 5 files changed, 45 insertions(+), 31 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/CMakeLists.txt b/src/ipcpd/CMakeLists.txt index cd81949e..54294f11 100644 --- a/src/ipcpd/CMakeLists.txt +++ b/src/ipcpd/CMakeLists.txt @@ -1,3 +1,5 @@ +set(CONNMGR_RCV_TIMEOUT 1000 CACHE STRING + "Timeout for the connection manager to wait for OCEP info (ms).") set(IPCP_DEBUG_LOCAL FALSE CACHE BOOL "Use PID as address for local debugging") set(IPCP_QOS_CUBE_BE_PRIO 50 CACHE STRING diff --git a/src/ipcpd/common/comp.h b/src/ipcpd/common/comp.h index 1130a163..f3790d9c 100644 --- a/src/ipcpd/common/comp.h +++ b/src/ipcpd/common/comp.h @@ -23,7 +23,7 @@ #ifndef OUROBOROS_IPCPD_COMMON_COMP_H #define OUROBOROS_IPCPD_COMMON_COMP_H -#include +#include #define DST_MAX_STRLEN 64 diff --git a/src/ipcpd/common/connmgr.c b/src/ipcpd/common/connmgr.c index 71b114aa..4b5fd420 100644 --- a/src/ipcpd/common/connmgr.c +++ b/src/ipcpd/common/connmgr.c @@ -22,9 +22,10 @@ #define OUROBOROS_PREFIX "connection-manager" +#include #include -#include #include +#include #include #include #include @@ -33,9 +34,9 @@ #include "connmgr.h" #include "ipcp.h" -#include -#include #include +#include +#include enum connmgr_state { CONNMGR_NULL = 0, @@ -128,10 +129,12 @@ static int add_comp_conn(enum comp_id id, static void * flow_acceptor(void * o) { - int fd; - qosspec_t qs; - struct conn_info rcv_info; - struct conn_info fail_info; + int fd; + qosspec_t qs; + struct conn_info rcv_info; + struct conn_info fail_info; + struct timespec timeo = TIMESPEC_INIT_MS(CONNMGR_RCV_TIMEOUT); + int err; (void) o; @@ -147,10 +150,13 @@ static void * flow_acceptor(void * o) continue; } - log_info("Handling incoming flow %d",fd); + log_info("Handling incoming flow %d.",fd); - if (cacep_rcv(fd, &rcv_info)) { - log_err("Error receiving CACEP info."); + fccntl(fd, FLOWSRCVTIMEO, &timeo); + + err = cep_rcv(fd, &rcv_info); + if (err < 0) { + log_err("Error receiving OCEP info: %d.", err); flow_dealloc(fd); continue; } @@ -161,24 +167,26 @@ static void * flow_acceptor(void * o) if (id < 0) { log_err("Connection request for unknown component %s.", rcv_info.comp_name); - cacep_snd(fd, &fail_info); + cep_snd(fd, &fail_info); flow_dealloc(fd); continue; } - if (cacep_snd(fd, &connmgr.comps[id].info)) { - log_err("Failed to respond to CACEP request."); + err = cep_snd(fd, &connmgr.comps[id].info); + if (err < 0) { + log_err("Failed responding to OCEP request: %d.", err); flow_dealloc(fd); continue; } - if (add_comp_conn(id, fd, qs, &rcv_info)) { - log_err("Failed to add new connection."); + err = add_comp_conn(id, fd, qs, &rcv_info); + if (err < 0) { + log_err("Failed to add new connection: %d.", err); flow_dealloc(fd); continue; } - log_info("Finished handling incoming flow %d for %s: 0.", + log_info("Finished handling incoming flow %d for %s.", fd, rcv_info.comp_name); } @@ -422,8 +430,9 @@ int connmgr_alloc(enum comp_id id, qosspec_t * qs, struct conn * conn) { - struct comp * comp; - int fd; + struct comp * comp; + int fd; + struct timespec timeo = TIMESPEC_INIT_MS(CONNMGR_RCV_TIMEOUT); assert(id >= 0 && id < COMPID_MAX); assert(dst); @@ -443,34 +452,36 @@ int connmgr_alloc(enum comp_id id, else memset(&conn->flow_info.qs, 0, sizeof(conn->flow_info.qs)); - log_dbg("Sending cacep info for protocol %s to fd %d.", + log_dbg("Sending OCEP info for protocol %s to fd %d.", comp->info.protocol, conn->flow_info.fd); - if (cacep_snd(fd, &comp->info)) { - log_err("Failed to send CACEP info."); - goto fail_cacep; + fccntl(fd, FLOWSRCVTIMEO, &timeo); + + if (cep_snd(fd, &comp->info)) { + log_err("Failed to send OCEP info."); + goto fail_cep; } - if (cacep_rcv(fd, &conn->conn_info)) { - log_err("Failed to receive CACEP info."); - goto fail_cacep; + if (cep_rcv(fd, &conn->conn_info)) { + log_err("Failed to receive OCEP info."); + goto fail_cep; } if (strcmp(comp->info.protocol, conn->conn_info.protocol)) { log_err("Unknown protocol (requested %s, got %s).", comp->info.protocol, conn->conn_info.protocol); - goto fail_cacep; + goto fail_cep; } if (comp->info.pref_version != conn->conn_info.pref_version) { log_err("Unknown protocol version %d.", conn->conn_info.pref_version); - goto fail_cacep; + goto fail_cep; } if (comp->info.pref_syntax != conn->conn_info.pref_syntax) { log_err("Unknown protocol syntax."); - goto fail_cacep; + goto fail_cep; } switch (id) { @@ -489,7 +500,7 @@ int connmgr_alloc(enum comp_id id, return 0; - fail_cacep: + fail_cep: flow_dealloc(conn->flow_info.fd); fail_alloc: return -1; diff --git a/src/ipcpd/common/connmgr.h b/src/ipcpd/common/connmgr.h index 21dc8ba3..0710dbbf 100644 --- a/src/ipcpd/common/connmgr.h +++ b/src/ipcpd/common/connmgr.h @@ -23,7 +23,7 @@ #ifndef OUROBOROS_IPCPD_COMMON_CONNMGR_H #define OUROBOROS_IPCPD_COMMON_CONNMGR_H -#include +#include #include #include "comp.h" diff --git a/src/ipcpd/config.h.in b/src/ipcpd/config.h.in index af0658d6..fe4f5fd2 100644 --- a/src/ipcpd/config.h.in +++ b/src/ipcpd/config.h.in @@ -51,6 +51,7 @@ #define PFT_SIZE @PFT_SIZE@ #define DHT_ENROLL_SLACK @DHT_ENROLL_SLACK@ #define IPCP_UNICAST_MPL @IPCP_UNICAST_MPL@ +#define CONNMGR_RCV_TIMEOUT @CONNMGR_RCV_TIMEOUT@ #cmakedefine IPCP_CONN_WAIT_DIR #cmakedefine DISABLE_CORE_LOCK -- cgit v1.2.3