76 active_open_session = s;
81 clib_warning (
"proxy session for %s handle %lld (%llx) AWOL",
82 is_active_open ?
"active open" :
"server",
101 clib_warning (
"proxy session for %s handle %lld (%llx) AWOL",
102 is_active_open ?
"active open" :
"server",
112 active_open_session = 0;
119 memset (ps, 0xFE,
sizeof (*ps));
125 if (active_open_session)
188 int actual_transfer __attribute__ ((unused));
197 session_fifo_event_t evt;
199 ASSERT (s->thread_index == thread_index);
207 active_open_tx_fifo = s->server_rx_fifo;
214 u32 ao_thread_index = active_open_tx_fifo->master_thread_index;
215 evt.fifo = active_open_tx_fifo;
224 rx_fifo = s->server_rx_fifo;
225 tx_fifo = s->server_tx_fifo;
227 ASSERT (rx_fifo->master_thread_index == thread_index);
228 ASSERT (tx_fifo->master_thread_index == thread_index);
236 max_dequeue, pm->
rx_buf[thread_index]);
240 memset (a, 0,
sizeof (*a));
244 memset (ps, 0,
sizeof (*ps));
257 a->api_context = proxy_index;
281 session_fifo_event_t evt;
304 s->server_tx_fifo->master_session_index = s->session_index;
305 s->server_tx_fifo->master_thread_index = s->thread_index;
312 s->server_tx_fifo->refcnt++;
313 s->server_rx_fifo->refcnt++;
325 evt.fifo = s->server_tx_fifo;
358 session_fifo_event_t evt;
361 proxy_tx_fifo = s->server_rx_fifo;
368 u32 p_thread_index = proxy_tx_fifo->master_thread_index;
369 evt.fifo = proxy_tx_fifo;
411 u32 segment_size = 512 << 20;
413 memset (a, 0,
sizeof (*a));
414 memset (options, 0,
sizeof (options));
420 a->options = options;
447 memset (a, 0,
sizeof (*a));
448 memset (options, 0,
sizeof (options));
462 | APP_OPTIONS_FLAGS_IS_PROXY;
464 a->options = options;
479 memset (a, 0,
sizeof (*a));
501 for (i = 0; i < num_threads; i++)
520 for (i = 0; i < num_threads; i++)
538 char *default_server_uri =
"tcp://0.0.0.0/23";
539 char *default_client_uri =
"tcp://6.0.2.2/23";
558 else if (
unformat (input,
"private-segment-count %d",
561 else if (
unformat (input,
"private-segment-size %U",
564 if (tmp >= 0x100000000ULL)
566 (0,
"private segment size %lld (%llu) too large", tmp, tmp);
580 clib_warning (
"No server-uri provided, Using default: %s",
586 clib_warning (
"No client-uri provided, Using default: %s",
608 .path =
"test proxy server",
609 .short_help =
"test proxy server [server-uri <tcp://ip/port>]" 610 "[client-uri <tcp://ip/port>][fifo-size <nn>][rcv-buf-size <nn>]" 611 "[prealloc-fifos <nn>][private-segment-size <mem>]" 612 "[private-segment-count <nn>]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static svm_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
u64 vpp_active_open_handle
#define hash_set(h, key, value)
u32 private_segment_count
Number of private fifo segs.
int svm_queue_add(svm_queue_t *q, u8 *elem, int nowait)
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
#define hash_unset(h, key)
static int proxy_add_segment_callback(u32 client_index, const ssvm_private_t *sp)
static void proxy_reset_callback(stream_session_t *s)
svm_queue_t * vl_input_queue
vpe input queue
struct _vnet_connect_args vnet_connect_args_t
int vnet_bind_uri(vnet_bind_args_t *a)
svm_queue_t ** active_open_event_queue
svm_queue_t ** server_event_queue
per-thread vectors
static int proxy_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static clib_error_t * proxy_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void create_api_loopbacks(vlib_main_t *vm)
uword * proxy_session_by_server_handle
static stream_session_t * session_get_from_handle(session_handle_t handle)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
svm_fifo_t * server_rx_fifo
struct _svm_fifo svm_fifo_t
u8 prealloc_fifos
Request fifo preallocation.
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
struct _stream_session_cb_vft session_cb_vft_t
static session_cb_vft_t proxy_session_cb_vft
#define clib_error_return(e, args...)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
u32 server_app_index
server app index
struct _stream_session_t stream_session_t
struct _vnet_app_attach_args_t vnet_app_attach_args_t
vl_shmem_hdr_t * shmem_hdr
clib_error_t * proxy_main_init(vlib_main_t *vm)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
proxy_session_t * sessions
Session pool, shared.
static int active_open_connected_callback(u32 app_index, u32 opaque, stream_session_t *s, u8 is_fail)
static void proxy_cb_fn(void *data, u32 data_len)
static session_handle_t session_handle(stream_session_t *s)
#define pool_put(P, E)
Free an object E in pool P.
static int proxy_server_create(vlib_main_t *vm)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
API main structure, used by both vpp and binary API clients.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
static void active_open_reset_callback(stream_session_t *s)
u32 active_open_client_index
active open API client handle
static int proxy_accept_callback(stream_session_t *s)
static_always_inline uword vlib_get_thread_index(void)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
#define clib_warning(format, args...)
u32 server_client_index
server API client handle
#define clib_memcpy(a, b, c)
static void proxy_call_main_thread(vnet_connect_args_t *a)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void delete_proxy_session(stream_session_t *s, int is_active_open)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
svm_queue_t * vl_input_queue
#define VLIB_CLI_COMMAND(x,...)
u32 active_open_app_index
active open index after attach
#define hash_create(elts, value_bytes)
static int proxy_server_attach()
static int active_open_create_callback(stream_session_t *s)
static void proxy_disconnect_callback(stream_session_t *s)
uword * proxy_session_by_active_open_handle
u8 ** rx_buf
intermediate rx buffers
clib_spinlock_t sessions_lock
u32 private_segment_size
size of private fifo segs
static int active_open_attach(void)
static int proxy_rx_callback(stream_session_t *s)
svm_fifo_t * server_tx_fifo
clib_error_t * vnet_connect_uri(vnet_connect_args_t *a)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static void active_open_disconnect_callback(stream_session_t *s)
static int proxy_server_listen()
static vlib_thread_main_t * vlib_get_thread_main()
static int active_open_rx_callback(stream_session_t *s)
static session_cb_vft_t active_open_clients
int svm_fifo_peek(svm_fifo_t *f, u32 relative_offset, u32 max_bytes, u8 *copy_here)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
struct _vnet_bind_args_t vnet_bind_args_t