summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-04-15 16:01:43 -0700
committerFlorin Coras <fcoras@cisco.com>2022-04-16 11:03:23 -0700
commit515aa751120cb73cbf0c4b98373a3b53807ca29b (patch)
treebf0207024637368b9ad617f1ce6392a625286d62 /src/plugins
parent9fda33da5ca80c0824bed99a2856aa5461751429 (diff)
hsa: vcl test client allow non-blocking connects
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: If7dd56e76efc31ed66b865e2c7231d22ec2322b4
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test.h5
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_client.c3
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_protos.c103
3 files changed, 66 insertions, 45 deletions
diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h
index d51e204140f..ac949797cdb 100644
--- a/src/plugins/hs_apps/vcl/vcl_test.h
+++ b/src/plugins/hs_apps/vcl/vcl_test.h
@@ -125,9 +125,10 @@ typedef struct
typedef struct vcl_test_session
{
- uint8_t is_alloc;
- uint8_t is_open;
uint8_t is_done;
+ uint8_t is_alloc : 1;
+ uint8_t is_open : 1;
+ uint8_t noblk_connect : 1;
int fd;
int (*read) (struct vcl_test_session *ts, void *buf, uint32_t buflen);
int (*write) (struct vcl_test_session *ts, void *buf, uint32_t buflen);
diff --git a/src/plugins/hs_apps/vcl/vcl_test_client.c b/src/plugins/hs_apps/vcl/vcl_test_client.c
index f096e235719..1b149b2d9bc 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_client.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_client.c
@@ -1077,7 +1077,10 @@ vt_incercept_sigs (void)
static void
vtc_alloc_workers (vcl_test_client_main_t *vcm)
{
+ vcl_test_main_t *vt = &vcl_test_main;
+
vcm->workers = calloc (vcm->n_workers, sizeof (vcl_test_client_worker_t));
+ vt->wrk = calloc (vcm->n_workers, sizeof (vcl_test_wrk_t));
for (int i = 0; i < vcm->n_workers; i++)
{
diff --git a/src/plugins/hs_apps/vcl/vcl_test_protos.c b/src/plugins/hs_apps/vcl/vcl_test_protos.c
index 60ee09265c9..97d64b5f10d 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_protos.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_protos.c
@@ -21,16 +21,15 @@ vt_tcp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
uint32_t flags, flen;
int rv;
- ts->fd = vppcom_session_create (VPPCOM_PROTO_TCP, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_TCP, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
return ts->fd;
}
- /* Connect is blocking */
rv = vppcom_session_connect (ts->fd, endpt);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_connect()", rv);
return rv;
@@ -38,10 +37,14 @@ vt_tcp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
ts->read = vcl_test_read;
ts->write = vcl_test_write;
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
- vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+ }
return 0;
}
@@ -108,16 +111,15 @@ vt_udp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
uint32_t flags, flen;
int rv;
- ts->fd = vppcom_session_create (VPPCOM_PROTO_UDP, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_UDP, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
return ts->fd;
}
- /* Connect is blocking */
rv = vppcom_session_connect (ts->fd, endpt);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_connect()", rv);
return rv;
@@ -125,10 +127,14 @@ vt_udp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
ts->read = vcl_test_read;
ts->write = vcl_test_write;
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
- vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+ }
return 0;
}
@@ -282,7 +288,7 @@ vt_tls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
uint32_t flags, flen, ckp_len;
int rv;
- ts->fd = vppcom_session_create (VPPCOM_PROTO_TLS, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_TLS, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
@@ -293,9 +299,8 @@ vt_tls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_CKPAIR, &vt->ckpair_index,
&ckp_len);
- /* Connect is blocking */
rv = vppcom_session_connect (ts->fd, endpt);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_connect()", rv);
return rv;
@@ -303,10 +308,14 @@ vt_tls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
ts->read = vcl_test_read;
ts->write = vcl_test_write;
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
- vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+ }
return 0;
}
@@ -387,7 +396,7 @@ vt_dtls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
uint32_t flags, flen, ckp_len;
int rv;
- ts->fd = vppcom_session_create (VPPCOM_PROTO_DTLS, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_DTLS, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
@@ -398,9 +407,8 @@ vt_dtls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_CKPAIR, &vt->ckpair_index,
&ckp_len);
- /* Connect is blocking */
rv = vppcom_session_connect (ts->fd, endpt);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_connect()", rv);
return rv;
@@ -408,10 +416,14 @@ vt_dtls_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
ts->read = vcl_test_read;
ts->write = vcl_test_write;
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
- vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+ }
return 0;
}
@@ -568,7 +580,7 @@ vt_quic_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
/* Make sure qsessions are initialized */
vt_quic_maybe_init_wrk (vt, wrk, endpt);
- ts->fd = vppcom_session_create (VPPCOM_PROTO_QUIC, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_QUIC, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
@@ -579,21 +591,23 @@ vt_quic_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
tq = &wrk->qsessions[ts->session_index / vt->cfg.num_test_sessions_perq];
rv = vppcom_session_stream_connect (ts->fd, tq->fd);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_stream_connect()", rv);
return rv;
}
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
-
ts->read = vcl_test_read;
ts->write = vcl_test_write;
- vtinf ("Test (quic stream) session %d (fd %d) connected.", ts->session_index,
- ts->fd);
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test (quic stream) session %d (fd %d) connected.",
+ ts->session_index, ts->fd);
+ }
return 0;
}
@@ -864,7 +878,7 @@ vt_srtp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
uint32_t flags, flen;
int rv;
- ts->fd = vppcom_session_create (VPPCOM_PROTO_SRTP, 0 /* is_nonblocking */);
+ ts->fd = vppcom_session_create (VPPCOM_PROTO_SRTP, ts->noblk_connect);
if (ts->fd < 0)
{
vterr ("vppcom_session_create()", ts->fd);
@@ -873,9 +887,8 @@ vt_srtp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
vt_session_add_srtp_policy (ts, 1 /* is connect */);
- /* Connect is blocking */
rv = vppcom_session_connect (ts->fd, endpt);
- if (rv < 0)
+ if (rv < 0 && rv != VPPCOM_EINPROGRESS)
{
vterr ("vppcom_session_connect()", rv);
return rv;
@@ -883,10 +896,14 @@ vt_srtp_connect (vcl_test_session_t *ts, vppcom_endpt_t *endpt)
ts->read = vt_srtp_read;
ts->write = vt_srtp_write;
- flags = O_NONBLOCK;
- flen = sizeof (flags);
- vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
- vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+
+ if (!ts->noblk_connect)
+ {
+ flags = O_NONBLOCK;
+ flen = sizeof (flags);
+ vppcom_session_attr (ts->fd, VPPCOM_ATTR_SET_FLAGS, &flags, &flen);
+ vtinf ("Test session %d (fd %d) connected.", ts->session_index, ts->fd);
+ }
vt_srtp_session_init (ts, 1 /* is connect */);