|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
22 #define ECHO_SERVER_DBG (0)
23 #define DBG(_fmt, _args...) \
24 if (ECHO_SERVER_DBG) \
25 clib_warning (_fmt, ##_args)
156 for (
i = 0;
i < actual_transfer;
i++)
182 u32 n_written, max_dequeue, max_enqueue, max_transfer;
206 max_dequeue =
ph.data_length -
ph.data_offset;
220 max_transfer =
clib_min (max_dequeue, max_enqueue);
264 ASSERT (actual_transfer == max_transfer);
288 if (n_written != max_transfer)
289 clib_warning (
"short trout! written %u read %u", n_written, max_transfer);
313 u32 segment_size = 512 << 20;
331 a->api_client_index = ~0;
332 a->name =
format (0,
"echo_server");
348 a->namespace_id = appns_id;
380 da->api_client_index = ~0;
390 return proto == TRANSPORT_PROTO_TLS ||
proto == TRANSPORT_PROTO_DTLS ||
391 proto == TRANSPORT_PROTO_QUIC;
401 args->sep_ext.app_wrk_index = 0;
412 args->sep_ext.ext_cfg->crypto.ckpair_index = esm->
ckpair_index;
415 if (args->sep_ext.transport_proto == TRANSPORT_PROTO_UDP)
422 if (args->sep_ext.ext_cfg)
444 for (
i = 0;
i < num_threads;
i++)
468 u8 server_uri_set = 0, *appns_id = 0;
469 u64 tmp, appns_flags = 0, appns_secret = 0;
470 char *default_uri =
"tcp://0.0.0.0/1234";
471 int rv, is_stop = 0, barrier_acq_needed = 0;
480 barrier_acq_needed = 1;
497 else if (
unformat (input,
"no-echo"))
505 else if (
unformat (input,
"private-segment-count %d",
508 else if (
unformat (input,
"private-segment-size %U",
511 if (
tmp >= 0x100000000ULL)
514 0,
"private segment size %lld (%llu) too large",
tmp,
tmp);
519 else if (
unformat (input,
"appns %_%v%_", &appns_id))
521 else if (
unformat (input,
"all-scope"))
522 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
523 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
524 else if (
unformat (input,
"local-scope"))
525 appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
526 else if (
unformat (input,
"global-scope"))
527 appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
528 else if (
unformat (input,
"secret %lu", &appns_secret))
564 clib_warning (
"No uri provided! Using default: %s", default_uri);
574 esm->
is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
587 if (barrier_acq_needed)
596 .path =
"test echo server",
597 .short_help =
"test echo server proto <proto> [no echo][fifo-size <mbytes>]"
598 "[rcv-buf-size <bytes>][prealloc-fifos <count>]"
599 "[private-segment-count <count>][private-segment-size <bytes[m|g]>]"
600 "[uri <tcp://ip/port>]",
u32 my_client_index
API client handle.
int vnet_listen(vnet_listen_args_t *a)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
static u32 vlib_num_workers()
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
enum session_error_ session_error_t
int echo_server_session_accept_callback(session_t *s)
@ APP_OPTIONS_RX_FIFO_SIZE
static int app_send_stream_raw(svm_fifo_t *f, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
u32 session_index
Index in thread pool where session was allocated.
static int echo_server_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
echo_server_main_t echo_server_main
struct session_dgram_header_ session_dgram_hdr_t
u8 is_dgram
set if transport is dgram
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
static void clib_mem_free(void *p)
u32 app_index
Server app index.
void test_bytes(echo_server_main_t *esm, int actual_transfer)
int(* builtin_app_rx_callback)(session_t *session)
Direct RX callback for built-in application.
#define clib_error_return(e, args...)
struct _session_endpoint_cfg session_endpoint_cfg_t
int echo_server_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
static int echo_server_detach(void)
static int app_recv_stream_raw(svm_fifo_t *f, u8 *buf, u32 len, u8 clear_evt, u8 peek)
struct _svm_queue svm_queue_t
u32 private_segment_count
Number of private segments
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
u8 thread_index
Index of the thread that allocated the session.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
static session_cb_vft_t echo_server_session_cb_vft
u32 rcv_buffer_size
Rcv buffer size.
@ APP_OPTIONS_SEGMENT_SIZE
struct _vnet_app_detach_args_t vnet_app_detach_args_t
void echo_server_session_disconnect_callback(session_t *s)
@ APP_OPTIONS_NAMESPACE_SECRET
static int echo_server_create(vlib_main_t *vm, u8 *appns_id, u64 appns_flags, u64 appns_secret)
session_worker_t * wrk
Worker contexts.
pool_header_t * ph(void *p)
GDB callable function: ph - call pool_header - get pool header.
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
struct _svm_fifo svm_fifo_t
#define SESSION_ENDPOINT_CFG_NULL
int echo_server_redirect_connect_callback(u32 client_index, void *mp)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
u8 no_echo
Don't echo traffic.
@ SESSION_IO_EVT_BUILTIN_RX
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void session_endpoint_alloc_ext_cfg(session_endpoint_cfg_t *sep_ext, transport_endpt_ext_cfg_type_t type)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static const char test_srv_key_rsa[]
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
int vnet_app_del_cert_key_pair(u32 index)
#define vlib_worker_thread_barrier_sync(X)
static_always_inline uword vlib_get_thread_index(void)
int echo_server_add_segment_callback(u32 client_index, u64 segment_handle)
struct _vnet_bind_args_t vnet_listen_args_t
static u8 vlib_thread_is_main_w_barrier(void)
session_main_t session_main
u32 private_segment_size
Size of private segments
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
static session_handle_t session_handle(session_t *s)
@ TRANSPORT_CFG_F_CONNECTED
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * echo_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int app_send_dgram_raw(svm_fifo_t *f, app_session_transport_t *at, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
u8 ** rx_buf
Per-thread RX buffer.
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
u32 prealloc_fifos
Preallocate fifos.
int vnet_disconnect_session(vnet_disconnect_args_t *a)
char * server_uri
Server URI.
u64 listener_handle
Session handle of the root listener.
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
@ APP_OPTIONS_PREALLOC_FIFO_PAIRS
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static int echo_client_transport_needs_crypto(transport_proto_t proto)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
#define vec_free(V)
Free vector's memory (no header).
u32 ckpair_index
Cert and key for tls/quic.
@ APP_OPTIONS_TX_FIFO_SIZE
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
static const char test_srv_crt_rsa[]
@ APP_OPTIONS_ADD_SEGMENT_SIZE
description fragment has unexpected format
u32 opaque
Opaque, for general use.
#define VLIB_INIT_FUNCTION(x)
static struct option options[]
enum _transport_proto transport_proto_t
int quic_echo_server_qsession_accept_callback(session_t *s)
static const u32 test_srv_crt_rsa_len
static uword pool_elts(void *v)
Number of active elements in a pool.
void echo_server_session_reset_callback(session_t *s)
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
session_t * sessions
Worker session pool.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define DBG(_fmt, _args...)
static vlib_cli_command_t echo_server_create_command
(constructor) VLIB_CLI_COMMAND (echo_server_create_command)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
int echo_server_builtin_server_rx_callback_no_echo(session_t *s)
clib_error_t * echo_server_main_init(vlib_main_t *vm)
#define clib_warning(format, args...)
static void cleanup(void)
u32 tls_engine
TLS engine: mbedtls/openssl.
struct _vnet_app_attach_args_t vnet_app_attach_args_t
@ APP_OPTIONS_PCT_FIRST_ALLOC
static vlib_thread_main_t * vlib_get_thread_main()
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
volatile u8 session_state
State in session layer state machine.
@ TRANSPORT_ENDPT_EXT_CFG_CRYPTO
svm_queue_t * vl_input_queue
Sever's event queue.
int quic_echo_server_session_accept_callback(session_t *s)
@ APP_OPTIONS_PRIVATE_SEGMENT_COUNT
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
static int echo_server_listen()
static const u32 test_srv_key_rsa_len
int echo_server_rx_callback(session_t *s)
u32 node_index
process node index for event scheduling