X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Fbuiltin_proxy.c;h=a4827bff56ddf8bd1cfe6ce2f2ab60fd63f86834;hb=b384b543313b6b47a277c903e9d4fcd4343054fa;hp=e1e0198e6953fdcbb2d1a5604e911e8651a46a67;hpb=3cbc04bea02fc60471dfe0c671ede3ca42c118c3;p=vpp.git diff --git a/src/vnet/tcp/builtin_proxy.c b/src/vnet/tcp/builtin_proxy.c index e1e0198e695..a4827bff56d 100644 --- a/src/vnet/tcp/builtin_proxy.c +++ b/src/vnet/tcp/builtin_proxy.c @@ -139,8 +139,7 @@ server_connected_callback (u32 app_index, u32 api_context, } static int -server_add_segment_callback (u32 client_index, - const u8 * seg_name, u32 seg_size) +server_add_segment_callback (u32 client_index, const ssvm_private_t * sp) { clib_warning ("called..."); return -1; @@ -185,7 +184,7 @@ server_rx_callback (stream_session_t * s) { evt.fifo = active_open_tx_fifo; evt.event_type = FIFO_EVENT_APP_TX; - if (unix_shared_memory_queue_add + if (svm_queue_add (bpm->active_open_event_queue[thread_index], (u8 *) & evt, 0 /* do wait for mutex */ )) clib_warning ("failed to enqueue tx evt"); @@ -226,7 +225,7 @@ server_rx_callback (stream_session_t * s) clib_spinlock_unlock_if_init (&bpm->sessions_lock); - a->uri = "tcp://6.0.2.2/23"; + a->uri = (char *) bpm->client_uri; a->api_context = proxy_index; a->app_index = bpm->active_open_app_index; a->mp = 0; @@ -299,7 +298,7 @@ active_open_connected_callback (u32 app_index, u32 opaque, { evt.fifo = s->server_tx_fifo; evt.event_type = FIFO_EVENT_APP_TX; - if (unix_shared_memory_queue_add + if (svm_queue_add (bpm->active_open_event_queue[thread_index], (u8 *) & evt, 0 /* do wait for mutex */ )) clib_warning ("failed to enqueue tx evt"); @@ -343,7 +342,7 @@ active_open_rx_callback (stream_session_t * s) { evt.fifo = server_rx_fifo; evt.event_type = FIFO_EVENT_APP_TX; - if (unix_shared_memory_queue_add + if (svm_queue_add (bpm->server_event_queue[thread_index], (u8 *) & evt, 0 /* do wait for mutex */ )) clib_warning ("failed to enqueue server rx evt"); @@ -382,28 +381,26 @@ static int server_attach () { builtin_proxy_main_t *bpm = &builtin_proxy_main; - u8 segment_name[128]; - u64 options[SESSION_OPTIONS_N_OPTIONS]; + u64 options[APP_OPTIONS_N_OPTIONS]; vnet_app_attach_args_t _a, *a = &_a; + u32 segment_size = 512 << 20; memset (a, 0, sizeof (*a)); memset (options, 0, sizeof (options)); + if (bpm->private_segment_size) + segment_size = bpm->private_segment_size; a->api_client_index = bpm->server_client_index; a->session_cb_vft = &builtin_session_cb_vft; a->options = options; - a->options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20; - a->options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size; - a->options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size; + a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size; + a->options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size; + a->options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size; a->options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count; - a->options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size; a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = bpm->prealloc_fifos ? bpm->prealloc_fifos : 1; - a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_BUILTIN_APP; - - a->segment_name = segment_name; - a->segment_name_length = ARRAY_LEN (segment_name); + a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN; if (vnet_application_attach (a)) { @@ -420,30 +417,23 @@ active_open_attach (void) { builtin_proxy_main_t *bpm = &builtin_proxy_main; vnet_app_attach_args_t _a, *a = &_a; - u8 segment_name[128]; - u32 segment_name_length; u64 options[16]; - segment_name_length = ARRAY_LEN (segment_name); - memset (a, 0, sizeof (*a)); memset (options, 0, sizeof (options)); a->api_client_index = bpm->active_open_client_index; - a->segment_name = segment_name; - a->segment_name_length = segment_name_length; a->session_cb_vft = &builtin_clients; - options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678; - options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20; - options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size; - options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size; + options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678; + options[APP_OPTIONS_SEGMENT_SIZE] = 512 << 20; + options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size; + options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size; options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count; - options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size; options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = bpm->prealloc_fifos ? bpm->prealloc_fifos : 1; - options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_BUILTIN_APP + options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN | APP_OPTIONS_FLAGS_IS_PROXY; a->options = options; @@ -463,7 +453,7 @@ server_listen () vnet_bind_args_t _a, *a = &_a; memset (a, 0, sizeof (*a)); a->app_index = bpm->server_app_index; - a->uri = "tcp://0.0.0.0/23"; + a->uri = (char *) bpm->server_uri; return vnet_bind_uri (a); } @@ -528,6 +518,7 @@ proxy_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, bpm->prealloc_fifos = 0; bpm->private_segment_count = 0; bpm->private_segment_size = 0; + bpm->server_uri = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -548,11 +539,20 @@ proxy_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, (0, "private segment size %lld (%llu) too large", tmp, tmp); bpm->private_segment_size = tmp; } + else if (unformat (input, "server-uri %s", &bpm->server_uri)) + ; + else if (unformat (input, "client-uri %s", &bpm->client_uri)) + ; else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); } + if (!bpm->server_uri) + bpm->server_uri = format (0, "%s%c", "tcp://0.0.0.0/23", 0); + if (!bpm->client_uri) + bpm->client_uri = format (0, "%s%c", "tcp://6.0.2.2/23", 0); + vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ ); rv = server_create (vm); @@ -571,7 +571,10 @@ proxy_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, VLIB_CLI_COMMAND (server_create_command, static) = { .path = "test proxy server", - .short_help = "test proxy server", + .short_help = "test proxy server [server-uri ]" + "[client-uri ][fifo-size ][rcv-buf-size ]" + "[prealloc-fifos ][private-segment-size ]" + "[private-segment-count ]", .function = proxy_server_create_command_fn, }; /* *INDENT-ON* */