aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-06-06 09:38:44 -0700
committerDave Barach <openvpp@barachs.net>2019-06-06 19:19:23 +0000
commit00cca801a5d96f4b5e5960396448dea6c457928b (patch)
treeec68fd57976a2b19debf99c8299c633e59af284b /src/vcl
parente003a1b9ffc51d16a0a4c617e173168973f0fe37 (diff)
vcl: avoid hash table lookup on accept
Type: refactor Change-Id: I363a97b9f5ab0dbda78e13582630e78d57fb83e7 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vcl_private.h1
-rw-r--r--src/vcl/vppcom.c50
2 files changed, 27 insertions, 24 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 14f461d9b56..b19e6b548f3 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -158,7 +158,6 @@ typedef struct
u32 sndbuf_size; // VPP-TBD: Hack until support setsockopt(SO_SNDBUF)
u32 rcvbuf_size; // VPP-TBD: Hack until support setsockopt(SO_RCVBUF)
u32 user_mss; // VPP-TBD: Hack until support setsockopt(TCP_MAXSEG)
- u32 client_context;
u64 vpp_handle;
u32 vpp_thread_index;
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 8b81e260298..8a05e3fde16 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -260,7 +260,8 @@ vcl_send_session_worker_update (vcl_worker_t * wrk, vcl_session_t * s,
}
static u32
-vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
+vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp,
+ u32 ls_index)
{
vcl_session_t *session, *listen_session;
svm_fifo_t *rx_fifo, *tx_fifo;
@@ -269,29 +270,23 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
session = vcl_session_alloc (wrk);
- listen_session = vcl_session_table_lookup_listener (wrk,
- mp->listener_handle);
- if (!listen_session)
+ listen_session = vcl_session_get (wrk, ls_index);
+ if (listen_session->vpp_handle != mp->listener_handle)
{
- evt_q = uword_to_pointer (mp->vpp_event_queue_address, svm_msg_q_t *);
- VDBG (0, "ERROR: couldn't find listen session: unknown vpp listener "
- "handle %llx", mp->listener_handle);
- vcl_send_session_accepted_reply (evt_q, mp->context, mp->handle,
- VNET_API_ERROR_INVALID_ARGUMENT);
- vcl_session_free (wrk, session);
- return VCL_INVALID_SESSION_INDEX;
+ VDBG (0, "ERROR: listener handle %lu does not match session %u",
+ mp->listener_handle, ls_index);
+ goto error;
}
- rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
- tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
-
if (vcl_wait_for_segment (mp->segment_handle))
{
- VDBG (0, "segment for session %u couldn't be mounted!",
+ VDBG (0, "ERROR: segment for session %u couldn't be mounted!",
session->session_index);
- return VCL_INVALID_SESSION_INDEX;
+ goto error;
}
+ rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
+ tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
session->vpp_evt_q = uword_to_pointer (mp->vpp_event_queue_address,
svm_msg_q_t *);
rx_fifo->client_session_index = session->session_index;
@@ -304,7 +299,6 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
session->vpp_handle = mp->handle;
session->vpp_thread_index = rx_fifo->master_thread_index;
- session->client_context = mp->context;
session->rx_fifo = rx_fifo;
session->tx_fifo = tx_fifo;
@@ -327,7 +321,17 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp)
clib_net_to_host_u16 (mp->rmt.port), session->vpp_evt_q);
vcl_evt (VCL_EVT_ACCEPT, session, listen_session, session_index);
+ vcl_send_session_accepted_reply (session->vpp_evt_q, mp->context,
+ session->vpp_handle, 0);
+
return session->session_index;
+
+error:
+ evt_q = uword_to_pointer (mp->vpp_event_queue_address, svm_msg_q_t *);
+ vcl_send_session_accepted_reply (evt_q, mp->context, mp->handle,
+ VNET_API_ERROR_INVALID_ARGUMENT);
+ vcl_session_free (wrk, session);
+ return VCL_INVALID_SESSION_INDEX;
}
static u32
@@ -1324,7 +1328,7 @@ vppcom_session_accept (uint32_t listen_session_handle, vppcom_endpt_t * ep,
e = svm_msg_q_msg_data (wrk->app_event_queue, &msg);
if (e->event_type != SESSION_CTRL_EVT_ACCEPTED)
{
- clib_warning ("discarded event: %u", e->event_type);
+ VDBG (0, "discarded event: %u", e->event_type);
svm_msg_q_free_msg (wrk->app_event_queue, &msg);
continue;
}
@@ -1335,7 +1339,11 @@ vppcom_session_accept (uint32_t listen_session_handle, vppcom_endpt_t * ep,
handle:
- client_session_index = vcl_session_accepted_handler (wrk, &accepted_msg);
+ client_session_index = vcl_session_accepted_handler (wrk, &accepted_msg,
+ listen_session_index);
+ if (client_session_index == VCL_INVALID_SESSION_INDEX)
+ return VPPCOM_ECONNABORTED;
+
listen_session = vcl_session_get (wrk, listen_session_index);
client_session = vcl_session_get (wrk, client_session_index);
@@ -1360,10 +1368,6 @@ handle:
sizeof (ip6_address_t));
}
- vcl_send_session_accepted_reply (client_session->vpp_evt_q,
- client_session->client_context,
- client_session->vpp_handle, 0);
-
VDBG (0, "listener %u [0x%llx] accepted %u [0x%llx] peer: %U:%u "
"local: %U:%u", listen_session_handle, listen_session->vpp_handle,
client_session_index, client_session->vpp_handle,