|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
57 memset (ct, 0xfc,
sizeof (*ct));
104 sep->port = ct->c_lcl_port;
105 sep->is_ip4 = ct->c_is_ip4;
106 ip_copy (&sep->ip, &ct->c_lcl_ip, ct->c_is_ip4);
133 clib_warning (
"failed to notify client %u of new segment",
159 cct->
flags &= ~CT_CONN_F_HALF_OPEN;
196 cs =
session_get (cct->c_s_index, cct->c_thread_index);
211 u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index, seg_size;
215 u32 margin = 16 << 10;
223 round_rx_fifo_sz = 1 <<
max_log2 (props->rx_fifo_size);
224 round_tx_fifo_sz = 1 <<
max_log2 (props->tx_fifo_size);
229 seg_size = 4 * (round_rx_fifo_sz + round_tx_fifo_sz + margin);
242 props->tx_fifo_size, &ls->
rx_fifo,
246 clib_warning (
"failed to add fifos in cut-through segment");
256 ls->
rx_fifo->segment_manager = sm_index;
257 ls->
tx_fifo->segment_manager = sm_index;
258 ls->
rx_fifo->segment_index = seg_index;
259 ls->
tx_fifo->segment_index = seg_index;
264 clib_warning (
"failed to notify server of new segment");
292 cct_index = cct->c_c_index;
305 cct->c_c_index = cct_index;
307 cct->
flags |= CT_CONN_F_HALF_OPEN;
330 sct->c_lcl_port = ll_ct->lcl_port;
331 sct->c_is_ip4 = cct->c_is_ip4;
332 clib_memcpy (&sct->c_lcl_ip, &ll_ct->lcl_ip, sizeof (ll_ct->lcl_ip));
334 sct->c_proto = TRANSPORT_PROTO_NONE;
398 ho_index = ho->c_c_index;
399 ho->c_rmt_port = sep->port;
401 ho->c_is_ip4 = sep->is_ip4;
405 ho->c_proto = TRANSPORT_PROTO_NONE;
407 clib_memcpy (&ho->c_rmt_ip, &sep->ip, sizeof (sep->ip));
408 ho->
flags |= CT_CONN_F_CLIENT;
433 ct->c_is_ip4 = sep->is_ip4;
434 clib_memcpy (&ct->c_lcl_ip, &sep->ip, sizeof (sep->ip));
435 ct->c_lcl_port = sep->port;
436 ct->c_s_index = app_listener_index;
438 return ct->c_c_index;
502 sep->transport_proto = sep_ext->original_tp;
506 return SESSION_E_FILTERED;
531 return SESSION_E_NOROUTE;
534 return SESSION_E_SCOPE;
545 return SESSION_E_LOCAL_CONNECT;
561 if (peer_ct->
flags & CT_CONN_F_HALF_OPEN)
567 else if (peer_ct->c_s_index != ~0)
573 s =
session_get (ct->c_s_index, ct->c_thread_index);
578 if (ct->
flags & CT_CONN_F_CLIENT)
599 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
603 &ct->c_rmt_ip4, clib_net_to_host_u16 (ct->c_rmt_port));
607 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
611 &ct->c_rmt_ip6, clib_net_to_host_u16 (ct->c_rmt_port));
645 ps =
session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
652 u32 tc_index = va_arg (*args,
u32);
654 u32 __clib_unused verbose = va_arg (*args,
u32);
665 u32 ho_index = va_arg (*args,
u32);
666 u32 verbose = va_arg (*args,
u32);
678 u32 verbose = va_arg (*args,
u32);
697 u32 ct_index = va_arg (*args,
u32);
699 u32 verbose = va_arg (*args,
u32);
705 s =
format (s,
"empty\n");
742 .transport_options = {
761 peer_s =
session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
762 if (peer_s->
session_state >= SESSION_STATE_TRANSPORT_CLOSING)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
fifo_segment_t * segment_manager_get_segment_w_lock(segment_manager_t *sm, u32 segment_index)
Reads a segment from the segment manager's pool and acquires reader lock.
static void clib_spinlock_init(clib_spinlock_t *p)
#define SESSION_CLI_STATE_LEN
static u8 * format_ct_listener(u8 *s, va_list *args)
static u32 vlib_num_workers()
u32 wrk_index
Worker index in global worker pool.
static ct_connection_t * ct_half_open_alloc(void)
int session_enqueue_notify(session_t *s)
segment_manager_t * segment_manager_get(u32 index)
description security check failed
int session_dequeue_notify(session_t *s)
u32 session_index
Index in thread pool where session was allocated.
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
#define clib_memcpy(d, s, n)
#define SESSION_CLI_ID_LEN
void session_close(session_t *s)
Initialize session closing procedure.
static u32 ct_start_listen(u32 app_listener_index, transport_endpoint_t *tep)
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
static ct_connection_t * ct_connection_alloc(u32 thread_index)
static uword pointer_to_uword(const void *p)
void session_half_open_delete_notify(transport_connection_t *tc)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static int ct_custom_tx(void *session, transport_send_params_t *sp)
static u64 listen_session_get_handle(session_t *s)
session_t * ct_session_get_peer(session_t *s)
void ct_half_open_add_reusable(u32 ho_index)
segment_manager_t * app_worker_get_listen_segment_manager(app_worker_t *, session_t *)
struct _segment_manager segment_manager_t
struct _session_endpoint_cfg session_endpoint_cfg_t
segment_manager_props_t * application_segment_manager_properties(application_t *app)
struct _transport_proto_vft transport_proto_vft_t
static session_t * listen_session_get(u32 ls_index)
u32 app_index
App index in app pool.
int session_half_open_migrated_notify(transport_connection_t *tc)
u8 thread_index
Index of the thread that allocated the session.
#define pool_put(P, E)
Free an object E in pool P.
session_type_t session_type
Type built from transport and network protocol types.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
u32 * ho_reusable
Vector of reusable ho indices.
static u8 session_endpoint_is_local(session_endpoint_t *sep)
ct_connection_flags_t flags
struct _transport_connection transport_connection_t
int app_worker_del_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
void session_free(session_t *s)
#define pool_put_index(p, i)
Free pool element with given index.
static uword max_log2(uword x)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
application_t * application_get(u32 app_index)
int ct_session_connect_notify(session_t *ss)
u32 app_wrk_index
Index of the app worker that owns the session.
u8 application_has_global_scope(application_t *app)
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
@ TRANSPORT_SND_F_DESCHED
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static void ct_session_close(u32 ct_index, u32 thread_index)
u32 app_index
owning app index
u32 app_index
Index of application that owns the listener.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void segment_manager_dealloc_fifos(svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
transport_connection_t * session_get_transport(session_t *s)
static transport_connection_t * ct_listener_get(u32 ct_index)
session_t * session_lookup_listener_wildcard(u32 table_index, session_endpoint_t *sep)
Lookup listener wildcard match.
struct _segment_manager_props segment_manager_props_t
static_always_inline uword vlib_get_thread_index(void)
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
app_worker_t * application_listener_select_worker(session_t *ls)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
svm_fifo_t * client_rx_fifo
void segment_manager_segment_reader_unlock(segment_manager_t *sm)
int segment_manager_add_segment(segment_manager_t *sm, uword segment_size, u8 notify_app)
Adds segment to segment manager's pool.
void session_half_open_migrate_notify(transport_connection_t *tc)
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
u64 segment_manager_segment_handle(segment_manager_t *sm, fifo_segment_t *segment)
vnet_feature_config_main_t * cm
void segment_manager_lock_and_del_segment(segment_manager_t *sm, u32 fs_index)
u64 session_lookup_local_endpoint(u32 table_index, session_endpoint_t *sep)
Look up endpoint in local session table.
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
static ct_connection_t * ct_connection_get(u32 ct_index, u32 thread_index)
static u8 * format_ct_session(u8 *s, va_list *args)
#define SESSION_DROP_HANDLE
static u8 * format_ct_connection_id(u8 *s, va_list *args)
u32 segment_manager_index(segment_manager_t *sm)
static session_t * session_get(u32 si, u32 thread_index)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, session_error_t err, u32 opaque)
u32 n_workers
Number of vpp workers.
transport_proto_t actual_tp
@ TRANSPORT_TX_INTERNAL
apps acting as transports
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
@ TRANSPORT_SERVICE_VC
virtual circuit service
u32 application_local_session_table(application_t *app)
transport_connection_t connection
static u32 ct_stop_listen(u32 ct_index)
static int ct_init_accepted_session(app_worker_t *server_wrk, ct_connection_t *ct, session_t *ls, session_t *ll)
@ TRANSPORT_CONNECTION_F_NO_LOOKUP
Don't register connection in lookup.
description fragment has unexpected format
static transport_connection_t * ct_half_open_get(u32 ct_index)
struct ct_main_ ct_main_t
int app_worker_add_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
Send an API message to the external app, to map new segment.
#define VLIB_INIT_FUNCTION(x)
transport_connection_t * listen_session_get_transport(session_t *s)
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
u32 n_sessions
Cumulative sessions counter.
app_worker_t * app_worker_get(u32 wrk_index)
ct_connection_t ** connections
Per-worker connection pools.
#define vec_foreach(var, vec)
Vector iterator.
static void ct_cleanup_ho(u32 ho_index)
struct _session_endpoint session_endpoint_t
static void ct_connection_free(ct_connection_t *ct)
svm_fifo_t * client_tx_fifo
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
#define SESSION_INVALID_HANDLE
static clib_error_t * ct_transport_init(vlib_main_t *vm)
int ct_session_tx(session_t *s)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
void ct_session_endpoint(session_t *ll, session_endpoint_t *sep)
#define uword_to_pointer(u, type)
static const transport_proto_vft_t cut_thru_proto
transport_snd_flags_t flags
#define clib_warning(format, args...)
static int ct_app_rx_evt(transport_connection_t *tc)
static u8 * format_ct_connection(u8 *s, va_list *args)
void session_free_w_fifos(session_t *s)
app_listener_t * app_listener_get_w_session(session_t *ls)
static transport_connection_t * ct_session_get(u32 ct_index, u32 thread_index)
static u8 * format_ct_half_open(u8 *s, va_list *args)
clib_spinlock_t ho_reuseable_lock
Lock for reusable ho indices.
u32 app_index
Index of owning app.
static u8 session_has_transport(session_t *s)
static void ct_session_cleanup(u32 conn_index, u32 thread_index)
static int ct_connect(app_worker_t *client_wrk, session_t *ll, session_endpoint_cfg_t *sep)
u8 * format_transport_proto_short(u8 *s, va_list *args)
u32 session_lookup_get_index_for_fib(u32 fib_proto, u32 fib_index)
clib_error_t * ct_enable_disable(vlib_main_t *vm, u8 is_en)
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
session_t * session_alloc(u32 thread_index)
static int ct_session_connect(transport_endpoint_cfg_t *tep)
volatile u8 session_state
State in session layer state machine.
u32 connection_index
Index of the transport connection associated to the session.
static void ct_accept_rpc_wrk_handler(void *accept_args)
int segment_manager_try_alloc_fifos(fifo_segment_t *fifo_segment, u32 thread_index, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
static session_t * listen_session_get_from_handle(session_handle_t handle)
void session_send_rpc_evt_to_thread_force(u32 thread_index, void *fp, void *rpc_args)