diff options
author | Florin Coras <fcoras@cisco.com> | 2020-01-21 16:17:53 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-01-22 22:26:29 +0000 |
commit | f5c7305c4ab21fe1c3eeeee1484449586464813a (patch) | |
tree | 773cacb00f4110f8a3e3b5db43a663fa30793fe9 /src/plugins | |
parent | da5dedfe33ca3cafb4cd6d90d34219d31cf69acb (diff) |
hsa: proxy app fixes
Type: fix
Change-Id: Icb4b331c9346d3781f4ddd6f62891c78d4059c1f
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/hs_apps/proxy.c | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/src/plugins/hs_apps/proxy.c b/src/plugins/hs_apps/proxy.c index c4ddd676436..e2a44e1706b 100644 --- a/src/plugins/hs_apps/proxy.c +++ b/src/plugins/hs_apps/proxy.c @@ -69,13 +69,12 @@ delete_proxy_session (session_t * s, int is_active_open) uword *p; u64 handle; + clib_spinlock_lock_if_init (&pm->sessions_lock); + handle = session_handle (s); - clib_spinlock_lock_if_init (&pm->sessions_lock); if (is_active_open) { - active_open_session = s; - p = hash_get (pm->proxy_session_by_active_open_handle, handle); if (p == 0) { @@ -85,17 +84,14 @@ delete_proxy_session (session_t * s, int is_active_open) } else if (!pool_is_free_index (pm->sessions, p[0])) { + active_open_session = s; ps = pool_elt_at_index (pm->sessions, p[0]); if (ps->vpp_server_handle != ~0) server_session = session_get_from_handle (ps->vpp_server_handle); - else - server_session = 0; } } else { - server_session = s; - p = hash_get (pm->proxy_session_by_server_handle, handle); if (p == 0) { @@ -105,12 +101,11 @@ delete_proxy_session (session_t * s, int is_active_open) } else if (!pool_is_free_index (pm->sessions, p[0])) { + server_session = s; ps = pool_elt_at_index (pm->sessions, p[0]); if (ps->vpp_active_open_handle != ~0) active_open_session = session_get_from_handle (ps->vpp_active_open_handle); - else - active_open_session = 0; } } @@ -121,8 +116,6 @@ delete_proxy_session (session_t * s, int is_active_open) pool_put (pm->sessions, ps); } - clib_spinlock_unlock_if_init (&pm->sessions_lock); - if (active_open_session) { a->handle = session_handle (active_open_session); @@ -140,6 +133,8 @@ delete_proxy_session (session_t * s, int is_active_open) session_handle (server_session)); vnet_disconnect_session (a); } + + clib_spinlock_unlock_if_init (&pm->sessions_lock); } static int @@ -232,6 +227,7 @@ proxy_rx_callback (session_t * s) if (PREDICT_FALSE (max_dequeue == 0)) return 0; + max_dequeue = clib_min (pm->rcv_buffer_size, max_dequeue); actual_transfer = svm_fifo_peek (rx_fifo, 0 /* relative_offset */ , max_dequeue, pm->rx_buf[thread_index]); @@ -239,7 +235,6 @@ proxy_rx_callback (session_t * s) clib_memset (a, 0, sizeof (*a)); - clib_spinlock_lock_if_init (&pm->sessions_lock); pool_get (pm->sessions, ps); clib_memset (ps, 0, sizeof (*ps)); ps->server_rx_fifo = rx_fifo; @@ -376,22 +371,6 @@ static session_cb_vft_t active_open_clients = { }; /* *INDENT-ON* */ - -static void -create_api_loopbacks (vlib_main_t * vm) -{ - proxy_main_t *pm = &proxy_main; - api_main_t *am = vlibapi_get_main (); - vl_shmem_hdr_t *shmem_hdr; - - shmem_hdr = am->shmem_hdr; - pm->vl_input_queue = shmem_hdr->vl_input_queue; - pm->server_client_index = - vl_api_memclnt_create_internal ("proxy_server", pm->vl_input_queue); - pm->active_open_client_index = - vl_api_memclnt_create_internal ("proxy_active_open", pm->vl_input_queue); -} - static int proxy_server_attach () { @@ -405,6 +384,7 @@ proxy_server_attach () if (pm->private_segment_size) segment_size = pm->private_segment_size; + a->name = format (0, "proxy-server"); a->api_client_index = pm->server_client_index; a->session_cb_vft = &proxy_session_cb_vft; a->options = options; @@ -424,6 +404,7 @@ proxy_server_attach () } pm->server_app_index = a->app_index; + vec_free (a->name); return 0; } @@ -439,6 +420,7 @@ active_open_attach (void) a->api_client_index = pm->active_open_client_index; a->session_cb_vft = &active_open_clients; + a->name = format (0, "proxy-active-open"); options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678; options[APP_OPTIONS_SEGMENT_SIZE] = 512 << 20; @@ -458,6 +440,8 @@ active_open_attach (void) pm->active_open_app_index = a->app_index; + vec_free (a->name); + return 0; } @@ -480,9 +464,6 @@ proxy_server_create (vlib_main_t * vm) u32 num_threads; int i; - if (pm->server_client_index == (u32) ~ 0) - create_api_loopbacks (vm); - num_threads = 1 /* main thread */ + vtm->n_threads; vec_validate (proxy_main.server_event_queue, num_threads - 1); vec_validate (proxy_main.active_open_event_queue, num_threads - 1); @@ -535,6 +516,7 @@ proxy_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, pm->private_segment_count = 0; pm->private_segment_size = 0; pm->server_uri = 0; + pm->client_uri = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -556,9 +538,9 @@ proxy_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, pm->private_segment_size = tmp; } else if (unformat (input, "server-uri %s", &pm->server_uri)) - ; + vec_add1 (pm->server_uri, 0); else if (unformat (input, "client-uri %s", &pm->client_uri)) - pm->client_uri = format (0, "%s%c", pm->client_uri, 0); + vec_add1 (pm->client_uri, 0); else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); |