FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
session.c File Reference

Session and session manager. More...

+ Include dependency graph for session.c:

Go to the source code of this file.

Typedefs

typedef struct _session_switch_pool_args session_switch_pool_args_t
 
typedef int(* session_open_service_fn) (u32, session_endpoint_t *, u32)
 
typedef int(* session_listen_service_fn) (stream_session_t *, session_endpoint_t *)
 

Functions

static void session_send_evt_to_thread (u64 session_handle, fifo_event_type_t evt_type, u32 thread_index, void *fp, void *rpc_args)
 
void session_send_session_evt_to_thread (u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
 
void session_send_rpc_evt_to_thread (u32 thread_index, void *fp, void *rpc_args)
 
stream_session_tsession_alloc (u32 thread_index)
 
void session_free (stream_session_t *s)
 
int session_alloc_fifos (segment_manager_t *sm, stream_session_t *s)
 
static stream_session_tsession_alloc_for_connection (transport_connection_t *tc)
 
static int session_alloc_and_init (segment_manager_t *sm, transport_connection_t *tc, u8 alloc_fifos, stream_session_t **ret_s)
 
static void session_enqueue_discard_chain_bytes (vlib_main_t *vm, vlib_buffer_t *b, vlib_buffer_t **chain_b, u32 n_bytes_to_drop)
 Discards bytes from buffer chain. More...
 
static int session_enqueue_chain_tail (stream_session_t *s, vlib_buffer_t *b, u32 offset, u8 is_in_order)
 Enqueue buffer chain tail. More...
 
int session_enqueue_stream_connection (transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
 
int session_enqueue_dgram_connection (stream_session_t *s, session_dgram_hdr_t *hdr, vlib_buffer_t *b, u8 proto, u8 queue_event)
 
u8 stream_session_no_space (transport_connection_t *tc, u32 thread_index, u16 data_len)
 Check if we have space in rx fifo to push more bytes. More...
 
u32 session_tx_fifo_max_dequeue (transport_connection_t *tc)
 
int stream_session_peek_bytes (transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
 
u32 stream_session_dequeue_drop (transport_connection_t *tc, u32 max_bytes)
 
static int session_enqueue_notify (stream_session_t *s, u8 block)
 Notify session peer that new data has been enqueued. More...
 
int session_manager_flush_enqueue_events (u8 transport_proto, u32 thread_index)
 Flushes queue of sessions that are to be notified of new data enqueued events. More...
 
int session_manager_flush_all_enqueue_events (u8 transport_proto)
 
void stream_session_init_fifos_pointers (transport_connection_t *tc, u32 rx_pointer, u32 tx_pointer)
 Init fifo tail and head pointers. More...
 
int session_stream_connect_notify (transport_connection_t *tc, u8 is_fail)
 
static void session_switch_pool (void *cb_args)
 
int session_dgram_connect_notify (transport_connection_t *tc, u32 old_thread_index, stream_session_t **new_session)
 Move dgram session to the right thread. More...
 
void stream_session_accept_notify (transport_connection_t *tc)
 
void stream_session_disconnect_notify (transport_connection_t *tc)
 Notification from transport that connection is being closed. More...
 
void stream_session_delete (stream_session_t *s)
 Cleans up session and lookup table. More...
 
void stream_session_delete_notify (transport_connection_t *tc)
 Notification from transport that connection is being deleted. More...
 
void stream_session_reset_notify (transport_connection_t *tc)
 Notify application that connection has been reset. More...
 
int stream_session_accept (transport_connection_t *tc, u32 listener_index, u8 notify)
 Accept a stream session. More...
 
int session_open_cl (u32 app_index, session_endpoint_t *rmt, u32 opaque)
 
int session_open_vc (u32 app_index, session_endpoint_t *rmt, u32 opaque)
 
int session_open_app (u32 app_index, session_endpoint_t *rmt, u32 opaque)
 
int session_open (u32 app_index, session_endpoint_t *rmt, u32 opaque)
 Ask transport to open connection to remote transport endpoint. More...
 
int session_listen_vc (stream_session_t *s, session_endpoint_t *sep)
 
int session_listen_cl (stream_session_t *s, session_endpoint_t *sep)
 
int session_listen_app (stream_session_t *s, session_endpoint_t *sep)
 
int stream_session_listen (stream_session_t *s, session_endpoint_t *sep)
 Ask transport to listen on local transport endpoint. More...
 
int stream_session_stop_listen (stream_session_t *s)
 Ask transport to stop listening on local transport endpoint. More...
 
void stream_session_disconnect (stream_session_t *s)
 Initialize session disconnect. More...
 
void stream_session_disconnect_transport (stream_session_t *s)
 Notify transport the session can be disconnected. More...
 
void stream_session_cleanup (stream_session_t *s)
 Cleanup transport and session state. More...
 
transport_service_type_t session_transport_service_type (stream_session_t *s)
 
transport_tx_fn_type_t session_transport_tx_fn_type (stream_session_t *s)
 
u8 session_tx_is_dgram (stream_session_t *s)
 
void session_vpp_event_queues_allocate (session_manager_main_t *smm)
 Allocate event queues in the shared-memory segment. More...
 
ssvm_private_tsession_manager_get_evt_q_segment (void)
 
void session_register_transport (transport_proto_t transport_proto, const transport_proto_vft_t *vft, u8 is_ip4, u32 output_node)
 Initialize session layer for given transport proto and ip version. More...
 
transport_connection_tsession_get_transport (stream_session_t *s)
 
transport_connection_tlisten_session_get_transport (stream_session_t *s)
 
int listen_session_get_local_session_endpoint (stream_session_t *listener, session_endpoint_t *sep)
 
void session_flush_frames_main_thread (vlib_main_t *vm)
 
static clib_error_tsession_manager_main_enable (vlib_main_t *vm)
 
void session_node_enable_disable (u8 is_en)
 
clib_error_tvnet_session_enable_disable (vlib_main_t *vm, u8 is_en)
 
clib_error_tsession_manager_main_init (vlib_main_t *vm)
 
static clib_error_tsession_config_fn (vlib_main_t *vm, unformat_input_t *input)
 

Variables

session_manager_main_t session_manager_main
 
transport_proto_vft_ttp_vfts
 Per-type vector of transport protocol virtual function tables. More...
 
static session_open_service_fn session_open_srv_fns [TRANSPORT_N_SERVICES]
 
static session_listen_service_fn session_listen_srv_fns [TRANSPORT_N_SERVICES]
 
static session_fifo_rx_fnsession_tx_fns [TRANSPORT_TX_N_FNS]
 

Detailed Description

Session and session manager.

Definition in file session.c.

Typedef Documentation

typedef int(* session_listen_service_fn) (stream_session_t *, session_endpoint_t *)

Definition at line 1001 of file session.c.

typedef int(* session_open_service_fn) (u32, session_endpoint_t *, u32)

Definition at line 899 of file session.c.

typedef struct _session_switch_pool_args session_switch_pool_args_t

Function Documentation

int listen_session_get_local_session_endpoint ( stream_session_t listener,
session_endpoint_t sep 
)

Definition at line 1287 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

transport_connection_t* listen_session_get_transport ( stream_session_t s)

Definition at line 1280 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

stream_session_t* session_alloc ( u32  thread_index)

Definition at line 81 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int session_alloc_and_init ( segment_manager_t sm,
transport_connection_t tc,
u8  alloc_fifos,
stream_session_t **  ret_s 
)
static

Definition at line 160 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_alloc_fifos ( segment_manager_t sm,
stream_session_t s 
)

Definition at line 116 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static stream_session_t* session_alloc_for_connection ( transport_connection_t tc)
static

Definition at line 140 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* session_config_fn ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 1473 of file session.c.

+ Here is the call graph for this function:

int session_dgram_connect_notify ( transport_connection_t tc,
u32  old_thread_index,
stream_session_t **  new_session 
)

Move dgram session to the right thread.

Definition at line 666 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int session_enqueue_chain_tail ( stream_session_t s,
vlib_buffer_t b,
u32  offset,
u8  is_in_order 
)
inlinestatic

Enqueue buffer chain tail.

Definition at line 218 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_enqueue_dgram_connection ( stream_session_t s,
session_dgram_hdr_t *  hdr,
vlib_buffer_t b,
u8  proto,
u8  queue_event 
)

Definition at line 362 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void session_enqueue_discard_chain_bytes ( vlib_main_t vm,
vlib_buffer_t b,
vlib_buffer_t **  chain_b,
u32  n_bytes_to_drop 
)
inlinestatic

Discards bytes from buffer chain.

It discards n_bytes_to_drop starting at first buffer after chain_b

Definition at line 187 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int session_enqueue_notify ( stream_session_t s,
u8  block 
)
static

Notify session peer that new data has been enqueued.

Parameters
sStream session for which the event is to be generated.
blockFlag to indicate if call should block if event queue is full.
Returns
0 on succes or negative number if failed to send notification.

Definition at line 449 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_enqueue_stream_connection ( transport_connection_t tc,
vlib_buffer_t b,
u32  offset,
u8  queue_event,
u8  is_in_order 
)

Definition at line 306 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void session_flush_frames_main_thread ( vlib_main_t vm)

Definition at line 1307 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void session_free ( stream_session_t s)

Definition at line 108 of file session.c.

+ Here is the caller graph for this function:

transport_connection_t* session_get_transport ( stream_session_t s)

Definition at line 1267 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_listen_app ( stream_session_t s,
session_endpoint_t sep 
)

Definition at line 991 of file session.c.

int session_listen_cl ( stream_session_t s,
session_endpoint_t sep 
)

Definition at line 957 of file session.c.

+ Here is the call graph for this function:

int session_listen_vc ( stream_session_t s,
session_endpoint_t sep 
)

Definition at line 930 of file session.c.

+ Here is the call graph for this function:

int session_manager_flush_all_enqueue_events ( u8  transport_proto)

Definition at line 539 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_manager_flush_enqueue_events ( u8  transport_proto,
u32  thread_index 
)

Flushes queue of sessions that are to be notified of new data enqueued events.

Parameters
thread_indexThread index for which the flush is to be performed.
Returns
0 on success or a positive number indicating the number of failures due to API queue being full.

Definition at line 515 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssvm_private_t* session_manager_get_evt_q_segment ( void  )

Definition at line 1214 of file session.c.

+ Here is the caller graph for this function:

static clib_error_t* session_manager_main_enable ( vlib_main_t vm)
static

Definition at line 1315 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* session_manager_main_init ( vlib_main_t vm)

Definition at line 1460 of file session.c.

void session_node_enable_disable ( u8  is_en)

Definition at line 1405 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_open ( u32  app_index,
session_endpoint_t rmt,
u32  opaque 
)

Ask transport to open connection to remote transport endpoint.

Stores handle for matching request with reply since the call can be asynchronous. For instance, for TCP the 3-way handshake must complete before reply comes. Session is only created once connection is established.

Parameters
app_indexIndex of the application requesting the connect
stSession type requested.
tepRemote transport endpoint
opaqueOpaque data (typically, api_context) the application expects on open completion.

Definition at line 923 of file session.c.

+ Here is the caller graph for this function:

int session_open_app ( u32  app_index,
session_endpoint_t rmt,
u32  opaque 
)

Definition at line 890 of file session.c.

int session_open_cl ( u32  app_index,
session_endpoint_t rmt,
u32  opaque 
)

Definition at line 819 of file session.c.

+ Here is the call graph for this function:

int session_open_vc ( u32  app_index,
session_endpoint_t rmt,
u32  opaque 
)

Definition at line 855 of file session.c.

+ Here is the call graph for this function:

void session_register_transport ( transport_proto_t  transport_proto,
const transport_proto_vft_t vft,
u8  is_ip4,
u32  output_node 
)

Initialize session layer for given transport proto and ip version.

Allocates per session type (transport proto + ip version) data structures and adds arc from session queue node to session type output node.

Definition at line 1238 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void session_send_evt_to_thread ( u64  session_handle,
fifo_event_type_t  evt_type,
u32  thread_index,
void *  fp,
void *  rpc_args 
)
static

Definition at line 31 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void session_send_rpc_evt_to_thread ( u32  thread_index,
void *  fp,
void *  rpc_args 
)

Definition at line 68 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void session_send_session_evt_to_thread ( u64  session_handle,
fifo_event_type_t  evt_type,
u32  thread_index 
)

Definition at line 60 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_stream_connect_notify ( transport_connection_t tc,
u8  is_fail 
)

Definition at line 564 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void session_switch_pool ( void *  cb_args)
static

Definition at line 647 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

transport_service_type_t session_transport_service_type ( stream_session_t s)

Definition at line 1138 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

transport_tx_fn_type_t session_transport_tx_fn_type ( stream_session_t s)

Definition at line 1146 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 session_tx_fifo_max_dequeue ( transport_connection_t tc)

Definition at line 417 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8 session_tx_is_dgram ( stream_session_t s)

Definition at line 1154 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void session_vpp_event_queues_allocate ( session_manager_main_t smm)

Allocate event queues in the shared-memory segment.

That can either be a newly created memfd segment, that will need to be mapped by all stack users, or the binary api's svm region. The latter is assumed to be already mapped. NOTE that this assumption DOES NOT hold if api clients bootstrap shm api over sockets (i.e. use memfd segments) and vpp uses api svm region for event queues.

Definition at line 1169 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stream_session_accept ( transport_connection_t tc,
u32  listener_index,
u8  notify 
)

Accept a stream session.

Optionally ping the server by callback.

Definition at line 789 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_accept_notify ( transport_connection_t tc)

Definition at line 702 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_cleanup ( stream_session_t s)

Cleanup transport and session state.

Notify transport of the cleanup and free the session. This should be called only if transport reported some error and is already closed.

Definition at line 1122 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_delete ( stream_session_t s)

Cleans up session and lookup table.

Transport connection must still be valid.

Definition at line 737 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_delete_notify ( transport_connection_t tc)

Notification from transport that connection is being deleted.

This removes the session if it is still valid. It should be called only on previously fully established sessions. For instance failed connects should call stream_session_connect_notify and indicate that the connect has failed.

Definition at line 760 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 stream_session_dequeue_drop ( transport_connection_t tc,
u32  max_bytes 
)

Definition at line 434 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_disconnect ( stream_session_t s)

Initialize session disconnect.

Request is always sent to session node to ensure that all outstanding requests are served before transport is notified.

Definition at line 1063 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_disconnect_notify ( transport_connection_t tc)

Notification from transport that connection is being closed.

A disconnect is sent to application but state is not removed. Once disconnect is acknowledged by application, session disconnect is called. Ultimately this leads to close being called on transport (passive close).

Definition at line 720 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_disconnect_transport ( stream_session_t s)

Notify transport the session can be disconnected.

This should eventually result in a delete notification that allows us to cleanup session state. Called for both active/passive disconnects.

Must be called from the session's thread.

Definition at line 1107 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_init_fifos_pointers ( transport_connection_t tc,
u32  rx_pointer,
u32  tx_pointer 
)

Init fifo tail and head pointers.

Useful if transport uses absolute offsets for tracking ooo segments.

Definition at line 554 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stream_session_listen ( stream_session_t s,
session_endpoint_t sep 
)

Ask transport to listen on local transport endpoint.

Parameters
sSession for which listen will be called. Note that unlike established sessions, listen sessions are not associated to a thread.
tepLocal endpoint to be listened on.

Definition at line 1022 of file session.c.

+ Here is the caller graph for this function:

u8 stream_session_no_space ( transport_connection_t tc,
u32  thread_index,
u16  data_len 
)

Check if we have space in rx fifo to push more bytes.

Definition at line 402 of file session.c.

+ Here is the call graph for this function:

int stream_session_peek_bytes ( transport_connection_t tc,
u8 buffer,
u32  offset,
u32  max_bytes 
)

Definition at line 426 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void stream_session_reset_notify ( transport_connection_t tc)

Notify application that connection has been reset.

Definition at line 775 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stream_session_stop_listen ( stream_session_t s)

Ask transport to stop listening on local transport endpoint.

Parameters
sSession to stop listening on. It must be in state LISTENING.

Definition at line 1034 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* vnet_session_enable_disable ( vlib_main_t vm,
u8  is_en 
)

Definition at line 1439 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

session_listen_service_fn session_listen_srv_fns[TRANSPORT_N_SERVICES]
static
Initial value:
= {
}
int session_listen_cl(stream_session_t *s, session_endpoint_t *sep)
Definition: session.c:957
int session_listen_vc(stream_session_t *s, session_endpoint_t *sep)
Definition: session.c:930
int session_listen_app(stream_session_t *s, session_endpoint_t *sep)
Definition: session.c:991

Definition at line 1006 of file session.c.

session_manager_main_t session_manager_main

Definition at line 27 of file session.c.

session_open_service_fn session_open_srv_fns[TRANSPORT_N_SERVICES]
static
Initial value:
= {
}
int session_open_vc(u32 app_index, session_endpoint_t *rmt, u32 opaque)
Definition: session.c:855
int session_open_app(u32 app_index, session_endpoint_t *rmt, u32 opaque)
Definition: session.c:890
int session_open_cl(u32 app_index, session_endpoint_t *rmt, u32 opaque)
Definition: session.c:819

Definition at line 902 of file session.c.

session_fifo_rx_fn* session_tx_fns[TRANSPORT_TX_N_FNS]
static
Initial value:
= {
session_tx_fifo_dequeue_and_snd
}
session_fifo_rx_fn session_tx_fifo_peek_and_snd
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
session_fifo_rx_fn session_tx_fifo_dequeue_internal

Definition at line 1223 of file session.c.

Per-type vector of transport protocol virtual function tables.

Definition at line 23 of file transport.c.