33 if (n_conns > 0 && is_add)
36 VLIB_NODE_STATE_POLLING);
37 else if (n_conns == 0)
40 VLIB_NODE_STATE_DISABLED);
50 ct->c_thread_index = 0;
68 memset (ct, 0xfc,
sizeof (*ct));
87 sep->port = ct->c_lcl_port;
88 sep->is_ip4 = ct->c_is_ip4;
113 clib_warning (
"failed to notify client %u of new segment",
160 cs->session_state = SESSION_STATE_READY;
169 u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index, seg_size;
173 u32 margin = 16 << 10;
181 round_rx_fifo_sz = 1 <<
max_log2 (props->rx_fifo_size);
182 round_tx_fifo_sz = 1 <<
max_log2 (props->tx_fifo_size);
183 seg_size = round_rx_fifo_sz + round_tx_fifo_sz + margin;
196 props->tx_fifo_size, &ls->
rx_fifo,
200 clib_warning (
"failed to add fifos in cut-through segment");
208 ls->
rx_fifo->segment_manager = sm_index;
209 ls->
tx_fifo->segment_manager = sm_index;
210 ls->
rx_fifo->segment_index = seg_index;
211 ls->
tx_fifo->segment_index = seg_index;
216 clib_warning (
"failed to notify server of new segment");
234 u32 cct_index, ll_index, ll_ct_index;
243 cct_index = cct->c_c_index;
251 cct->c_thread_index = 0;
252 cct->c_rmt_port = sep->port;
254 cct->c_is_ip4 = sep->is_ip4;
255 clib_memcpy (&cct->c_rmt_ip, &sep->ip, sizeof (sep->ip));
262 sct->c_thread_index = 0;
264 sct->c_lcl_port = ll_ct->c_lcl_port;
265 sct->c_is_ip4 = sep->is_ip4;
266 clib_memcpy (&sct->c_lcl_ip, &ll_ct->c_lcl_ip, sizeof (ll_ct->c_lcl_ip));
268 sct->c_proto = TRANSPORT_PROTO_NONE;
324 ct->c_is_ip4 = sep->is_ip4;
325 clib_memcpy (&ct->c_lcl_ip, &sep->ip, sizeof (sep->ip));
326 ct->c_lcl_port = sep->port;
329 return ct->c_c_index;
366 sep->transport_proto = sep_ext->original_tp;
370 return VNET_API_ERROR_APP_CONNECT_FILTERED;
395 return VNET_API_ERROR_SESSION_CONNECT;
398 return VNET_API_ERROR_APP_CONNECT_SCOPE;
452 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
456 &ct->c_rmt_ip4, clib_net_to_host_u16 (ct->c_rmt_port));
460 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
464 &ct->c_rmt_ip6, clib_net_to_host_u16 (ct->c_rmt_port));
488 ps =
session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
495 u32 tc_index = va_arg (*args,
u32);
496 u32 __clib_unused thread_index = va_arg (*args,
u32);
497 u32 __clib_unused verbose = va_arg (*args,
u32);
501 s =
format (s,
"%-15s",
"LISTEN");
509 u32 verbose = va_arg (*args,
u32);
516 s =
format (s,
"%-15s",
"ESTABLISHED");
528 u32 ct_index = va_arg (*args,
u32);
529 u32 __clib_unused thread_index = va_arg (*args,
u32);
530 u32 verbose = va_arg (*args,
u32);
536 s =
format (s,
"empty\n");
556 .transport_options = {
574 if (peer_s->
session_state >= SESSION_STATE_TRANSPORT_CLOSING)
static u32 ct_stop_listen(u32 ct_index)
u32 segment_manager_index(segment_manager_t *sm)
#define SESSION_DROP_HANDLE
u32 connection_index
Index of the transport connection associated to the session.
void segment_manager_segment_reader_unlock(segment_manager_t *sm)
u64 segment_manager_segment_handle(segment_manager_t *sm, fifo_segment_t *segment)
int ct_session_tx(session_t *s)
u8 * format_transport_proto_short(u8 *s, va_list *args)
session_type_t session_type
Type built from transport and network protocol types.
int segment_manager_add_segment(segment_manager_t *sm, uword segment_size)
Adds segment to segment manager's pool.
static int ct_connect(app_worker_t *client_wrk, session_t *ll, session_endpoint_cfg_t *sep)
u8 application_has_global_scope(application_t *app)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
static void ct_session_close(u32 ct_index, u32 thread_index)
static int ct_app_rx_evt(transport_connection_t *tc)
u32 session_index
Index in thread pool where session was allocated.
transport_connection_t * session_get_transport(session_t *s)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
app_listener_t * app_listener_get_w_session(session_t *ls)
u32 session_lookup_get_index_for_fib(u32 fib_proto, u32 fib_index)
static session_t * listen_session_get_from_handle(session_handle_t handle)
session_t * session_lookup_listener_wildcard(u32 table_index, session_endpoint_t *sep)
Lookup listener wildcard match.
static u8 * format_ct_session(u8 *s, va_list *args)
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
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.
static session_t * session_get(u32 si, u32 thread_index)
static int ct_session_connect(transport_endpoint_cfg_t *tep)
static ct_connection_t * ct_connection_alloc(void)
segment_manager_t * app_worker_get_listen_segment_manager(app_worker_t *, session_t *)
segment_manager_props_t * application_segment_manager_properties(application_t *app)
#define clib_memcpy(d, s, n)
u32 app_index
owning app index
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
void session_free_w_fifos(session_t *s)
vlib_node_registration_t session_queue_pre_input_node
(constructor) VLIB_REGISTER_NODE (session_queue_pre_input_node)
#define VLIB_INIT_FUNCTION(x)
void segment_manager_dealloc_fifos(svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
static void ct_enable_disable_main_pre_input_node(u8 is_add)
static transport_connection_t * ct_session_get(u32 ct_index, u32 thread_index)
static ct_connection_t * connections
#define SESSION_INVALID_HANDLE
static ct_connection_t * ct_connection_get(u32 ct_index)
struct _transport_proto_vft transport_proto_vft_t
int session_dequeue_notify(session_t *s)
struct _session_endpoint_cfg session_endpoint_cfg_t
svm_fifo_t * client_rx_fifo
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
void segment_manager_del_segment(segment_manager_t *sm, fifo_segment_t *fs)
Remove segment without lock.
#define pool_put(P, E)
Free an object E in pool P.
struct _segment_manager_props segment_manager_props_t
u32 wrk_index
Worker index in global worker pool.
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
static u64 listen_session_get_handle(session_t *s)
u64 session_lookup_local_endpoint(u32 table_index, session_endpoint_t *sep)
Look up endpoint in local session table.
u32 application_local_session_table(application_t *app)
static transport_connection_t * ct_listener_get(u32 ct_index)
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static u8 * format_ct_listener(u8 *s, va_list *args)
static u8 * format_ct_connection(u8 *s, va_list *args)
void session_free(session_t *s)
#define clib_warning(format, args...)
struct _transport_connection transport_connection_t
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
transport_proto_t actual_tp
application_t * application_get(u32 app_index)
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.
apps acting as transports
static const transport_proto_vft_t cut_thru_proto
transport_connection_t connection
int ct_session_connect_notify(session_t *ss)
session_t * ct_session_get_peer(session_t *s)
app_worker_t * application_listener_select_worker(session_t *ls)
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 vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static int ct_custom_tx(void *session, u32 max_burst_size)
static vlib_main_t * vlib_get_main(void)
u8 thread_index
Index of the thread that allocated the session.
int app_worker_del_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
session_t * session_alloc(u32 thread_index)
u32 app_index
App index in app pool.
app_worker_t * app_worker_get(u32 wrk_index)
volatile u8 session_state
State in session layer state machine.
int session_enqueue_notify(session_t *s)
static uword max_log2(uword x)
void session_close(session_t *s)
Initialize session closing procedure.
svm_fifo_t * client_tx_fifo
struct _segment_manager segment_manager_t
static u32 ct_start_listen(u32 app_listener_index, transport_endpoint_t *tep)
segment_manager_t * segment_manager_get(u32 index)
static u8 session_has_transport(session_t *s)
u32 app_index
Index of owning app.
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 int ct_init_local_session(app_worker_t *client_wrk, app_worker_t *server_wrk, ct_connection_t *ct, session_t *ls, session_t *ll)
static u32 vlib_num_workers()
u32 app_wrk_index
Index of the app worker that owns the session.
static u8 session_endpoint_is_local(session_endpoint_t *sep)
static void ct_connection_free(ct_connection_t *ct)
static u8 * format_ct_connection_id(u8 *s, va_list *args)
struct _session_endpoint session_endpoint_t
static clib_error_t * ct_transport_init(vlib_main_t *vm)
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, u32 opaque)
static session_t * listen_session_get(u32 ls_index)
void ct_session_endpoint(session_t *ll, session_endpoint_t *sep)
static uword pool_elts(void *v)
Number of active elements in a pool.