diff options
author | Florin Coras <fcoras@cisco.com> | 2022-02-16 17:59:55 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2022-02-23 21:24:47 +0000 |
commit | f83d6668b083ca9ce502240557d8f6abd8645922 (patch) | |
tree | 024d88482ec4e6cfc5738761ce481b1ec8617c9c /src/plugins/http | |
parent | 45207e0fb2c46e211ff2e66fb141867d81198d97 (diff) |
http hsa: support multiple listeners for http tps
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ie89326ed4e599231fc20de67c5dadbb428568bec
Diffstat (limited to 'src/plugins/http')
-rw-r--r-- | src/plugins/http/http.c | 45 | ||||
-rw-r--r-- | src/plugins/http/http.h | 2 |
2 files changed, 40 insertions, 7 deletions
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c index 868d0ddf42d..f1a304829ac 100644 --- a/src/plugins/http/http.c +++ b/src/plugins/http/http.c @@ -76,17 +76,27 @@ static u32 http_listener_alloc (void) { http_main_t *hm = &http_main; - http_conn_t *ctx; + http_conn_t *lhc; - pool_get_zero (hm->listener_ctx_pool, ctx); - ctx->c_c_index = ctx - hm->listener_ctx_pool; - return ctx->c_c_index; + pool_get_zero (hm->listener_pool, lhc); + lhc->c_c_index = lhc - hm->listener_pool; + return lhc->c_c_index; } http_conn_t * -http_listener_get (u32 ctx_index) +http_listener_get (u32 lhc_index) { - return pool_elt_at_index (http_main.listener_ctx_pool, ctx_index); + return pool_elt_at_index (http_main.listener_pool, lhc_index); +} + +void +http_listener_free (http_conn_t *lhc) +{ + http_main_t *hm = &http_main; + + if (CLIB_DEBUG) + memset (lhc, 0xfc, sizeof (*lhc)); + pool_put (hm->listener_pool, lhc); } void @@ -776,6 +786,28 @@ http_start_listen (u32 app_listener_index, transport_endpoint_cfg_t *tep) return lhc_index; } +static u32 +http_stop_listen (u32 listener_index) +{ + http_conn_t *lhc; + int rv; + + lhc = http_listener_get (listener_index); + + vnet_unlisten_args_t a = { + .handle = lhc->h_tc_session_handle, + .app_index = http_main.app_index, + .wrk_map_index = 0 /* default wrk */ + }; + + if ((rv = vnet_unlisten (&a))) + clib_warning ("unlisten returned %d", rv); + + http_listener_free (lhc); + + return 0; +} + static void http_transport_close (u32 hc_index, u32 thread_index) { @@ -956,6 +988,7 @@ static const transport_proto_vft_t http_proto = { .enable = http_transport_enable, .connect = http_transport_connect, .start_listen = http_start_listen, + .stop_listen = http_stop_listen, .close = http_transport_close, .custom_tx = http_app_tx_callback, .get_connection = http_transport_get_connection, diff --git a/src/plugins/http/http.h b/src/plugins/http/http.h index 8a5731ea592..da74459794c 100644 --- a/src/plugins/http/http.h +++ b/src/plugins/http/http.h @@ -165,7 +165,7 @@ typedef struct http_worker_ typedef struct http_main_ { http_worker_t *wrk; - http_conn_t *listener_ctx_pool; + http_conn_t *listener_pool; u32 app_index; clib_timebase_t timebase; |