summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-10-19 20:51:36 -0700
committerDave Barach <openvpp@barachs.net>2020-10-20 17:49:41 +0000
commitac422d6430060c003f70191c9a12466c29dab7e7 (patch)
tree6ed0a22bba0049dc66fb9f5e77fbd6a6b7a7f360 /src/vcl/vppcom.c
parent2531d50101991011fb1c7755d48f11b41f092628 (diff)
vcl: more session struct cleanup
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I8e466e789c860caaa55f67095a57fc6ab670f32b
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c143
1 files changed, 72 insertions, 71 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 1e9e5c45fd7..dd50df153bb 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -520,7 +520,7 @@ vcl_session_connected_handler (vcl_worker_t * wrk,
session->transport.lcl_port = mp->lcl.port;
/* Application closed session before connect reply */
- if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK)
+ if (vcl_session_has_attr (session, VCL_SESS_ATTR_NONBLOCK)
&& session->session_state == VCL_STATE_CLOSED)
vcl_send_session_disconnect (wrk, session);
else
@@ -1288,7 +1288,7 @@ vppcom_session_create (u8 proto, u8 is_nonblocking)
session->is_dgram = vcl_proto_is_dgram (proto);
if (is_nonblocking)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_NONBLOCK);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_NONBLOCK);
vcl_evt (VCL_EVT_CREATE, session, session_type, session->session_state,
is_nonblocking, session_index);
@@ -1560,8 +1560,8 @@ vppcom_session_accept (uint32_t listen_session_handle, vppcom_endpt_t * ep,
goto handle;
}
- is_nonblocking = VCL_SESS_ATTR_TEST (listen_session->attr,
- VCL_SESS_ATTR_NONBLOCK);
+ is_nonblocking = vcl_session_has_attr (listen_session,
+ VCL_SESS_ATTR_NONBLOCK);
while (1)
{
if (svm_msg_q_is_empty (wrk->app_event_queue) && is_nonblocking)
@@ -1593,13 +1593,13 @@ handle:
client_session = vcl_session_get (wrk, client_session_index);
if (flags & O_NONBLOCK)
- VCL_SESS_ATTR_SET (client_session->attr, VCL_SESS_ATTR_NONBLOCK);
+ vcl_session_set_attr (client_session, VCL_SESS_ATTR_NONBLOCK);
VDBG (1, "listener %u [0x%llx]: Got a connect request! session %u [0x%llx],"
" flags %d, is_nonblocking %u", listen_session->session_index,
listen_session->vpp_handle, client_session_index,
client_session->vpp_handle, flags,
- VCL_SESS_ATTR_TEST (client_session->attr, VCL_SESS_ATTR_NONBLOCK));
+ vcl_session_has_attr (client_session, VCL_SESS_ATTR_NONBLOCK));
if (ep)
{
@@ -1699,7 +1699,7 @@ vppcom_session_connect (uint32_t session_handle, vppcom_endpt_t * server_ep)
vcl_send_session_connect (wrk, session);
- if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK))
+ if (vcl_session_has_attr (session, VCL_SESS_ATTR_NONBLOCK))
{
/* State set to STATE_UPDATED to ensure the session is not assumed
* to be ready and to also allow the app to close it prior to vpp's
@@ -1819,11 +1819,11 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n,
return vcl_session_closed_error (s);
}
- is_nonblocking = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK);
+ is_nonblocking = vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK);
is_ct = vcl_session_is_ct (s);
mq = wrk->app_event_queue;
rx_fifo = is_ct ? s->ct_rx_fifo : s->rx_fifo;
- s->has_rx_evt = 0;
+ s->flags &= ~VCL_SESSION_F_HAS_RX_EVT;
if (svm_fifo_is_empty_cons (rx_fifo))
{
@@ -1929,11 +1929,11 @@ vppcom_session_read_segments (uint32_t session_handle,
if (PREDICT_FALSE (!vcl_session_is_open (s)))
return vcl_session_closed_error (s);
- is_nonblocking = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK);
+ is_nonblocking = vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK);
is_ct = vcl_session_is_ct (s);
- mq = is_ct ? s->our_evt_q : wrk->app_event_queue;
+ mq = wrk->app_event_queue;
rx_fifo = s->rx_fifo;
- s->has_rx_evt = 0;
+ s->flags &= ~VCL_SESSION_F_HAS_RX_EVT;
if (is_ct)
svm_fifo_unset_event (s->rx_fifo);
@@ -1974,7 +1974,7 @@ vppcom_session_read_segments (uint32_t session_handle,
svm_fifo_unset_event (s->rx_fifo);
if (svm_fifo_max_dequeue_cons (rx_fifo) != n_read
&& svm_fifo_set_event (s->rx_fifo)
- && VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK))
+ && vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK))
{
session_event_t *e;
vec_add2 (wrk->unhandled_evts_vector, e, 1);
@@ -2051,7 +2051,7 @@ vppcom_session_write_inline (vcl_worker_t * wrk, vcl_session_t * s, void *buf,
is_ct = vcl_session_is_ct (s);
tx_fifo = is_ct ? s->ct_tx_fifo : s->tx_fifo;
- is_nonblocking = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK);
+ is_nonblocking = vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK);
mq = wrk->app_event_queue;
if (!vcl_fifo_is_writeable (tx_fifo, n, is_dgram))
@@ -2785,12 +2785,13 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e,
break;
vcl_fifo_rx_evt_valid_or_break (session);
session_events = session->vep.ev.events;
- if (!(EPOLLIN & session->vep.ev.events) || session->has_rx_evt)
+ if (!(EPOLLIN & session->vep.ev.events)
+ || (session->flags & VCL_SESSION_F_HAS_RX_EVT))
break;
add_event = 1;
events[*num_ev].events |= EPOLLIN;
session_evt_data = session->vep.ev.data.u64;
- session->has_rx_evt = 1;
+ session->flags |= VCL_SESSION_F_HAS_RX_EVT;
break;
case SESSION_IO_EVT_TX:
sid = e->session_index;
@@ -3088,12 +3089,12 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
*flags =
O_RDWR |
- (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK) ?
+ (vcl_session_has_attr (session, VCL_SESS_ATTR_NONBLOCK) ?
O_NONBLOCK : 0);
*buflen = sizeof (*flags);
VDBG (2, "VPPCOM_ATTR_GET_FLAGS: sh %u, flags = 0x%08x, "
"is_nonblocking = %u", session_handle, *flags,
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK));
+ vcl_session_has_attr (session, VCL_SESS_ATTR_NONBLOCK));
}
else
rv = VPPCOM_EINVAL;
@@ -3103,13 +3104,13 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (PREDICT_TRUE (buffer && buflen && (*buflen == sizeof (*flags))))
{
if (*flags & O_NONBLOCK)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_NONBLOCK);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_NONBLOCK);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_NONBLOCK);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_NONBLOCK);
VDBG (2, "VPPCOM_ATTR_SET_FLAGS: sh %u, flags = 0x%08x,"
" is_nonblocking = %u", session_handle, *flags,
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK));
+ vcl_session_has_attr (session, VCL_SESS_ATTR_NONBLOCK));
}
else
rv = VPPCOM_EINVAL;
@@ -3214,8 +3215,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
case VPPCOM_ATTR_GET_LISTEN:
if (buffer && buflen && (*buflen >= sizeof (int)))
{
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_LISTEN);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_LISTEN);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_LISTEN: %d, buflen %d", *(int *) buffer,
@@ -3305,8 +3306,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_REUSEADDR);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_REUSEADDR);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_REUSEADDR: %d, buflen %d, #VPP-TBD#",
@@ -3318,16 +3319,16 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
case VPPCOM_ATTR_SET_REUSEADDR:
if (buffer && buflen && (*buflen == sizeof (int)) &&
- !VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_LISTEN))
+ !vcl_session_has_attr (session, VCL_SESS_ATTR_LISTEN))
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_REUSEADDR);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_REUSEADDR);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_REUSEADDR);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_REUSEADDR);
VDBG (2, "VPPCOM_ATTR_SET_REUSEADDR: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_REUSEADDR),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_REUSEADDR),
*buflen);
}
else
@@ -3338,8 +3339,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_REUSEPORT);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_REUSEPORT);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_REUSEPORT: %d, buflen %d, #VPP-TBD#",
@@ -3351,16 +3352,16 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
case VPPCOM_ATTR_SET_REUSEPORT:
if (buffer && buflen && (*buflen == sizeof (int)) &&
- !VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_LISTEN))
+ !vcl_session_has_attr (session, VCL_SESS_ATTR_LISTEN))
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_REUSEPORT);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_REUSEPORT);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_REUSEPORT);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_REUSEPORT);
VDBG (2, "VPPCOM_ATTR_SET_REUSEPORT: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_REUSEPORT),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_REUSEPORT),
*buflen);
}
else
@@ -3371,8 +3372,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_BROADCAST);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_BROADCAST);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_BROADCAST: %d, buflen %d, #VPP-TBD#",
@@ -3387,12 +3388,12 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_BROADCAST);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_BROADCAST);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_BROADCAST);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_BROADCAST);
VDBG (2, "VPPCOM_ATTR_SET_BROADCAST: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_BROADCAST),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_BROADCAST),
*buflen);
}
else
@@ -3403,8 +3404,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_V6ONLY);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_V6ONLY);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_V6ONLY: %d, buflen %d, #VPP-TBD#",
@@ -3419,12 +3420,12 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_V6ONLY);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_V6ONLY);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_V6ONLY);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_V6ONLY);
VDBG (2, "VPPCOM_ATTR_SET_V6ONLY: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_V6ONLY),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_V6ONLY),
*buflen);
}
else
@@ -3435,8 +3436,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_KEEPALIVE);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_KEEPALIVE);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_KEEPALIVE: %d, buflen %d, #VPP-TBD#",
@@ -3451,12 +3452,12 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_KEEPALIVE);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_KEEPALIVE);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_KEEPALIVE);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_KEEPALIVE);
VDBG (2, "VPPCOM_ATTR_SET_KEEPALIVE: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_KEEPALIVE),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_KEEPALIVE),
*buflen);
}
else
@@ -3467,8 +3468,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_TCP_NODELAY);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_TCP_NODELAY);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_TCP_NODELAY: %d, buflen %d, #VPP-TBD#",
@@ -3483,12 +3484,12 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_TCP_NODELAY);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_TCP_NODELAY);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_TCP_NODELAY);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_TCP_NODELAY);
VDBG (2, "VPPCOM_ATTR_SET_TCP_NODELAY: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_TCP_NODELAY),
+ vcl_session_has_attr (session, VCL_SESS_ATTR_TCP_NODELAY),
*buflen);
}
else
@@ -3499,8 +3500,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_TCP_KEEPIDLE);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_TCP_KEEPIDLE);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_TCP_KEEPIDLE: %d, buflen %d, #VPP-TBD#",
@@ -3515,13 +3516,13 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_TCP_KEEPIDLE);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_TCP_KEEPIDLE);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_TCP_KEEPIDLE);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_TCP_KEEPIDLE);
VDBG (2, "VPPCOM_ATTR_SET_TCP_KEEPIDLE: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_TCP_KEEPIDLE), *buflen);
+ vcl_session_has_attr (session,
+ VCL_SESS_ATTR_TCP_KEEPIDLE), *buflen);
}
else
rv = VPPCOM_EINVAL;
@@ -3531,8 +3532,8 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
if (buffer && buflen && (*buflen >= sizeof (int)))
{
/* VPP-TBD */
- *(int *) buffer = VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_TCP_KEEPINTVL);
+ *(int *) buffer = vcl_session_has_attr (session,
+ VCL_SESS_ATTR_TCP_KEEPINTVL);
*buflen = sizeof (int);
VDBG (2, "VPPCOM_ATTR_GET_TCP_KEEPINTVL: %d, buflen %d, #VPP-TBD#",
@@ -3547,13 +3548,13 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
{
/* VPP-TBD */
if (*(int *) buffer)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_TCP_KEEPINTVL);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_TCP_KEEPINTVL);
else
- VCL_SESS_ATTR_CLR (session->attr, VCL_SESS_ATTR_TCP_KEEPINTVL);
+ vcl_session_clear_attr (session, VCL_SESS_ATTR_TCP_KEEPINTVL);
VDBG (2, "VPPCOM_ATTR_SET_TCP_KEEPINTVL: %d, buflen %d, #VPP-TBD#",
- VCL_SESS_ATTR_TEST (session->attr,
- VCL_SESS_ATTR_TCP_KEEPINTVL), *buflen);
+ vcl_session_has_attr (session,
+ VCL_SESS_ATTR_TCP_KEEPINTVL), *buflen);
}
else
rv = VPPCOM_EINVAL;
@@ -3588,15 +3589,15 @@ vppcom_session_attr (uint32_t session_handle, uint32_t op,
case VPPCOM_ATTR_SET_SHUT:
if (*flags == SHUT_RD || *flags == SHUT_RDWR)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_SHUT_RD);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_SHUT_RD);
if (*flags == SHUT_WR || *flags == SHUT_RDWR)
- VCL_SESS_ATTR_SET (session->attr, VCL_SESS_ATTR_SHUT_WR);
+ vcl_session_set_attr (session, VCL_SESS_ATTR_SHUT_WR);
break;
case VPPCOM_ATTR_GET_SHUT:
- if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_SHUT_RD))
+ if (vcl_session_has_attr (session, VCL_SESS_ATTR_SHUT_RD))
tmp_flags = 1;
- if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_SHUT_WR))
+ if (vcl_session_has_attr (session, VCL_SESS_ATTR_SHUT_WR))
tmp_flags |= 2;
if (tmp_flags == 1)
*(int *) buffer = SHUT_RD;