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;
195 props->tx_fifo_size, &ls->
rx_fifo,
199 clib_warning (
"failed to add fifos in cut-through segment");
207 ls->
rx_fifo->segment_manager = sm_index;
208 ls->
tx_fifo->segment_manager = sm_index;
209 ls->
rx_fifo->segment_index = seg_index;
210 ls->
tx_fifo->segment_index = seg_index;
215 clib_warning (
"failed to notify server of new segment");
233 u32 cct_index, ll_index, ll_ct_index;
242 cct_index = cct->c_c_index;
250 cct->c_thread_index = 0;
251 cct->c_rmt_port = sep->port;
253 cct->c_is_ip4 = sep->is_ip4;
254 clib_memcpy (&cct->c_rmt_ip, &sep->ip, sizeof (sep->ip));
261 sct->c_thread_index = 0;
263 sct->c_lcl_port = ll_ct->c_lcl_port;
264 sct->c_is_ip4 = sep->is_ip4;
265 clib_memcpy (&sct->c_lcl_ip, &ll_ct->c_lcl_ip, sizeof (ll_ct->c_lcl_ip));
267 sct->c_proto = TRANSPORT_PROTO_NONE;
323 ct->c_is_ip4 = sep->is_ip4;
324 clib_memcpy (&ct->c_lcl_ip, &sep->ip, sizeof (sep->ip));
325 ct->c_lcl_port = sep->port;
328 return ct->c_c_index;
365 sep->transport_proto = sep_ext->original_tp;
369 return VNET_API_ERROR_APP_CONNECT_FILTERED;
394 return VNET_API_ERROR_SESSION_CONNECT;
397 return VNET_API_ERROR_APP_CONNECT_SCOPE;
451 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
455 &ct->c_rmt_ip4, clib_net_to_host_u16 (ct->c_rmt_port));
459 s =
format (s,
"[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
463 &ct->c_rmt_ip6, clib_net_to_host_u16 (ct->c_rmt_port));
487 ps =
session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
494 u32 tc_index = va_arg (*args,
u32);
495 u32 __clib_unused thread_index = va_arg (*args,
u32);
496 u32 __clib_unused verbose = va_arg (*args,
u32);
500 s =
format (s,
"%-15s",
"LISTEN");
508 u32 verbose = va_arg (*args,
u32);
515 s =
format (s,
"%-15s",
"ESTABLISHED");
527 u32 ct_index = va_arg (*args,
u32);
528 u32 __clib_unused thread_index = va_arg (*args,
u32);
529 u32 verbose = va_arg (*args,
u32);
535 s =
format (s,
"empty\n");
555 .transport_options = {
573 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.
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)
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)
int segment_manager_try_alloc_fifos(fifo_segment_t *fifo_segment, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
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)
u32 application_session_table(application_t *app, u8 fib_proto)
int segment_manager_add_segment(segment_manager_t *sm, u32 segment_size)
Adds segment to segment manager's pool.
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)
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.
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.