summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-07-20 21:12:23 -0700
committerDave Barach <openvpp@barachs.net>2021-07-21 21:17:00 +0000
commite71aeab3926485ee42d185483f8fe5bffe4693bf (patch)
tree254297ee964b32bfdd5148d01ff49712a7435722 /src/plugins/hs_apps
parentbbc8faebf13f2db7299c948c441b526419fefe09 (diff)
hsa: separate ctrl and test session accept vcl server
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Id6bcf6511c904c8625c0845cd9758539f35e6b50
Diffstat (limited to 'src/plugins/hs_apps')
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_server.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c
index 78d7752dd68..93c244484c8 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_server.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_server.c
@@ -307,6 +307,48 @@ vts_server_echo (vcl_test_session_t *conn, int rx_bytes)
}
static vcl_test_session_t *
+vts_accept_ctrl (vcl_test_server_worker_t *wrk, int listen_fd)
+{
+ vcl_test_server_main_t *vsm = &vcl_server_main;
+ const vcl_test_proto_vft_t *tp;
+ vcl_test_session_t *conn;
+ struct epoll_event ev;
+ int rv;
+
+ conn = conn_pool_alloc (wrk);
+ if (!conn)
+ {
+ vtwrn ("No free connections!");
+ return 0;
+ }
+
+ if (vsm->ctrl)
+ conn->cfg = vsm->ctrl->cfg;
+ vcl_test_session_buf_alloc (conn);
+ clock_gettime (CLOCK_REALTIME, &conn->old_stats.stop);
+
+ tp = vcl_test_main.protos[VPPCOM_PROTO_TCP];
+ if (tp->accept (listen_fd, conn))
+ return 0;
+
+ vtinf ("CTRL accepted fd = %d (0x%08x) on listener fd = %d (0x%08x)",
+ conn->fd, conn->fd, listen_fd, listen_fd);
+
+ ev.events = EPOLLET | EPOLLIN;
+ ev.data.u64 = conn - wrk->conn_pool;
+ rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, conn->fd, &ev);
+ if (rv < 0)
+ {
+ vterr ("vppcom_epoll_ctl()", rv);
+ return 0;
+ }
+
+ wrk->nfds++;
+
+ return conn;
+}
+
+static vcl_test_session_t *
vts_accept_client (vcl_test_server_worker_t *wrk, int listen_fd)
{
vcl_test_server_main_t *vsm = &vcl_server_main;
@@ -654,7 +696,7 @@ vts_worker_loop (void *arg)
vtwrn ("ctrl already exists");
continue;
}
- vsm->ctrl = vts_accept_client (wrk, vsm->ctrl_listen_fd);
+ vsm->ctrl = vts_accept_ctrl (wrk, vsm->ctrl_listen_fd);
continue;
}
if (ep_evts[i].data.u32 == VCL_TEST_DATA_LISTENER)