15 #ifndef __included_session_h__ 16 #define __included_session_h__ 24 #define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0) 25 #define INVALID_INDEX ((u32)~0) 28 #define MAX_HDRS_LEN 100 38 #define foreach_session_input_error \ 39 _(NO_SESSION, "No session drops") \ 40 _(NO_LISTENER, "No listener for dst port drops") \ 41 _(ENQUEUED, "Packets pushed into rx fifo") \ 42 _(NOT_READY, "Session not ready packets") \ 43 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \ 44 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \ 45 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \ 46 _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \ 47 _(NO_SPACE, "Couldn't allocate a fifo pair") 51 #define _(sym,str) SESSION_ERROR_##sym, 68 #define foreach_session_type \ 76 #define _(A, a) SESSION_TYPE_##A, 101 }) session_fifo_event_t;
103 typedef struct _stream_session_t
127 u32 connection_index;
136 u32 server_segment_index;
139 typedef struct _session_manager
142 u32 *segment_indices;
150 u32 add_segment_size;
163 u32 thread_index,
int *n_tx_pkts);
168 struct _session_manager_main
171 clib_bihash_16_8_t v4_session_hash;
172 clib_bihash_48_8_t v6_session_hash;
175 clib_bihash_16_8_t v4_half_open_hash;
176 clib_bihash_48_8_t v6_half_open_hash;
188 u8 *current_enqueue_epoch;
191 u32 **session_indices_to_enqueue_by_thread;
197 session_fifo_event_t **evts_partially_read;
200 session_fifo_event_t **fifo_events;
206 u32 unique_segment_name_counter;
244 return session_manager_main.vpp_event_queues[thread_index];
249 session_type_t session_type)
252 smm->connect_manager_index[session_type]);
271 u16 lcl_port,
u8 proto);
274 u16 rmt_port,
u8 proto,
277 u16 lcl_port,
u8 proto);
280 u16 rmt_port,
u8,
u32 thread_index);
284 u16 rmt_port,
u8 proto,
289 u16 rmt_port,
u8 proto,
292 u16 lcl_port,
u8 proto);
297 ASSERT ((
u32) (ti_and_si >> 32) == thread_index);
299 ti_and_si & 0xFFFFFFFFULL);
311 if (thread_index >=
vec_len (session_manager_main.sessions))
330 return s - session_manager_main.listen_sessions[s->session_type];
332 return s - session_manager_main.sessions[s->thread_index];
346 return s->server_rx_fifo->nitems;
355 u32 offset,
u32 max_bytes);
370 u16 port_host_byte_order,
u32 api_client_index);
int stream_session_enqueue_data(transport_connection_t *tc, u8 *data, u16 len, u8 queue_event)
void session_register_transport(u8 type, const transport_proto_vft_t *vft)
transport_proto_vft_t * session_get_transport_vft(u8 type)
int stream_session_start_listen(u32 server_index, ip46_address_t *ip, u16 port)
int session_manager_add_first_segment(session_manager_main_t *smm, session_manager_t *sm, u32 segment_size, u8 **segment_name)
struct _transport_connection transport_connection_t
struct _vlib_node_registration vlib_node_registration_t
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
int stream_session_open(u8 sst, ip46_address_t *addr, u16 port_host_byte_order, u32 api_client_index)
void session_manager_del(session_manager_main_t *smm, session_manager_t *sm)
#define foreach_session_type
stream_session_t * stream_session_lookup_listener(ip46_address_t *lcl, u16 lcl_port, u8 proto)
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
session_fifo_rx_fn session_tx_fifo_peek_and_snd
struct _stream_session_t stream_session_t
static u32 stream_session_fifo_size(transport_connection_t *tc)
static stream_session_t * stream_session_get(u64 si, u32 thread_index)
stream_session_t * stream_session_lookup_listener6(ip6_address_t *lcl, u16 lcl_port, u8 proto)
static u32 stream_session_max_enqueue(transport_connection_t *tc)
static session_manager_t * session_manager_get(u32 index)
void stream_session_accept_notify(transport_connection_t *tc)
u32 stream_session_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
stream_session_t * stream_session_lookup4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
Looks up a session based on the 5-tuple passed as argument.
struct _transport_proto_vft transport_proto_vft_t
static session_manager_main_t * vnet_get_session_manager_main()
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void session_manager_get_segment_info(u32 index, u8 **name, u32 *size)
struct _session_manager_main session_manager_main_t
void connects_session_manager_init(session_manager_main_t *smm, u8 session_type)
u32 stream_session_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
static u32 stream_session_get_index(stream_session_t *s)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
stream_session_t * stream_session_lookup_listener4(ip4_address_t *lcl, u16 lcl_port, u8 proto)
void stream_session_disconnect(stream_session_t *s)
Disconnect session and propagate to transport.
transport_connection_t * stream_session_lookup_transport4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
struct _session_manager session_manager_t
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
typedef CLIB_PACKED(struct{svm_fifo_t *fifo;u8 event_type;u16 event_id;u32 enqueue_length;}) session_fifo_event_t
session_manager_main_t session_manager_main
static stream_session_t * stream_session_get_if_valid(u64 si, u32 thread_index)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
void stream_session_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
static stream_session_t * stream_session_get_tsi(u64 ti_and_si, u32 thread_index)
void stream_session_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
transport_connection_t * stream_session_lookup_transport6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index)
static stream_session_t * stream_session_listener_get(u8 sst, u64 si)
stream_session_t * stream_session_lookup6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8, u32 thread_index)
static session_manager_t * connects_session_manager_get(session_manager_main_t *smm, session_type_t session_type)
int stream_session_accept(transport_connection_t *tc, u32 listener_index, u8 sst, u8 notify)
Accept a stream session.
void stream_session_connect_notify(transport_connection_t *tc, u8 sst, u8 is_fail)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_session_input_error
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)
void stream_session_stop_listen(u32 server_index)
void stream_session_disconnect_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
int session_manager_flush_enqueue_events(u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
struct _unix_shared_memory_queue unix_shared_memory_queue_t