FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
session.h File Reference
+ Include dependency graph for session.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rpc_args_t
 

Macros

#define HALF_OPEN_LOOKUP_INVALID_VALUE   ((u64)~0)
 
#define INVALID_INDEX   ((u32)~0)
 
#define MAX_HDRS_LEN   100 /* Max number of bytes for headers */
 
#define foreach_session_input_error
 

Typedefs

typedef struct _session_manager_main session_manager_main_t
 
typedef int( session_fifo_rx_fn) (vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_pkts)
 

Enumerations

enum  fifo_event_type_t {
  FIFO_EVENT_APP_RX, FIFO_EVENT_APP_TX, FIFO_EVENT_TIMEOUT, FIFO_EVENT_DISCONNECT,
  FIFO_EVENT_BUILTIN_RX, FIFO_EVENT_RPC
}
 
enum  session_error_t { SESSION_N_ERROR }
 
enum  session_queue_next_t {
  SESSION_QUEUE_NEXT_DROP, SESSION_QUEUE_NEXT_TCP_IP4_OUTPUT, SESSION_QUEUE_NEXT_IP4_LOOKUP, SESSION_QUEUE_NEXT_TCP_IP6_OUTPUT,
  SESSION_QUEUE_NEXT_IP6_LOOKUP, SESSION_QUEUE_N_NEXT
}
 

Functions

static const char * fifo_event_type_str (fifo_event_type_t et)
 
typedef CLIB_PACKED (struct{union{svm_fifo_t *fifo;u64 session_handle;rpc_args_t rpc_args;};u8 event_type;u16 event_id;}) session_fifo_event_t
 
u8 session_node_lookup_fifo_event (svm_fifo_t *f, session_fifo_event_t *e)
 
static session_manager_main_tvnet_get_session_manager_main ()
 
static u8 stream_session_is_valid (u32 si, u8 thread_index)
 
static stream_session_tstream_session_get (u32 si, u32 thread_index)
 
static stream_session_tstream_session_get_if_valid (u64 si, u32 thread_index)
 
static u64 stream_session_handle (stream_session_t *s)
 
static u32 stream_session_index_from_handle (u64 handle)
 
static u32 stream_session_thread_from_handle (u64 handle)
 
static void stream_session_parse_handle (u64 handle, u32 *index, u32 *thread_index)
 
static stream_session_tstream_session_get_from_handle (u64 handle)
 
static stream_session_tstream_session_listener_get (u8 sst, u64 si)
 
static u32 stream_session_get_index (stream_session_t *s)
 
static u32 stream_session_max_rx_enqueue (transport_connection_t *tc)
 
static u32 stream_session_rx_fifo_size (transport_connection_t *tc)
 
u32 stream_session_tx_fifo_max_dequeue (transport_connection_t *tc)
 
int stream_session_enqueue_data (transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
 
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)
 
int stream_session_connect_notify (transport_connection_t *tc, u8 is_fail)
 
void stream_session_init_fifos_pointers (transport_connection_t *tc, u32 rx_pointer, u32 tx_pointer)
 Init fifo tail and head pointers. 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_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 sst, u8 notify)
 Accept a stream session. More...
 
int stream_session_open (u32 app_index, session_type_t st, transport_endpoint_t *tep, transport_connection_t **tc)
 Ask transport to open connection to remote transport endpoint. More...
 
int stream_session_listen (stream_session_t *s, transport_endpoint_t *tep)
 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)
 Disconnect session and propagate to transport. More...
 
void stream_session_cleanup (stream_session_t *s)
 Cleanup transport and session state. More...
 
void session_send_session_evt_to_thread (u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
 
u8format_stream_session (u8 *s, va_list *args)
 Format stream session as per the following format. More...
 
uword unformat_stream_session (unformat_input_t *input, va_list *args)
 
uword unformat_transport_connection (unformat_input_t *input, va_list *args)
 
int send_session_connected_callback (u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
 
clib_error_tvnet_session_enable_disable (vlib_main_t *vm, u8 is_en)
 
static unix_shared_memory_queue_tsession_manager_get_vpp_event_queue (u32 thread_index)
 
int session_manager_flush_enqueue_events (u32 thread_index)
 Flushes queue of sessions that are to be notified of new data enqueued events. More...
 
static u64 listen_session_get_handle (stream_session_t *s)
 
static stream_session_tlisten_session_get_from_handle (u64 handle)
 
static stream_session_tlisten_session_new (session_type_t type)
 
static stream_session_tlisten_session_get (session_type_t type, u32 index)
 
static void listen_session_del (stream_session_t *s)
 
static stream_session_tsession_manager_get_listener (u8 type, u32 index)
 
static void session_manager_set_transport_rx_fn (u8 type, u8 is_peek)
 
session_type_t session_type_from_proto_and_ip (transport_proto_t proto, u8 is_ip4)
 
static u8 session_manager_is_enabled ()
 

Variables

session_fifo_rx_fn session_tx_fifo_peek_and_snd
 
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
 
session_manager_main_t session_manager_main
 
vlib_node_registration_t session_queue_node
 (constructor) VLIB_REGISTER_NODE (session_queue_node) More...
 

Macro Definition Documentation

#define foreach_session_input_error
Value:
_(NO_SESSION, "No session drops") \
_(NO_LISTENER, "No listener for dst port drops") \
_(ENQUEUED, "Packets pushed into rx fifo") \
_(NOT_READY, "Session not ready packets") \
_(FIFO_FULL, "Packets dropped for lack of rx fifo space") \
_(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \
_(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \
_(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \
_(NO_SPACE, "Couldn't allocate a fifo pair")

Definition at line 63 of file session.h.

#define HALF_OPEN_LOOKUP_INVALID_VALUE   ((u64)~0)

Definition at line 25 of file session.h.

#define INVALID_INDEX   ((u32)~0)

Definition at line 26 of file session.h.

#define MAX_HDRS_LEN   100 /* Max number of bytes for headers */

Definition at line 29 of file session.h.

Typedef Documentation

typedef int( session_fifo_rx_fn) (vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_pkts)

Definition at line 116 of file session.h.

typedef struct _session_manager_main session_manager_main_t

Definition at line 113 of file session.h.

Enumeration Type Documentation

Enumerator
FIFO_EVENT_APP_RX 
FIFO_EVENT_APP_TX 
FIFO_EVENT_TIMEOUT 
FIFO_EVENT_DISCONNECT 
FIFO_EVENT_BUILTIN_RX 
FIFO_EVENT_RPC 

Definition at line 31 of file session.h.

Enumerator
SESSION_N_ERROR 

Definition at line 74 of file session.h.

Enumerator
SESSION_QUEUE_NEXT_DROP 
SESSION_QUEUE_NEXT_TCP_IP4_OUTPUT 
SESSION_QUEUE_NEXT_IP4_LOOKUP 
SESSION_QUEUE_NEXT_TCP_IP6_OUTPUT 
SESSION_QUEUE_NEXT_IP6_LOOKUP 
SESSION_QUEUE_N_NEXT 

Definition at line 83 of file session.h.

Function Documentation

typedef CLIB_PACKED ( struct{union{svm_fifo_t *fifo;u64 session_handle;rpc_args_t rpc_args;};u8 event_type;u16 event_id;}  )
static const char* fifo_event_type_str ( fifo_event_type_t  et)
inlinestatic

Definition at line 42 of file session.h.

u8* format_stream_session ( u8 s,
va_list *  args 
)

Format stream session as per the following format.

verbose: "Connection", "Rx fifo", "Tx fifo", "Session Index" non-verbose: "Connection"

Definition at line 52 of file session_cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void listen_session_del ( stream_session_t s)
inlinestatic

Definition at line 399 of file session.h.

+ Here is the caller graph for this function:

static stream_session_t* listen_session_get ( session_type_t  type,
u32  index 
)
inlinestatic

Definition at line 392 of file session.h.

+ Here is the caller graph for this function:

static stream_session_t* listen_session_get_from_handle ( u64  handle)
inlinestatic

Definition at line 360 of file session.h.

+ Here is the caller graph for this function:

static u64 listen_session_get_handle ( stream_session_t s)
inlinestatic

Definition at line 353 of file session.h.

+ Here is the caller graph for this function:

static stream_session_t* listen_session_new ( session_type_t  type)
inlinestatic

Definition at line 377 of file session.h.

+ Here is the caller graph for this function:

int send_session_connected_callback ( u32  app_index,
u32  api_context,
stream_session_t s,
u8  is_fail 
)

Definition at line 155 of file session_api.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int session_manager_flush_enqueue_events ( 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 392 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_manager_get_listener ( u8  type,
u32  index 
)
inlinestatic

Definition at line 405 of file session.h.

+ Here is the caller graph for this function:

static unix_shared_memory_queue_t* session_manager_get_vpp_event_queue ( u32  thread_index)
inlinestatic

Definition at line 345 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u8 session_manager_is_enabled ( )
inlinestatic

Definition at line 423 of file session.h.

+ Here is the caller graph for this function:

static void session_manager_set_transport_rx_fn ( u8  type,
u8  is_peek 
)
inlinestatic

Definition at line 412 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8 session_node_lookup_fifo_event ( svm_fifo_t f,
session_fifo_event_t *  e 
)

Definition at line 496 of file session_node.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 730 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

session_type_t session_type_from_proto_and_ip ( transport_proto_t  proto,
u8  is_ip4 
)

Definition at line 820 of file session.c.

+ Here is the caller graph for this function:

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

Accept a stream session.

Optionally ping the server by callback.

Definition at line 594 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 506 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, wait for a delete notify to actually remove the session state.

Definition at line 776 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stream_session_connect_notify ( transport_connection_t tc,
u8  is_fail 
)

Definition at line 441 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 565 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 307 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)

Disconnect session and propagate to transport.

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

Should be called from the session's thread.

Definition at line 763 of file session.c.

+ 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 524 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 220 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static stream_session_t* stream_session_get ( u32  si,
u32  thread_index 
)
inlinestatic

Definition at line 217 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static stream_session_t* stream_session_get_from_handle ( u64  handle)
inlinestatic

Definition at line 262 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static stream_session_t* stream_session_get_if_valid ( u64  si,
u32  thread_index 
)
inlinestatic

Definition at line 224 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 stream_session_get_index ( stream_session_t s)
inlinestatic

Definition at line 277 of file session.h.

+ Here is the caller graph for this function:

static u64 stream_session_handle ( stream_session_t s)
inlinestatic

Definition at line 237 of file session.h.

+ Here is the caller graph for this function:

static u32 stream_session_index_from_handle ( u64  handle)
inlinestatic

Definition at line 243 of file session.h.

+ 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 431 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u8 stream_session_is_valid ( u32  si,
u8  thread_index 
)
inlinestatic

Definition at line 203 of file session.h.

+ Here is the caller graph for this function:

int stream_session_listen ( stream_session_t s,
transport_endpoint_t tep 
)

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 676 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static stream_session_t* stream_session_listener_get ( u8  sst,
u64  si 
)
inlinestatic

Definition at line 271 of file session.h.

static u32 stream_session_max_rx_enqueue ( transport_connection_t tc)
inlinestatic

Definition at line 286 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stream_session_open ( u32  app_index,
session_type_t  st,
transport_endpoint_t rmt,
transport_connection_t **  res 
)

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
resResulting transport connection .

Definition at line 637 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void stream_session_parse_handle ( u64  handle,
u32 index,
u32 thread_index 
)
inlinestatic

Definition at line 255 of file session.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 299 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 580 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 stream_session_rx_fifo_size ( transport_connection_t tc)
inlinestatic

Definition at line 293 of file session.h.

+ 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 707 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 stream_session_thread_from_handle ( u64  handle)
inlinestatic

Definition at line 249 of file session.h.

+ Here is the caller graph for this function:

u32 stream_session_tx_fifo_max_dequeue ( transport_connection_t tc)

Definition at line 290 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_stream_session ( unformat_input_t input,
va_list *  args 
)

Definition at line 135 of file session_cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword unformat_transport_connection ( unformat_input_t input,
va_list *  args 
)

Definition at line 166 of file session_cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static session_manager_main_t* vnet_get_session_manager_main ( )
inlinestatic

Definition at line 197 of file session.h.

+ 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 928 of file session.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

session_manager_main_t session_manager_main

Definition at line 28 of file session.c.

vlib_node_registration_t session_queue_node
Initial value:
=
{
.function = session_queue_node_fn,
.name = "session-queue",
.format_trace = format_session_queue_trace,
.error_strings = session_queue_error_strings,
.n_next_nodes = SESSION_QUEUE_N_NEXT,
.state = VLIB_NODE_STATE_DISABLED,
.next_nodes =
{
[SESSION_QUEUE_NEXT_DROP] = "error-drop",
},
}
static uword session_queue_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: session_node.c:539
static char * session_queue_error_strings[]
Definition: session_node.c:61
#define ARRAY_LEN(x)
Definition: clib.h:59
static u8 * format_session_queue_trace(u8 *s, va_list *args)
Definition: session_node.c:35

(constructor) VLIB_REGISTER_NODE (session_queue_node)

Definition at line 46 of file session_node.c.

session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
session_fifo_rx_fn session_tx_fifo_peek_and_snd