summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--VNFs/DPPD-PROX/input_conn.c17
-rw-r--r--VNFs/DPPD-PROX/input_conn.h1
-rw-r--r--VNFs/DPPD-PROX/prox_args.c3
-rw-r--r--VNFs/DPPD-PROX/prox_cfg.h2
-rw-r--r--VNFs/DPPD-PROX/run.c14
5 files changed, 37 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/input_conn.c b/VNFs/DPPD-PROX/input_conn.c
index 63e6511e..13d6110e 100644
--- a/VNFs/DPPD-PROX/input_conn.c
+++ b/VNFs/DPPD-PROX/input_conn.c
@@ -20,10 +20,13 @@
#include <sys/un.h>
#include <unistd.h>
+#include <rte_cycles.h>
#include "input_conn.h"
#include "input.h"
+#include "log.h"
#include "run.h"
#include "cmd_parser.h"
+#include "prox_cfg.h"
static struct input tcp_server;
int tcp_server_started;
@@ -132,6 +135,8 @@ static void handle_client(struct input* client_input)
return ;
}
+ prox_cfg.heartbeat_tsc = rte_rdtsc() + prox_cfg.heartbeat_timeout * rte_get_tsc_hz();
+
/* Scan in data until \n (\r skipped if followed by \n) */
for (int i = 0; i < ret; ++i) {
if (cur[i] == '\r' && i + 1 < ret && cur[i + 1] == '\n')
@@ -150,6 +155,18 @@ static void handle_client(struct input* client_input)
}
}
+void stop_handling_client(void)
+{
+ size_t i;
+ for (i = 0; i < sizeof(clients)/sizeof(clients[0]); ++i) {
+ if (clients[i].enabled) {
+ close(clients[i].input.fd);
+ clients[i].enabled = 0;
+ unreg_input(&clients[i].input);
+ }
+ }
+}
+
static void handle_new_client(struct input* server)
{
size_t i;
diff --git a/VNFs/DPPD-PROX/input_conn.h b/VNFs/DPPD-PROX/input_conn.h
index 98e9af45..9e39c808 100644
--- a/VNFs/DPPD-PROX/input_conn.h
+++ b/VNFs/DPPD-PROX/input_conn.h
@@ -23,5 +23,6 @@ int reg_input_uds(void);
void unreg_input_tcp(void);
void unreg_input_uds(void);
+void stop_handling_client(void);
#endif /* _INPUT_CONN_H_ */
diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c
index ca5b93ba..e1ed10ee 100644
--- a/VNFs/DPPD-PROX/prox_args.c
+++ b/VNFs/DPPD-PROX/prox_args.c
@@ -338,6 +338,9 @@ static int get_global_cfg(__attribute__((unused))unsigned sindex, char *str, voi
if (STR_EQ(str, "enable bypass")) {
return parse_flag(&pset->flags, DSF_ENABLE_BYPASS, pkey);
}
+ if (STR_EQ(str, "heartbeat timeout")) {
+ return parse_int(&pset->heartbeat_timeout, pkey);
+ }
if (STR_EQ(str, "cpe table map")) {
/* The config defined ports through 0, 1, 2 ... which
diff --git a/VNFs/DPPD-PROX/prox_cfg.h b/VNFs/DPPD-PROX/prox_cfg.h
index ed54ecc5..9d5f25f7 100644
--- a/VNFs/DPPD-PROX/prox_cfg.h
+++ b/VNFs/DPPD-PROX/prox_cfg.h
@@ -66,6 +66,8 @@ struct prox_cfg {
uint32_t logbuf_size;
uint32_t logbuf_pos;
char *logbuf;
+ uint32_t heartbeat_timeout;
+ uint64_t heartbeat_tsc;
};
extern struct prox_cfg prox_cfg;
diff --git a/VNFs/DPPD-PROX/run.c b/VNFs/DPPD-PROX/run.c
index bed0c757..c05f0a9f 100644
--- a/VNFs/DPPD-PROX/run.c
+++ b/VNFs/DPPD-PROX/run.c
@@ -237,6 +237,13 @@ void __attribute__((noreturn)) run(uint32_t flags)
if (stop_tsc && rte_rdtsc() >= stop_tsc) {
stop_prox = 1;
}
+ if ((prox_cfg.heartbeat_tsc) && (prox_cfg.heartbeat_timeout) && (rte_rdtsc() >= prox_cfg.heartbeat_tsc)) {
+ plog_info("Stopping to handle client as heartbeat timed out\n");
+ stop_core_all(-1);
+ stop_handling_client();
+ req_refresh();
+ prox_cfg.heartbeat_tsc = 0;
+ }
}
} else {
while (stop_prox == 0) {
@@ -254,6 +261,13 @@ void __attribute__((noreturn)) run(uint32_t flags)
if (stop_tsc && rte_rdtsc() >= stop_tsc) {
stop_prox = 1;
}
+ if ((prox_cfg.heartbeat_tsc) && (prox_cfg.heartbeat_timeout) && (rte_rdtsc() >= prox_cfg.heartbeat_tsc)) {
+ plog_info("Stopping to handle client as heartbeat timed out\n");
+ stop_core_all(-1);
+ stop_handling_client();
+ req_refresh();
+ prox_cfg.heartbeat_tsc = 0;
+ }
}
}