22 #undef __included_bihash_template_h__ 53 }) v4_connection_key_t;
78 u16 lcl_port,
u16 rmt_port,
u8 proto)
80 v4_connection_key_t *key = (v4_connection_key_t *) kv->
key;
82 key->src.as_u32 = lcl->
as_u32;
83 key->dst.as_u32 = rmt->
as_u32;
84 key->src_port = lcl_port;
85 key->dst_port = rmt_port;
95 v4_connection_key_t *key = (v4_connection_key_t *) kv->
key;
97 key->src.as_u32 = lcl->
as_u32;
99 key->src_port = lcl_port;
109 make_v4_ss_kv (kv, &t->lcl_ip.ip4, &t->rmt_ip.ip4, t->lcl_port, t->rmt_port,
115 u16 lcl_port,
u16 rmt_port,
u8 proto)
119 key->src.as_u64[0] = lcl->
as_u64[0];
120 key->src.as_u64[1] = lcl->
as_u64[1];
121 key->dst.as_u64[0] = rmt->
as_u64[0];
122 key->dst.as_u64[1] = rmt->
as_u64[1];
123 key->src_port = lcl_port;
124 key->dst_port = rmt_port;
137 key->src.as_u64[0] = lcl->
as_u64[0];
138 key->src.as_u64[1] = lcl->
as_u64[1];
139 key->dst.as_u64[0] = 0;
140 key->dst.as_u64[1] = 0;
141 key->src_port = lcl_port;
152 make_v6_ss_kv (kv, &t->lcl_ip.ip6, &t->rmt_ip.ip6, t->lcl_port, t->rmt_port,
171 clib_bihash_add_del_16_8 (&sl->v4_session_hash, &kv4, 1 );
177 clib_bihash_add_del_48_8 (&sl->v6_session_hash, &kv6, 1 );
187 tc = tp_vfts[s->session_type].get_connection (s->connection_index,
202 return clib_bihash_add_del_16_8 (&sl->v4_session_hash, &kv4,
208 return clib_bihash_add_del_48_8 (&sl->v6_session_hash, &kv6,
219 ts = tp_vfts[s->session_type].get_connection (s->connection_index,
236 (void) clib_bihash_add_del_16_8 (&sl->v4_half_open_hash, &kv4,
243 (void) clib_bihash_add_del_48_8 (&sl->v6_half_open_hash, &kv6,
258 clib_bihash_add_del_16_8 (&sl->v4_half_open_hash, &kv4,
264 clib_bihash_add_del_48_8 (&sl->v6_half_open_hash, &kv6,
277 rv = clib_bihash_search_inline_16_8 (&sl->v4_session_hash, &kv4);
283 rv = clib_bihash_search_inline_16_8 (&sl->v4_session_hash, &kv4);
298 u16 lcl_port,
u16 rmt_port,
u8 proto)
307 rv = clib_bihash_search_inline_16_8 (&sl->v4_session_hash, &kv4);
316 rv = clib_bihash_search_inline_16_8 (&sl->v4_half_open_hash, &kv4);
330 rv = clib_bihash_search_inline_48_8 (&sl->v6_session_hash, &kv6);
335 kv6.
key[0] = kv6.
key[1] = 0;
336 rv = clib_bihash_search_inline_48_8 (&sl->v6_session_hash, &kv6);
349 u16 lcl_port,
u16 rmt_port,
u8 proto)
357 rv = clib_bihash_search_inline_48_8 (&sl->v6_session_hash, &kv6);
366 rv = clib_bihash_search_inline_48_8 (&sl->v6_half_open_hash, &kv6);
377 case SESSION_TYPE_IP4_UDP:
378 case SESSION_TYPE_IP4_TCP:
381 case SESSION_TYPE_IP6_UDP:
382 case SESSION_TYPE_IP6_TCP:
391 ip46_address_t * rmt,
u16 lcl_port,
392 u16 rmt_port,
u8 proto)
401 case SESSION_TYPE_IP4_UDP:
402 case SESSION_TYPE_IP4_TCP:
403 make_v4_ss_kv (&kv4, &lcl->ip4, &rmt->ip4, lcl_port, rmt_port, proto);
404 rv = clib_bihash_search_inline_16_8 (&sl->v4_half_open_hash, &kv4);
411 case SESSION_TYPE_IP6_UDP:
412 case SESSION_TYPE_IP6_TCP:
413 make_v6_ss_kv (&kv6, &lcl->ip6, &rmt->ip6, lcl_port, rmt_port, proto);
414 rv = clib_bihash_search_inline_48_8 (&sl->v6_half_open_hash, &kv6);
427 u16 lcl_port,
u16 rmt_port,
u8 proto)
434 return tp_vfts[proto].get_half_open (handle & 0xFFFFFFFF);
441 ASSERT ((
u32) (ti_and_si >> 32) == thread_index);
443 ti_and_si & 0xFFFFFFFFULL);
448 u16 lcl_port,
u16 rmt_port,
u8 proto,
458 rv = clib_bihash_search_inline_16_8 (&sl->v4_session_hash, &kv4);
462 return tp_vfts[s->session_type].get_connection (s->connection_index,
469 return tp_vfts[s->session_type].get_listener (s->connection_index);
472 rv = clib_bihash_search_inline_16_8 (&sl->v4_half_open_hash, &kv4);
474 return tp_vfts[proto].get_half_open (kv4.
value & 0xFFFFFFFF);
480 u16 lcl_port,
u16 rmt_port,
u8 proto)
489 rv = clib_bihash_search_inline_16_8 (&sl->v4_session_hash, &kv4);
493 return tp_vfts[s->session_type].get_connection (s->connection_index,
500 return tp_vfts[s->session_type].get_listener (s->connection_index);
503 rv = clib_bihash_search_inline_16_8 (&sl->v4_half_open_hash, &kv4);
505 return tp_vfts[proto].get_half_open (kv4.
value & 0xFFFFFFFF);
511 u16 lcl_port,
u16 rmt_port,
u8 proto,
520 rv = clib_bihash_search_inline_48_8 (&sl->v6_session_hash, &kv6);
524 return tp_vfts[s->session_type].get_connection (s->connection_index,
531 return tp_vfts[s->session_type].get_listener (s->connection_index);
534 rv = clib_bihash_search_inline_48_8 (&sl->v6_half_open_hash, &kv6);
536 return tp_vfts[proto].get_half_open (kv6.
value & 0xFFFFFFFF);
543 u16 lcl_port,
u16 rmt_port,
u8 proto)
551 rv = clib_bihash_search_inline_48_8 (&sl->v6_session_hash, &kv6);
555 return tp_vfts[s->session_type].get_connection (s->connection_index,
562 return tp_vfts[s->session_type].get_listener (s->connection_index);
565 rv = clib_bihash_search_inline_48_8 (&sl->v6_half_open_hash, &kv6);
567 return tp_vfts[proto].get_half_open (kv6.
value & 0xFFFFFFFF);
572 #define foreach_hash_table_parameter \ 573 _(v4,session,buckets,20000) \ 574 _(v4,session,memory,(64<<20)) \ 575 _(v6,session,buckets,20000) \ 576 _(v6,session,memory,(64<<20)) \ 577 _(v4,halfopen,buckets,20000) \ 578 _(v4,halfopen,memory,(64<<20)) \ 579 _(v6,halfopen,buckets,20000) \ 580 _(v6,halfopen,memory,(64<<20)) 587 #define _(af,table,parm,value) \ 588 u32 configured_##af##_##table##_table_##parm = value; 592 #define _(af,table,parm,value) \ 593 if (session_manager_main.configured_##af##_##table##_table_##parm) \ 594 configured_##af##_##table##_table_##parm = \ 595 session_manager_main.configured_##af##_##table##_table_##parm; 599 clib_bihash_init_16_8 (&sl->v4_session_hash,
"v4 session table",
600 configured_v4_session_table_buckets,
601 configured_v4_session_table_memory);
602 clib_bihash_init_48_8 (&sl->v6_session_hash,
"v6 session table",
603 configured_v6_session_table_buckets,
604 configured_v6_session_table_memory);
605 clib_bihash_init_16_8 (&sl->v4_half_open_hash,
"v4 half-open table",
606 configured_v4_halfopen_table_buckets,
607 configured_v4_halfopen_table_memory);
608 clib_bihash_init_48_8 (&sl->v6_half_open_hash,
"v6 half-open table",
609 configured_v6_halfopen_table_buckets,
610 configured_v6_halfopen_table_memory);
static void make_v4_ss_kv_from_tc(session_kv4_t *kv, transport_connection_t *t)
clib_bihash_kv_48_8_t session_kv6_t
struct _transport_connection transport_connection_t
transport_connection_t * stream_session_lookup_transport6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
session_manager_main_t session_manager_main
struct _transport_proto_vft transport_proto_vft_t
int stream_session_table_del(stream_session_t *s)
int stream_session_table_del_for_tc(transport_connection_t *tc)
static void make_v6_listener_kv(session_kv6_t *kv, ip6_address_t *lcl, u16 lcl_port, u8 proto)
#define foreach_hash_table_parameter
void stream_session_half_open_table_del(transport_connection_t *tc)
static stream_session_t * session_manager_get_listener(u8 type, u32 index)
transport_proto_vft_t * tp_vfts
Per-type vector of transport protocol virtual function tables.
static void make_v6_ss_kv(session_kv6_t *kv, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
void stream_session_table_add(session_manager_main_t *smm, stream_session_t *s, u64 value)
transport_connection_t * stream_session_half_open_lookup(ip46_address_t *lcl, ip46_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
struct _stream_session_t stream_session_t
transport_connection_t * stream_session_lookup_transport4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
struct _session_lookup session_lookup_t
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static stream_session_t * stream_session_get_tsi(u64 ti_and_si, u32 thread_index)
static void make_v6_ss_kv_from_tc(session_kv6_t *kv, transport_connection_t *t)
transport_connection_t * stream_session_lookup_transport_wt6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 my_thread_index)
stream_session_t * stream_session_lookup_listener6(ip6_address_t *lcl, u16 lcl_port, u8 proto)
struct _session_manager_main session_manager_main_t
stream_session_t * stream_session_lookup_listener4(ip4_address_t *lcl, u16 lcl_port, u8 proto)
stream_session_t * stream_session_lookup6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
stream_session_t * stream_session_lookup_listener(ip46_address_t *lcl, u16 lcl_port, u8 proto)
void stream_session_half_open_table_add(transport_connection_t *tc, u64 value)
stream_session_t * stream_session_lookup4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
Looks up a session based on the 5-tuple passed as argument.
void stream_session_table_add_for_tc(transport_connection_t *tc, u64 value)
typedef CLIB_PACKED(struct{union{struct{ip4_address_t src;ip4_address_t dst;u16 src_port;u16 dst_port;u32 proto;};u64 as_u64[2];};})
transport_connection_t * stream_session_lookup_transport_wt4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 my_thread_index)
static void make_v4_listener_kv(session_kv4_t *kv, ip4_address_t *lcl, u16 lcl_port, u8 proto)
session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
#define HALF_OPEN_LOOKUP_INVALID_VALUE
void session_lookup_init(void)
static session_lookup_t session_lookup
Generate typed init functions for multiple hash table styles...
u64 stream_session_half_open_lookup_handle(ip46_address_t *lcl, ip46_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
static void make_v4_ss_kv(session_kv4_t *kv, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
static stream_session_t * stream_session_get_from_handle(u64 handle)
clib_bihash_kv_16_8_t session_kv4_t